Posted March 28, 20187 yr Hello there mcforge forums, So i was helping someone else with coding a custom machine working with the energy capability and saw that he used IInventory for his TE, i know that that shouldn't be used as its vanilla code and forge suggests to use the IItemHandler capability, so i rewrote the machine, now i only have a little bit of a problem as i wanted to make a container for it. But i needed an IInventory to add slots to the container. So i figured that i'd make a new instance of the slot and make it compatible with IItemHandler. Spoiler package harry.mod.objects.blocks.machines.electricalSinterer.slots; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.Slot; import net.minecraft.item.ItemStack; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.items.IItemHandler; public class SlotIItemHandler extends Slot { IItemHandler INVENTORY; TileEntity TILE; @Deprecated public SlotIItemHandler(IInventory inventoryIn, int index, int xPosition, int yPosition) { super(inventoryIn, index, xPosition, yPosition); } public SlotIItemHandler(IItemHandler inventoryIn, int index, int xPosition, int yPosition, TileEntity tile) { super(null, index, xPosition, yPosition); this.INVENTORY = inventoryIn; this.TILE = tile; } @Override public int getSlotStackLimit() { return this.INVENTORY.getSlotLimit(slotNumber); } @Override public ItemStack getStack() { return this.INVENTORY.getStackInSlot(slotNumber); } @Override public void putStack(ItemStack stack) { this.INVENTORY.insertItem(slotNumber, stack, false); onSlotChanged(); } @Override public void onSlotChanged() { this.TILE.markDirty(); } @Override public ItemStack decrStackSize(int amount) { return this.INVENTORY.extractItem(slotNumber, amount, false); } @Override public boolean isHere(IInventory inv, int slotIn) { return false; } public boolean isHere(IItemHandler inv, int slotIn) { return this.INVENTORY.equals(inv) && this.slotNumber == slotIn; } } Now here's my question: Wouldn't it be smart to add this standardly to the Slot class? That would save time for both me an you, i dont need to re-write this file again, and you aren't in need to explain why to use IItemHandler instead of IInventory as Quote The Slot will only work with IInventory Edited March 28, 20187 yr by tebreca marked it solved
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.