Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class CotainerFurnaceChest extends Container {
- TileEntityFurnaceChest tileEntity;
- InventoryPlayer playerInventory;
- public CotainerFurnaceChest(TileEntity te,
- EntityPlayer player) {
- tileEntity = (TileEntityFurnaceChest)te;
- playerInventory = player.inventory;
- int rowCount = 6;
- int colCount = 9;
- //the Slot constructor takes the IInventory and the slot number in that it binds to
- //and the x-y coordinates it resides on-screen
- /* Sets up the chest inventory */
- for (int row = 0; row < rowCount; row++) {
- for (int col = 0; col < colCount; col++) {
- addSlotToContainer(new Slot(tileEntity, col + row * colCount, 12 + col * 18, 8 + row * 18));
- // New Slot (Inventory, SlotNumber, xPosition, yPosition);
- }
- }
- /* Player Inventory */
- for (int playerRow = 0; playerRow < 3; playerRow++)
- for (int playerCol = 0; playerCol < 9; playerCol++)
- addSlotToContainer(new Slot(playerInventory, playerCol + playerRow * 9 + 9, 12 + playerCol * 18, 8 + playerRow * 18));
- /* Player hotbar */
- for (int hotSlotNum = 0; hotSlotNum < 9; hotSlotNum++){
- addSlotToContainer(new Slot(playerInventory, hotSlotNum, 12 + hotSlotNum * 18, 8 -24));
- }
- }
- @Override
- public ItemStack transferStackInSlot(EntityPlayer p, int i)
- {
- ItemStack itemstack = null;
- Slot slot = (Slot) inventorySlots.get(i);
- if (slot != null && slot.getHasStack())
- {
- ItemStack itemstack1 = slot.getStack();
- itemstack = itemstack1.copy();
- int invSize = tileEntity.getSizeInventory();
- if (i < invSize)
- {
- if (!mergeItemStack(itemstack1, invSize, inventorySlots.size(), true))
- {
- return null;
- }
- }
- else if (!mergeItemStack(itemstack1, 0, invSize, false))
- {
- return null;
- }
- if (itemstack1.stackSize == 0)
- {
- slot.putStack(null);
- }
- else
- {
- slot.onSlotChanged();
- }
- }
- return itemstack;
- }
- @Override
- public boolean canInteractWith(EntityPlayer entityplayer) {
- // TODO Auto-generated method stub
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment