public void freezeItem() { if (inventory[1] != null) { RecipeData data = Recipes.getFreezerRecipeFromInput(inventory[1]); if (data == null) { return; } if (inventory[2] == null) { inventory[2] = data.getOutput().copy(); } else if (inventory[2].getItem() == data.getOutput().getItem() && inventory[2].getItemDamage() == data.getOutput().getItemDamage()) { inventory[2].stackSize += data.getOutput().copy().stackSize; } if (inventory[1].getItem().hasContainerItem()) { inventory[1] = new ItemStack(inventory[1].getItem().getContainerItem()); } else { inventory[1].stackSize--; } if (inventory[1].stackSize <= 0) { inventory[1] = null; } } }
public boolean canFreeze() { if (inventory[0] == null && timeRemaining == 0) { return false; } if (inventory[0] != null && timeRemaining == 0) { if (!isFuel(inventory[0])) { return false; } } if (inventory[1] != null) { RecipeData data = Recipes.getFreezerRecipeFromInput(inventory[1]); if (data == null) { return false; } if (inventory[2] == null) { return true; } if (inventory[2].getItem() != data.getOutput().getItem()) { return false; } if (inventory[2].stackSize < this.getInventoryStackLimit() && inventory[2].stackSize < inventory[2].getMaxStackSize()) { return true; } } return false; }
@Override public boolean onBlockActivated( World world, BlockPos pos, IBlockState state, EntityPlayer player, EnumFacing side, float hitX, float hitY, float hitZ) { ItemStack currentItem = player.getCurrentEquippedItem(); TileEntity tileEntity = world.getTileEntity(pos); if (tileEntity instanceof TileEntityChoppingBoard) { TileEntityChoppingBoard tileEntityChoppingBoard = (TileEntityChoppingBoard) tileEntity; if (currentItem != null) { if (Recipes.getChoppingBoardRecipeFromInput(currentItem) != null && tileEntityChoppingBoard.getFood() == null) { if (tileEntityChoppingBoard.getFood() == null) { tileEntityChoppingBoard.setFood(new ItemStack(currentItem.getItem(), 1)); world.markBlockForUpdate(pos); world.updateComparatorOutputLevel(pos, this); currentItem.stackSize--; return true; } else { if (!world.isRemote) { EntityItem entityFood = new EntityItem( world, pos.getX() + 0.5, pos.getY() + 0.4, pos.getZ() + 0.5, tileEntityChoppingBoard.getFood()); world.spawnEntityInWorld(entityFood); tileEntityChoppingBoard.setFood(null); world.markBlockForUpdate(pos); } world.updateComparatorOutputLevel(pos, this); return true; } } else if (currentItem.getItem() == FurnitureItems.itemKnife && tileEntityChoppingBoard.getFood() != null) { if (tileEntityChoppingBoard.chopFood()) { currentItem.damageItem(1, player); } return true; } } if (tileEntityChoppingBoard.getFood() != null) { if (!world.isRemote) { EntityItem entityFood = new EntityItem( world, pos.getX() + 0.5, pos.getY() + 0.4, pos.getZ() + 0.5, tileEntityChoppingBoard.getFood()); world.spawnEntityInWorld(entityFood); } tileEntityChoppingBoard.setFood(null); world.markBlockForUpdate(pos); world.updateComparatorOutputLevel(pos, this); } } return true; }