Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package minefantasy.mf2.block.crafting;
- import minefantasy.mf2.block.tileentity.TileEntityCarpenter;
- 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 ContainerCarpenterBench extends Container {
- protected TileEntityCarpenter tec;
- protected int PLAYER_INVENTORY_ROWS = 3;
- protected int PLAYER_INVENTORY_COLUMNS = 9;
- public ContainerCarpenterBench(TileEntityCarpenter te,
- InventoryPlayer player_inventory) {
- this.tec = te;
- addSlots(player_inventory);
- }
- @Override
- public boolean canInteractWith(EntityPlayer player) {
- return tec.isUseableByPlayer(player);
- }
- protected void addSlots(InventoryPlayer player_inventory) {
- this.addSlotToContainer(new Slot(tec, 0, 10, 23));
- int x = 0;
- // Add the player's inventory slots to the container
- //Slots 9-35
- for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex) {
- for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex) {
- x++;
- System.out.println(x + ": " + (int)(inventoryColumnIndex + inventoryRowIndex * 9 + 9));
- this.addSlotToContainer(new Slot(player_inventory,
- inventoryColumnIndex + inventoryRowIndex * 9 + 9,
- 7 + inventoryColumnIndex * 18,
- 83 + inventoryRowIndex * 18));
- }
- }
- //slots 0-8
- // Add the player's action bar slots to the container
- for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex) {
- this.addSlotToContainer(new Slot(player_inventory,
- actionBarSlotIndex, 7 + actionBarSlotIndex * 18, 177));
- }
- }
- @Override
- public ItemStack transferStackInSlot(EntityPlayer player, int sn)
- {
- ItemStack itemstack = null;
- Slot slot = (Slot)this.inventorySlots.get(sn);
- if (slot != null && slot.getHasStack())
- {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- if (sn < 9)
- {
- if (!this.mergeItemStack(itemstack1, 9, 36, true))
- {
- return null;
- }
- }
- else if (!this.mergeItemStack(itemstack1, 0, 9, false))
- {
- return null;
- }
- if (itemstack1.stackSize == 0)
- {
- slot.putStack((ItemStack)null);
- }
- else
- {
- slot.onSlotChanged();
- }
- }
- return itemstack;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement