表情包构造类 demo
package demo;
import link.botwmcs.fizzy.client.formatting.emoji.EmojiClickContext;
import link.botwmcs.fizzy.client.formatting.emoji.EmojiPack;
import link.botwmcs.fizzy.client.formatting.emoji.EmojiRegistry;
import link.botwmcs.fizzy.client.formatting.inline.AnimatedInlineImageSource;
import link.botwmcs.fizzy.client.formatting.inline.StaticInlineImageSource;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import java.util.List;
public final class DemoEmojiPack implements EmojiPack {
public static final String ID = "demo_pack";
public static void register() {
EmojiRegistry.registerPack(new DemoEmojiPack());
}
@Override
public String id() {
return ID;
}
@Override
public void register(Registrar registrar) {
registrar.token(
"spark",
new StaticInlineImageSource(
ResourceLocation.fromNamespaceAndPath("fizzy", "textures/gui/components/icon/star_4x3.png"),
16.0f,
16.0f
)
);
registrar.token(
"pulse",
new AnimatedInlineImageSource(
List.of(
ResourceLocation.fromNamespaceAndPath("fizzy", "textures/gui/components/icon/heart.png"),
ResourceLocation.fromNamespaceAndPath("fizzy", "textures/gui/components/icon/warning.png")
),
120L,
16.0f,
16.0f
)
);
registrar.tokenInteractive(
"help",
new StaticInlineImageSource(
ResourceLocation.fromNamespaceAndPath("fizzy", "textures/gui/components/icon/light-bulb.png"),
16.0f,
16.0f
),
DemoEmojiPack::onHelpClicked
);
}
private static void onHelpClicked(EmojiClickContext ctx) {
if (ctx.minecraft().player != null) {
ctx.minecraft().player.sendSystemMessage(Component.literal("Clicked :" + ctx.token() + ":"));
}
}
}Last updated on