You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
102 lines
2.7 KiB
Java
102 lines
2.7 KiB
Java
package net.minecraft.inventory;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
public class ContainerChest extends Container
|
|
{
|
|
private IInventory lowerChestInventory;
|
|
private int numRows;
|
|
private static final String __OBFID = "CL_00001742";
|
|
|
|
public ContainerChest(IInventory p_i1806_1_, IInventory p_i1806_2_)
|
|
{
|
|
this.lowerChestInventory = p_i1806_2_;
|
|
this.numRows = p_i1806_2_.getSizeInventory() / 9;
|
|
p_i1806_2_.openInventory();
|
|
int i = (this.numRows - 4) * 18;
|
|
int j;
|
|
int k;
|
|
|
|
for (j = 0; j < this.numRows; ++j)
|
|
{
|
|
for (k = 0; k < 9; ++k)
|
|
{
|
|
this.addSlotToContainer(new Slot(p_i1806_2_, k + j * 9, 8 + k * 18, 18 + j * 18));
|
|
}
|
|
}
|
|
|
|
for (j = 0; j < 3; ++j)
|
|
{
|
|
for (k = 0; k < 9; ++k)
|
|
{
|
|
this.addSlotToContainer(new Slot(p_i1806_1_, k + j * 9 + 9, 8 + k * 18, 103 + j * 18 + i));
|
|
}
|
|
}
|
|
|
|
for (j = 0; j < 9; ++j)
|
|
{
|
|
this.addSlotToContainer(new Slot(p_i1806_1_, j, 8 + j * 18, 161 + i));
|
|
}
|
|
}
|
|
|
|
public boolean canInteractWith(EntityPlayer player)
|
|
{
|
|
return this.lowerChestInventory.isUseableByPlayer(player);
|
|
}
|
|
|
|
/**
|
|
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
|
|
*/
|
|
public ItemStack transferStackInSlot(EntityPlayer player, int index)
|
|
{
|
|
ItemStack itemstack = null;
|
|
Slot slot = (Slot)this.inventorySlots.get(index);
|
|
|
|
if (slot != null && slot.getHasStack())
|
|
{
|
|
ItemStack itemstack1 = slot.getStack();
|
|
itemstack = itemstack1.copy();
|
|
|
|
if (index < this.numRows * 9)
|
|
{
|
|
if (!this.mergeItemStack(itemstack1, this.numRows * 9, this.inventorySlots.size(), true))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else if (!this.mergeItemStack(itemstack1, 0, this.numRows * 9, false))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (itemstack1.stackSize == 0)
|
|
{
|
|
slot.putStack((ItemStack)null);
|
|
}
|
|
else
|
|
{
|
|
slot.onSlotChanged();
|
|
}
|
|
}
|
|
|
|
return itemstack;
|
|
}
|
|
|
|
/**
|
|
* Called when the container is closed.
|
|
*/
|
|
public void onContainerClosed(EntityPlayer p_75134_1_)
|
|
{
|
|
super.onContainerClosed(p_75134_1_);
|
|
this.lowerChestInventory.closeInventory();
|
|
}
|
|
|
|
/**
|
|
* Return this chest container's lower chest inventory.
|
|
*/
|
|
public IInventory getLowerChestInventory()
|
|
{
|
|
return this.lowerChestInventory;
|
|
}
|
|
} |