@Override public boolean isItemValidForSlot(int slot, ItemStack stack) { if (!formed || stack == null) return false; TileEntityBottlingMachine master = master(); if (master != null) return master.isItemValidForSlot(slot, stack); return true; // this.getFilledItem(stack, false)!=null; }
@Override public ItemStack getStackInSlot(int slot) { if (!formed) return null; TileEntityBottlingMachine master = master(); if (master != null) return master.getStackInSlot(slot); if (slot < inventory.length) return inventory[slot]; return null; }
@Override public ItemStack getStackInSlotOnClosing(int slot) { if (!formed) return null; TileEntityBottlingMachine master = master(); if (master != null) return master.getStackInSlotOnClosing(slot); ItemStack stack = getStackInSlot(slot); if (stack != null) setInventorySlotContents(slot, null); return stack; }
@Override public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) { TileEntityBottlingMachine master = master(); if (formed && pos == 10 && from == ForgeDirection.UP && master != null) { int rec = master.energyStorage.receiveEnergy(maxReceive, simulate); master.markDirty(); if (rec > 0) worldObj.markBlockForUpdate(master.xCoord, master.yCoord, master.zCoord); return rec; } return 0; }
@Override public int fill(ForgeDirection from, FluidStack resource, boolean doFill) { if (resource == null) return 0; TileEntityBottlingMachine master = master(); if (master != null && canFill(from, resource.getFluid())) return master.fill(from, resource, doFill); int fill = tank.fill(resource, doFill); if (fill > 0) { markDirty(); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); } return fill < 0 ? 0 : fill; }
@Override public void setInventorySlotContents(int slot, ItemStack stack) { if (!formed || worldObj.isRemote) return; TileEntityBottlingMachine master = master(); if (master != null) { master.setInventorySlotContents(slot, stack); return; } inventory[slot] = stack; if (stack != null && stack.stackSize > getInventoryStackLimit()) stack.stackSize = getInventoryStackLimit(); this.markDirty(); worldObj.markBlockForUpdate(xCoord, yCoord, zCoord); }
@Override public ItemStack decrStackSize(int slot, int amount) { if (!formed) return null; TileEntityBottlingMachine master = master(); if (master != null) return master.decrStackSize(slot, amount); ItemStack stack = getStackInSlot(slot); if (stack != null) if (stack.stackSize <= amount) setInventorySlotContents(slot, null); else { stack = stack.splitStack(amount); if (stack.stackSize == 0) setInventorySlotContents(slot, null); } this.markDirty(); return stack; }