Posted December 27, 201212 yr 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?
December 27, 201212 yr 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
December 27, 201212 yr 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.
December 27, 201212 yr 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.
December 27, 201212 yr 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.