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 making an Item that allows the user to interract with any block remotely. It does this by calling onBlockActivated on the block whose data is stored in the NBT Tag Compound of the Item. This works fine for blocks like the lever and the door, who have no Container or Tile Entity, but for blocks like the Furnace or the Crafting Table, it only works when the user is within 5 or so blocks of the linked block. The GUI of the associated block shows for a split second, and then closes again, and I'm pretty sure this is because of isUsableByPlayer and/or canInterractWith returning false because the player is not close enough. Is there any way to bypass this, or am I going to have to scrap this Item?

inside the container class you need to change

@Override
        public boolean canInteractWith(EntityPlayer player) {
                return tileEntity.isUseableByPlayer(player);
        }

to

@Override
        public boolean canInteractWith(EntityPlayer player) {
                if(player.getCurrentEquippedItem()==new ItemStack(Mod.item))return true;
                return tileEntity.isUseableByPlayer(player);
        }

The Korecraft Mod

  • Author

Well yes, I'm quite aware of that, but I'm not just talking about my own Tile Entities and Containers here. I want this item to be able to access any Block, regardless of whether it's a Vanilla Block, my own Block, or a Block added by another mod.

  • Author

Okay, so I did a little digging around in the code, and the responsible line of code is line 330 of EntityPlayer.

if (!this.worldObj.isRemote && this.openContainer != null && !this.openContainer.canInteractWith(this))

This statement causes the current GuiScreen to close if canInteractWith in the open container returns false, so I'm guessing this means there's no workaround at all. I suppose I could do a Pull Request and add a hook in there to cancel the Gui being closed.

well you could also ask the creator of enderchests for help, they have the enderpouch

The Korecraft Mod

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.