Posted November 19, 20168 yr 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.
November 20, 20168 yr Add some break points, then slowly debug it (step into) and find where it roughly appears to be recursively calling net.minecraft.nbt.NBTTagCompound.copy at lines 523 17 525 Currently updating my Mod to 1.10.2 https://bitbucket.org/hugo_the_dwarf/riseoftristram2016/src?at=master
November 20, 20168 yr 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.