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.
89 lines
2.3 KiB
Java
89 lines
2.3 KiB
Java
package net.minecraft.inventory;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntityDispenser;
|
|
|
|
public class ContainerDispenser extends Container
|
|
{
|
|
private TileEntityDispenser tileDispenser;
|
|
private static final String __OBFID = "CL_00001763";
|
|
|
|
public ContainerDispenser(IInventory p_i1825_1_, TileEntityDispenser p_i1825_2_)
|
|
{
|
|
this.tileDispenser = p_i1825_2_;
|
|
int i;
|
|
int j;
|
|
|
|
for (i = 0; i < 3; ++i)
|
|
{
|
|
for (j = 0; j < 3; ++j)
|
|
{
|
|
this.addSlotToContainer(new Slot(p_i1825_2_, j + i * 3, 62 + j * 18, 17 + i * 18));
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < 3; ++i)
|
|
{
|
|
for (j = 0; j < 9; ++j)
|
|
{
|
|
this.addSlotToContainer(new Slot(p_i1825_1_, j + i * 9 + 9, 8 + j * 18, 84 + i * 18));
|
|
}
|
|
}
|
|
|
|
for (i = 0; i < 9; ++i)
|
|
{
|
|
this.addSlotToContainer(new Slot(p_i1825_1_, i, 8 + i * 18, 142));
|
|
}
|
|
}
|
|
|
|
public boolean canInteractWith(EntityPlayer player)
|
|
{
|
|
return this.tileDispenser.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 < 9)
|
|
{
|
|
if (!this.mergeItemStack(itemstack1, 9, 45, true))
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
else if (!this.mergeItemStack(itemstack1, 0, 9, false))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
if (itemstack1.stackSize == 0)
|
|
{
|
|
slot.putStack((ItemStack)null);
|
|
}
|
|
else
|
|
{
|
|
slot.onSlotChanged();
|
|
}
|
|
|
|
if (itemstack1.stackSize == itemstack.stackSize)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
slot.onPickupFromSlot(player, itemstack1);
|
|
}
|
|
|
|
return itemstack;
|
|
}
|
|
} |