Skip to content

Commit

Permalink
Fix External Heater breaking when used with an extra-fast cooking rec…
Browse files Browse the repository at this point in the history
…ipe. (#5824)

* Respect the configured cooking time when using the external heater

* Switch external heater to use furnace's recipe cache

* Fetch cooking time from the ContainerData, instead of from the recipe
  • Loading branch information
TeamSpen210 authored Dec 31, 2023
1 parent e08fecb commit 7f395d1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.level.block.AbstractFurnaceBlock;
import net.minecraft.world.level.block.entity.FurnaceBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
Expand All @@ -31,8 +30,7 @@ boolean canCook()
ItemStack input = furnace.getItem(DATA_LIT_TIME);
if(input.isEmpty())
return false;
RecipeType<? extends AbstractCookingRecipe> type = ((FurnaceTEAccess)furnace).getRecipeType();
Optional<? extends AbstractCookingRecipe> output = furnace.getLevel().getRecipeManager().getRecipeFor(type, furnace, furnace.getLevel());
Optional<? extends AbstractCookingRecipe> output = ((FurnaceTEAccess)furnace).getQuickCheck().getRecipeFor(furnace, furnace.getLevel());
if(output.isEmpty())
return false;
ItemStack existingOutput = furnace.getItem(2);
Expand Down Expand Up @@ -78,7 +76,7 @@ public int doHeatTick(int energyAvailable, boolean redstone)
}
}
// Speed up once fully charged
if(canCook&&furnaceData.get(DATA_LIT_TIME) >= FULLY_HEATED_LIT_TIME&&furnaceData.get(DATA_COOKING_PROGRESS) < BURN_TIME_STANDARD-1)
if(canCook&&furnaceData.get(DATA_LIT_TIME) >= FULLY_HEATED_LIT_TIME&&furnaceData.get(DATA_COOKING_PROGRESS) < furnaceData.get(DATA_COOKING_TOTAL_TIME)-1)
{
int energyToUse = ExternalHeaterHandler.defaultFurnaceSpeedupCost;
if(energyAvailable-energyConsumed > energyToUse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@

package blusunrize.immersiveengineering.mixin.accessors;

import net.minecraft.world.Container;
import net.minecraft.world.inventory.ContainerData;
import net.minecraft.world.item.crafting.AbstractCookingRecipe;
import net.minecraft.world.item.crafting.RecipeType;
import net.minecraft.world.item.crafting.RecipeManager;
import net.minecraft.world.level.block.entity.AbstractFurnaceBlockEntity;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
Expand All @@ -20,10 +21,9 @@
@Mixin(AbstractFurnaceBlockEntity.class)
public interface FurnaceTEAccess
{
// This is a Forge-added field in 1.19, so it does not need to be remapped
@Accessor(remap = false)
@Accessor
@Final
RecipeType<? extends AbstractCookingRecipe> getRecipeType();
RecipeManager.CachedCheck<Container, ? extends AbstractCookingRecipe> getQuickCheck();

@Accessor
@Final
Expand Down

0 comments on commit 7f395d1

Please sign in to comment.