private void doCookFood() { final double distanceToFurnace = RadixMath.getDistanceToXYZ(owner, furnacePos); if (distanceToFurnace <= 2.5D) { if (isCooking) { if (cookingTicks <= cookingInterval) { if (BlockHelper.getBlock( owner.worldObj, furnacePos.iPosX, furnacePos.iPosY, furnacePos.iPosZ) != Blocks.lit_furnace) { BlockHelper.updateFurnaceState( true, owner.worldObj, furnacePos.iPosX, furnacePos.iPosY, furnacePos.iPosZ); } cookingTicks++; } else { CookableFood foodObj = RegistryMCA.getCookableFoodList().get(indexOfCookingFood); int rawFoodSlot = owner.getInventory().getFirstSlotContainingItem(foodObj.getFoodRaw()); if (rawFoodSlot > -1) { owner.getInventory().decrStackSize(rawFoodSlot, 1); addItemStackToInventory(new ItemStack(foodObj.getFoodCooked(), 1, 0)); owner.swingItem(); } else { EntityPlayer player = getAssigningPlayer(); if (player != null) { owner.sayRaw("I don't have any food to cook.", player); // TODO Translate. } reset(); } isCooking = false; hasCookableFood = false; cookingTicks = 0; fuelUsesRemaining--; BlockHelper.updateFurnaceState( false, owner.worldObj, furnacePos.iPosX, furnacePos.iPosY, furnacePos.iPosZ); if (fuelUsesRemaining <= 0) { hasFuel = false; } } } else { owner.swingItem(); isCooking = true; } } }
@Override public void setIsActive(boolean value) { isAIActive.setValue(value); if (!value) { if (hasFurnace) { BlockHelper.updateFurnaceState( false, owner.worldObj, furnacePos.iPosX, furnacePos.iPosY, furnacePos.iPosZ); } } }