Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.10.2] Is there a way to block automation interaction with my TileEntity?


Starless
 Share

Recommended Posts

If you don't expose an IItemHandler capability on any side, there will be no automated interaction with your TE's inventory (or inventories), but players can of course still interact via any GUI you choose to attach to it via a Container.

 

What do you mean by "implement IItemHandler..." ? Your TE shouldn't be doing that at all; your TE should contain an object implementing IItemHandler (commonly just an ItemStackHandler) for each inventory it has, and, if it wants to make those available to other mods (and vanilla!), return those from getCapability(), like I do here: https://github.com/desht/ModularRouters/blob/master/src/main/java/me/desht/modularrouters/block/tile/TileEntityItemRouter.java#L156

 

(Note that vanilla items like a hopper have been retrofitted with capability awareness and will interact with any inventory you expose via capabilities).

 

You don't need to explicitly implement INBTSerializable; the TileEntity class implements that anyway, and the implementing methods just call readFromNBT() and writeToNBT(), which are the methods you should normally be overriding.

Link to comment
Share on other sites

"is a chest"?  You mean, you're directly extending TileEntityChest, or you're creating a tile entity with chest-like functionality?

 

Have you looked at the code for TileEntityChest (note, it gets tricky because of double chests).  You'll see that even vanilla chests implement getCapability() & hasCapability() for ITEM_HANDLER_CAPABILITY.

 

But I think the short answer to your question is no: you don't need to implement any of those interfaces.

Link to comment
Share on other sites

public class Tilelol extends TileEntity {

    ItemStackHandler itemStackHandler = new ItemStackHandler(5);

 

    @Override

    public void readFromNBT(NBTTagCompound compound) {

        itemStackHandler.deserializeNBT(compound.getCompoundTag("llo"));

        super.readFromNBT(compound);

    }

 

    @Override

    public NBTTagCompound writeToNBT(NBTTagCompound compound) {

        super.writeToNBT(compound);

        compound.setTag("llo", itemStackHandler.serializeNBT());

        return compound;

       

    }

}

is this what you want ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.