BloodMagic/BM_src/WayofTime/alchemicalWizardry/common/tileEntity/container/ContainerAltar.java
Fenn e3644f2d2b Massive rework of configs, items and blocks.
I redone where the items/blocsks are stored and how the configs are
handled to clean up it and give space. You can change the config line to
AWWayofTime if you want to keep the compatibility with old configs. Now
you reference the blocks from the ModBlocks and Items from the ModItems.
2014-01-17 21:05:38 +00:00

95 lines
2.7 KiB
Java

package WayofTime.alchemicalWizardry.common.tileEntity.container;
import WayofTime.alchemicalWizardry.common.tileEntity.TEAltar;
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 ContainerAltar extends Container {
protected TEAltar tileEntity;
public ContainerAltar(InventoryPlayer inventoryPlayer, TEAltar te)
{
tileEntity = te;
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
addSlotToContainer(new Slot(tileEntity, j + i * 3, 62 + j * 18, 17 + i * 18));
}
}
bindPlayerInventory(inventoryPlayer);
}
@Override
public boolean canInteractWith(EntityPlayer entityplayer)
{
return tileEntity.isUseableByPlayer(entityplayer);
}
protected void bindPlayerInventory(InventoryPlayer inventoryPlayer)
{
for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 9; j++)
{
addSlotToContainer(new Slot(inventoryPlayer, j + i * 9 + 9,
8 + j * 18, 84 + i * 18));
}
}
for (int i = 0; i < 9; i++)
{
addSlotToContainer(new Slot(inventoryPlayer, i, 8 + i * 18, 142));
}
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int slot)
{
ItemStack stack = null;
Slot slotObject = (Slot) inventorySlots.get(slot);
//null checks and checks if the item can be stacked (maxStackSize > 1)
if (slotObject != null && slotObject.getHasStack())
{
ItemStack stackInSlot = slotObject.getStack();
stack = stackInSlot.copy();
//merges the item into player inventory since its in the tileEntity
if (slot < 9)
{
if (!this.mergeItemStack(stackInSlot, 0, 35, true))
{
return null;
}
}
//places it into the tileEntity is possible since its in the player inventory
else if (!this.mergeItemStack(stackInSlot, 0, 9, false))
{
return null;
}
if (stackInSlot.stackSize == 0)
{
slotObject.putStack(null);
} else
{
slotObject.onSlotChanged();
}
if (stackInSlot.stackSize == stack.stackSize)
{
return null;
}
slotObject.onPickupFromSlot(player, stackInSlot);
}
return stack;
}
}