mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-13 08:54:12 +00:00
80 lines
2.3 KiB
Java
80 lines
2.3 KiB
Java
package tconstruct.inventory;
|
|||
|
|
|
||
|
|
import tconstruct.blocks.logic.DrawbridgeLogic;
|
||
|
|
import net.minecraft.entity.player.EntityPlayer;
|
||
|
|
import net.minecraft.entity.player.InventoryPlayer;
|
||
|
|
import net.minecraft.inventory.Container;
|
||
|
|
import net.minecraft.inventory.Slot;
|
||
|
|
import net.minecraft.item.ItemStack;
|
||
|
|
|
||
|
|
public class DrawbridgeContainer extends Container
|
||
|
|
{
|
||
|
|
public DrawbridgeLogic logic;
|
||
|
|
public int progress = 0;
|
||
|
|
public int fuel = 0;
|
||
|
|
public int fuelGague = 0;
|
||
|
|
|
||
|
|
public DrawbridgeContainer(InventoryPlayer inventoryplayer, DrawbridgeLogic logic)
|
||
|
|
{
|
||
|
|
this.logic = logic;
|
||
|
|
|
||
|
|
this.addSlotToContainer(new DrawbridgeSlot(logic, 0, 80, 36, logic));
|
||
|
|
this.addSlotToContainer(new Slot(logic, 1, 35, 36));
|
||
|
|
|
||
|
|
/* Player inventory */
|
||
|
|
for (int column = 0; column < 3; column++)
|
||
|
|
{
|
||
|
|
for (int row = 0; row < 9; row++)
|
||
|
|
{
|
||
|
|
this.addSlotToContainer(new Slot(inventoryplayer, row + column * 9 + 9, 8 + row * 18, 84 + column * 18));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
for (int column = 0; column < 9; column++)
|
||
|
|
{
|
||
|
|
this.addSlotToContainer(new Slot(inventoryplayer, column, 8 + column * 18, 142));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public boolean canInteractWith (EntityPlayer entityplayer)
|
||
|
|
{
|
||
|
|
return logic.isUseableByPlayer(entityplayer);
|
||
|
|
}
|
||
|
|
|
||
|
|
@Override
|
||
|
|
public ItemStack transferStackInSlot (EntityPlayer player, int slotID)
|
||
|
|
{
|
||
|
|
ItemStack stack = null;
|
||
|
|
Slot slot = (Slot) this.inventorySlots.get(slotID);
|
||
|
|
|
||
|
|
if (slot != null && slot.getHasStack())
|
||
|
|
{
|
||
|
|
ItemStack slotStack = slot.getStack();
|
||
|
|
stack = slotStack.copy();
|
||
|
|
|
||
|
|
if (slotID < logic.getSizeInventory())
|
||
|
|
{
|
||
|
|
if (!this.mergeItemStack(slotStack, logic.getSizeInventory(), this.inventorySlots.size(), true))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else if (!this.mergeItemStack(slotStack, 0, logic.getSizeInventory(), false))
|
||
|
|
{
|
||
|
|
return null;
|
||
|
|
}
|
||
|
|
|
||
|
|
if (slotStack.stackSize == 0)
|
||
|
|
{
|
||
|
|
slot.putStack((ItemStack) null);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
slot.onSlotChanged();
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
return stack;
|
||
|
|
}
|
||
|
|
}
|