Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Sheker

Members
  • Joined

  • Last visited

Everything posted by Sheker

  1. Thank you for your help, it ended up working. Did an override on readNBTShareTag where it wrote all NBT data to the handler's slots, and now the tooltip works immediately on servers.
  2. @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, java.util.List<String> tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, (java.util.List<String>) tooltip, flagIn); IItemHandler itemHandler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); for (int i = 0; i < itemHandler.getSlots() - 1; i++) { ItemStack displayedStack = itemHandler.getStackInSlot(i); if (!displayedStack.isEmpty() && displayedStack.getItem() != Item.getItemFromBlock(Blocks.AIR)) { tooltip.add(TextFormatting.GRAY + displayedStack.getDisplayName()); } } } Hi everyone, I have an item that opens its contents on right-click. I've been trying to have a tooltip similar to how Shulker Boxes have a tooltip listing all its contents. It's close to how I want it to work on singleplayer, but the tooltip only updates when I right-click and open up the item GUI again. I also have the problem of not being able to see the tooltip on a server. I've looked around and the closest solution I've found is to override getNBTShareTag(), but I have no idea where to start and how it works as none of my data seems to be saved. Here is my code for my attempt to utilise getNBTShareTag to solve the problem: @Override public NBTTagCompound getNBTShareTag(ItemStack stack) { IItemHandler handler = stack.getCapability(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, null); NBTBase capTag = CapabilityItemHandler.ITEM_HANDLER_CAPABILITY.getStorage().writeNBT(CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, handler, null); NBTTagCompound tag = stack.getTagCompound(); if (tag == null) { tag = new NBTTagCompound(); } if (capTag != null) { tag.setTag("GemInventory", capTag); } return tag; } @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, java.util.List<String> tooltip, ITooltipFlag flagIn) { super.addInformation(stack, worldIn, (java.util.List<String>) tooltip, flagIn); if (!stack.hasTagCompound()) { stack.setTagCompound(new NBTTagCompound()); } NBTTagCompound itemTagCompound = stack.getTagCompound(); NBTTagList list = itemTagCompound.getTagList("GemInventory", 10);; for (int i = 0; i < list.tagCount(); i++) { ItemStack slotStack = new ItemStack(list.getCompoundTagAt(i)); if (!slotStack.isEmpty()) { tooltip.add("Test"); } } }

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.