Posted July 23, 20187 yr @SubscribeEvent public void itemPickup(PlayerEvent.ItemPickupEvent event){ ItemStack stack = event.getStack(); if (stack.getItem().equals(ModItems.mobSoul)) { System.out.println("You picked up Mob Soul"); NBTTagCompound nbt = stack.getTagCompound(); if (nbt == null) { nbt = new NBTTagCompound(); System.out.println("NBT Created for Mob Soul"); } if (nbt.hasKey("potency")) { nbt.setInteger("potency", nbt.getInteger("potency")); } else { System.out.println("Random Value generated for Potency value"); nbt.setInteger("potency", (int) (Math.random() * 100) + 1); } System.out.println("Value written to NBT tag"); stack.setTagCompound(nbt); } } This is my Event code, so what I want to do is when I pick up my custom item from a mob drop, it will generate a random number to be put inside of a tooltip showing how much "potency" the item has. @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List<String> tooltip, ITooltipFlag flagIn) { if (stack.hasTagCompound() && stack.getTagCompound().hasKey("potency")) { NBTTagCompound nbt = stack.getTagCompound(); System.out.println(nbt); if (nbt != null && nbt.hasKey("potency")) { int pot = nbt.getInteger("potency"); tooltip.add("Potency: " + pot); } } else { tooltip.add("Potency: N/A"); } } this is my tooltip code, I've tried all of the troubleshooting that I know of, such as just using a onRightClick method using the same general code in the ItemPickupEvent, which worked fine however my issue strides from the event. I want to know if I am doing something generally wrong, as in 1.10 this same method worked for me previously. Edited July 23, 20187 yr by quinn50
July 23, 20187 yr have you tried looking at the values in the debugger? your tooltip code may not be picking up the values About Me Spoiler My Discord - Cadiboo#8887 My Website - Cadiboo.github.io My Mods - Cadiboo.github.io/projects My Tutorials - Cadiboo.github.io/tutorials Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support. When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible. Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)
July 23, 20187 yr Author 49 minutes ago, Cadiboo said: have you tried looking at the values in the debugger? your tooltip code may not be picking up the values yes, I have but that is the issue for me it's not grabbing the NBT tag, but other options it does idk what is going on Edited July 23, 20187 yr by quinn50
July 23, 20187 yr Author 11 hours ago, diesieben07 said: That event cannot be used to modify the item being picked up. Why do you not create the item entity containing the necessary NBT data in the first place? Where is this dropped item coming from? Sorry for late reply, I implemented this solution thanks for the help.
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.