Started by
Suzu
on
Topic category: Help with Minecraft modding (Java Edition)
Hello, I'm making a mod that you can storage your XP levels and you can watch your XP levels in the book.
This is the first item, the basic book:
@Override
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
int xp = 0;
super.appendHoverText(itemstack, world, list, flag);
xp = (int) ((itemstack).getOrCreateTag().getDouble("xp"));
list.add(new TextComponent((("\u00A77") + "" + ((xp)) + "" + ("/10 XP"))));
}
This is the problem, I want to make the same lore but similar to an enderchest, so instead of using an item NBT I need an entity NBT (I guess), this is all I could found by myself:
@Override
public void appendHoverText(ItemStack itemstack, Level world, List<Component> list, TooltipFlag flag) {
int xp_ender = 0;
super.appendHoverText(itemstack, world, list, flag);
xp_ender = (int) ((entity).getPersistentData().getDouble("xp_ender"));
list.add(new TextComponent((("\u00A77") + "" + ((xp_ender)) + "" + ("/30 XP"))));
}
I'm very noob with Java so I don't really understand coding, any idea about what is wrong?
I have the same problem get me up on discord perhaps we can figure out stuff together.
Here is my ID: Nosferatu#3742