Skip to content

Commit

Permalink
fix #156 by accessing ingredient getters instead of fields in serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Sep 19, 2024
1 parent d988807 commit e0fffe1
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.possible_triangle.sliceanddice.mixins;

import com.simibubi.create.content.processing.recipe.ProcessingRecipe;
import com.simibubi.create.content.processing.recipe.ProcessingRecipeSerializer;
import com.simibubi.create.foundation.fluid.FluidIngredient;
import net.minecraft.core.NonNullList;
import net.minecraft.world.item.crafting.Ingredient;
import org.objectweb.asm.Opcodes;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Redirect;

@Mixin(value = ProcessingRecipeSerializer.class, remap = false)
public class ProcessingRecipeSerializerMixin {

@Redirect(
method = "writeToBuffer",
at = @At(value = "FIELD", target = "Lcom/simibubi/create/content/processing/recipe/ProcessingRecipe;ingredients:Lnet/minecraft/core/NonNullList;", opcode = Opcodes.GETFIELD)
)
private NonNullList<Ingredient> useIngredientsGetter(ProcessingRecipe<?> instance) {
return instance.getIngredients();
}

@Redirect(
method = "writeToBuffer",
at = @At(value = "FIELD", target = "Lcom/simibubi/create/content/processing/recipe/ProcessingRecipe;fluidIngredients:Lnet/minecraft/core/NonNullList;", opcode = Opcodes.GETFIELD)
)
private NonNullList<FluidIngredient> useFluidIngredientsGetter(ProcessingRecipe<?> instance) {
return instance.getFluidIngredients();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class LazyMixingRecipe(params: ProcessingRecipeParams) : MixingRecipe(params) {
resolvedIngredients = super.ingredients.filterNot { replaceable.containsKey(it) }.toNonnullList()
resolvedFluidIngredients = (super.fluidIngredients + replaceable.values).toNonnullList()
resolved = true
emptyingRecipes = emptyList()
}

override fun getIngredients(): NonNullList<Ingredient> {
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/sliceanddice.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"minVersion": "0.8",
"refmap": "${mod_id}.refmap.json",
"mixins": [
"EntityMixin", "HarvesterMovementBehaviourMixin", "LevelMixin", "PressingBehaviourMixin", "RecipeEventJSMixin",
"RecipeManagerAccessor", "RecipeManagerMixin"
"EntityMixin", "HarvesterMovementBehaviourMixin", "LevelMixin", "PressingBehaviourMixin",
"ProcessingRecipeSerializerMixin", "RecipeEventJSMixin", "RecipeManagerAccessor", "RecipeManagerMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down

0 comments on commit e0fffe1

Please sign in to comment.