TelepathicGrunt / Bumblezone

A bee dimension just for fun!
https://www.curseforge.com/minecraft/mc-mods/the-bumblezone-forge
GNU Lesser General Public License v3.0
181 stars 37 forks source link

Game crashes if a Honey Block is inserted in the Electric Furnace from Tech Reborn or the Powered Furnace from Energized Power #319

Closed JDDev0 closed 9 months ago

JDDev0 commented 9 months ago

RecipeType.SMELTING requires recipes to extend from net.minecraft.world.item.crafting.SmeltingRecipe. The class com.telepathicgrunt.the_bumblezone.items.recipes.ItemStackSmeltingRecipe should extend SmeltingRecipe - You need to change the extends from AbstractCookingRecipe to SmeltingRecipe and remove RecipeType.SMELTING from the super constructor call, afterwards the crash should be fixed.

Currently the recipes using the the_bumblezone:itemstack_smelting_recipe recipe type are not shown in REI on Forge and cause crashes in Energized Power and Tech Reborn - See crash report after a Honey Block was inserted in the Electric Furnace from Tech Reborn: crash-2023-12-13_18.10.26-server.txt.

TelepathicGrunt commented 9 months ago

Kinda surprising as AbstractCookingRecipe implements everything they need to know for the class and the recipe type being smelting for what it is for. Checking each derived class, I don't see anything special that would require casting at all. Just casting to AbstractCookingRecipe would be enough.

JDDev0 commented 9 months ago

In Tech Reborn and Energized Power SmeltingRecipe is explicitly used and not AbstractCookingRecipe:

JDDev0 commented 9 months ago

This line will try to cast the recipe to a SmeltingRecipe: Optional<SmeltingRecipe> testRecipe = world.getRecipeManager().getFirstMatch(RecipeType.SMELTING, inventory, world).map(RecipeEntry::value);

TelepathicGrunt commented 9 months ago

But my question is, why the cast? Why cant you just check for the recipe type like you're doing and keep it as AbstractCookingRecipe? What necessitates the need to cast to SmeltingRecipe when it doesn't seem to prove any extra functionality?

I will fix my recipe to extend it but I'm feeling like this is an assumption that mods made that turned out to be weird and not always safe to do.

TelepathicGrunt commented 9 months ago

OH. I see. Then I am definitely incorrect here as recipe type itself expects SmeltingRecipe public static final RecipeType<SmeltingRecipe> SMELTING = RecipeType.register("smelting");

TelepathicGrunt commented 9 months ago

Fixed now in v7.2.9