Posted August 25, 20205 yr I'm trying to model an item after the book and quill. The goal is to open a GUI in which the player can write stuff, and when a button is pressed use NBT to store it. To make things easier on myself I'm limiting it to one page and no signing feature. In the packet handler, I'm creating a method (called processEditScroll, obviously a copy of processEditBook from ServerPlayNetHandler) that checks if the item in hand is the scroll (again, like processEditBook). What I believe to be the relevant code is here: public void processEditScroll(ScrollPacket packetIn) { ItemStack itemstack = packetIn.getStack(); if (!itemstack.isEmpty()) { if (MessageScrollItem.isNBTValid(itemstack.getTag())) { ItemStack itemstack1 = this.player.getHeldItem(packetIn.getHand()); if (itemstack.getItem() == ModItems.MESSAGE_SCROLL) I'm aware I can't compare ItemStacks to Items (since I did try and look into it before posting, and that's the only related problem that pops up) so I use itemstack.getItem. The issue I'm having is that Intellij says Quote Operator '==' cannot be applied to 'net.minecraft.item.Item', 'net.minecraftforge.fml.RegistryObject<net.minecraft.item.Item> In case it's at all relevant, I'm using the DefferedRegistry system.
August 25, 20205 yr Have you tried ModItems.MESSAGE_SCROLL.get()? The method comment for RegistryObject::get is: Quote /** * Directly retrieves the wrapped Registry Object. This value will automatically be updated when the backing registry is updated. * Will throw NPE if the value is null, use isPresent to check first. Or use any of the other guarded functions. */ Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
August 25, 20205 yr Author Just now, Matryoshika said: Have you tried ModItems.MESSAGE_SCROLL.get()? I'm such a moron. Thank you so much, it was such an obvious fix.
August 25, 20205 yr Hey, we all have our moments when we need to rubber duck debug. Sometimes the answer could be staring right at us and we don't notice until someone else points it out. It's a human Feature™ Also previously known as eAndPi. "Pi, is there a station coming up where we can board your train of thought?" -Kronnn Published Mods: Underworld Handy links: Vic_'s Forge events Own WIP Tutorials.
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.