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.

Featured Replies

Posted

So I have the following code to add a tooltip to an item:

@SubscribeEvent
public void onItemTooltip(ItemTooltipEvent event) {
    ItemStack stack = event.getItemStack();
    NBTTagCompound tag = stack.getTagCompound();
    if (tag == null) {
        return;
    }

    if (!tag.getString("infused_element").equals("")) {
        Element element = Element.valueOf(tag.getString("infused_element"));
        int level = tag.getInteger("infusion_level");

        event.getToolTip().add(String.format(TOOLTIP_FORMAT, element.toString(), RomanNumber.toRoman(level)));
    }
}

 

When in game I look at an item with this NBT tag the game crashes with the following error:

[12:03:21] [server thread/ERROR]: Encountered an unexpected exception
net.minecraft.util.ReportedException: Ticking player
at net.minecraft.server.MinecraftServer.updateTimeLightAndEntities(MinecraftServer.java:789) ~[MinecraftServer.class:?]
at net.minecraft.server.MinecraftServer.tick(MinecraftServer.java:687) ~[MinecraftServer.class:?]
at net.minecraft.server.integrated.IntegratedServer.tick(IntegratedServer.java:156) ~[integratedServer.class:?]
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:536) [MinecraftServer.class:?]
at java.lang.Thread.run(Thread.java:745) [?:1.8.0_111]
Caused by: java.lang.StackOverflowError
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:523) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:17) ~[NBTTagCompound.class:?]
at net.minecraft.nbt.NBTTagCompound.copy(NBTTagCompound.java:525) ~[NBTTagCompound.class:?]

 

Any idea what I'm doing wrong?

I'm a plugin developer, and I just started modding. Don't blame me for doing things wrong, Forge is not the same as Bukkit.

Hi

 

It looks to me like you've somehow managed to create an NBTTagCompound "A" which contains an element that has been set to itself (i.e. "A").

So when vanilla tries to copy your "A", it keeps trying to copy all the elements including the one that points to "A", i.e. a recursive loop.

 

I'm not sure how you managed to do that.  Personally I would follow hugo's advice and use your debugger to set a breakpoint at onItemTooltip and then check what is happening when you modify the tag.

 

-TGG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

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.