Jump to content

Recommended Posts

Posted

Haven't tried a plugin myself, but inventories are stored as itemstack arrays as part of the tileentity used by the block.

How exactly they name that array depends on the mod. IC2 has all it's machines based off TileentityMachine.class which defines it as "inventory", while the vanilla chest uses "chestContents", furnace is "furnaceItemStacks", and so on...

There's probably a way to find every itemstack array attached to a tileentity derived class using reflection, but I's still new to java.

Posted

I have figured it out.

First, you have to add .zip of the mod to the build path. Then you can easily access stuff. For example alchemy chest:

            //block = Alchemist chest block

            TileEntity entity = ((CraftWorld) block.getWorld()).getTileEntityAt(block.getX(), block.getY(), block.getZ());

            if (!(entity instanceof TileAlchChest)) return;

            TileAlchChest chest = (TileAlchChest) entity;

           

            ItemStack[] items = chest.getContents();

Thanks for your help!

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.   Paste as plain text instead

  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.

×
×
  • Create New...