@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; }
@Override public int getComparatorInputOverride(World world, BlockPos pos) { TileEntityChoppingBoard tecb = (TileEntityChoppingBoard) world.getTileEntity(pos); return tecb.getFood() != null ? 1 : 0; }