matejdro Posted July 29, 2012 Posted July 29, 2012 Is there a way I can see contents of mod chests (like alchemist chest or Iron chest) using bukkit plugin?
Neowulf Posted July 29, 2012 Posted July 29, 2012 Working on a plugin to remote open inventories? What do you have so far? Not working on a plugin yourself? Wrong section.
matejdro Posted July 29, 2012 Author Posted July 29, 2012 I'm working on a plugin that will delete chest and put items somewhere else. But to do that, I need to first get a list of items that are inside chest.
Neowulf Posted July 29, 2012 Posted July 29, 2012 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.
matejdro Posted July 30, 2012 Author Posted July 30, 2012 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!
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now