2013-08-23 16:59:50 +02:00
|
|
|
package com.pahimar.ee3.inventory;
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
import com.pahimar.ee3.tileentity.TileGlassBell;
|
2013-08-23 16:59:50 +02:00
|
|
|
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;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Equivalent-Exchange-3
|
2013-12-16 02:26:42 +01:00
|
|
|
* <p/>
|
2013-08-23 16:59:50 +02:00
|
|
|
* ContainerGlassBell
|
2013-12-16 02:26:42 +01:00
|
|
|
*
|
2013-08-23 16:59:50 +02:00
|
|
|
* @author pahimar
|
|
|
|
*/
|
2013-12-16 02:26:42 +01:00
|
|
|
public class ContainerGlassBell extends Container
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
|
|
|
|
private final int PLAYER_INVENTORY_ROWS = 3;
|
|
|
|
private final int PLAYER_INVENTORY_COLUMNS = 9;
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
public ContainerGlassBell(InventoryPlayer inventoryPlayer, TileGlassBell tileGlassBell)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
|
|
|
|
this.addSlotToContainer(new Slot(tileGlassBell, TileGlassBell.DISPLAY_SLOT_INVENTORY_INDEX, 80, 22));
|
|
|
|
|
|
|
|
// Add the player's inventory slots to the container
|
2013-12-16 02:26:42 +01:00
|
|
|
for (int inventoryRowIndex = 0; inventoryRowIndex < PLAYER_INVENTORY_ROWS; ++inventoryRowIndex)
|
|
|
|
{
|
|
|
|
for (int inventoryColumnIndex = 0; inventoryColumnIndex < PLAYER_INVENTORY_COLUMNS; ++inventoryColumnIndex)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
this.addSlotToContainer(new Slot(inventoryPlayer, inventoryColumnIndex + inventoryRowIndex * 9 + 9, 8 + inventoryColumnIndex * 18, 58 + inventoryRowIndex * 18));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Add the player's action bar slots to the container
|
2013-12-16 02:26:42 +01:00
|
|
|
for (int actionBarSlotIndex = 0; actionBarSlotIndex < PLAYER_INVENTORY_COLUMNS; ++actionBarSlotIndex)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
this.addSlotToContainer(new Slot(inventoryPlayer, actionBarSlotIndex, 8 + actionBarSlotIndex * 18, 116));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public boolean canInteractWith(EntityPlayer var1)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2013-12-16 02:26:42 +01:00
|
|
|
public ItemStack transferStackInSlot(EntityPlayer entityPlayer, int slotIndex)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
|
|
|
|
ItemStack itemStack = null;
|
|
|
|
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
if (slot != null && slot.getHasStack())
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
ItemStack slotItemStack = slot.getStack();
|
|
|
|
itemStack = slotItemStack.copy();
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
if (slotIndex < TileGlassBell.INVENTORY_SIZE)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
if (!this.mergeItemStack(slotItemStack, 1, inventorySlots.size(), true))
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2013-12-16 02:26:42 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!this.mergeItemStack(slotItemStack, 0, TileGlassBell.INVENTORY_SIZE, false))
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-16 02:26:42 +01:00
|
|
|
if (slotItemStack.stackSize == 0)
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
slot.putStack((ItemStack) null);
|
|
|
|
}
|
2013-12-16 02:26:42 +01:00
|
|
|
else
|
|
|
|
{
|
2013-08-23 16:59:50 +02:00
|
|
|
slot.onSlotChanged();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return itemStack;
|
|
|
|
}
|
|
|
|
}
|