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? Quote
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. Quote
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. Quote
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. Quote
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! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.