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

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. 

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.

  • 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.

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.

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.