Jump to content

Bukkit Plugin - Mod chests


matejdro
 Share

Recommended Posts

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...