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.

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

Featured Replies

Posted

I have an inventory TileEntity. How do I make sure no automation mods can interact with it (like BuildCraft pipes)?

  • Author

So if I don't expose it, players will still be able to interact with it? And should I implement

IItemHandler

,

IItemHandlerModifiable

and

INBTSerializable<NBTTagCompound>

?

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.

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

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 ?

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.