diff --git a/src/main/java/com/nomiceu/nomilabs/mixin/extrautils2/IMachineRecipeMixin.java b/src/main/java/com/nomiceu/nomilabs/mixin/extrautils2/IMachineRecipeMixin.java new file mode 100644 index 00000000..2528605e --- /dev/null +++ b/src/main/java/com/nomiceu/nomilabs/mixin/extrautils2/IMachineRecipeMixin.java @@ -0,0 +1,43 @@ +package com.nomiceu.nomilabs.mixin.extrautils2; + +import java.util.Map; + +import net.minecraft.item.ItemStack; +import net.minecraftforge.fluids.FluidStack; + +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +import com.google.common.collect.ImmutableMap; +import com.rwtema.extrautils2.api.machine.IMachineRecipe; +import com.rwtema.extrautils2.api.machine.MachineSlotFluid; +import com.rwtema.extrautils2.api.machine.MachineSlotItem; +import com.rwtema.extrautils2.machine.TileMachine; + +/** + * Fixes XU2 Machine Recipes not consuming GT Tools Correctly, especially evident in the Enchanter. + *
+ * This causes a dupe bug of GT Tools. + */ +@Mixin(value = IMachineRecipe.class, remap = false) +public interface IMachineRecipeMixin { + + /** + * Overrides (most) XU2 Machine Recipes to return a empty map instead of a map of collections of items, populated + * via {@link net.minecraftforge.common.ForgeHooks#getContainerItem(ItemStack)}. + *
+ * This is because ItemGTTool overrides that method, in order to damage, instead of consume, GT Tools in Crafting + * Recipes. + *
+ * See {@link TileMachine#consumeInputs()} for why this works. Essentially, if there is no container item map for
+ * the specified slot, an Empty ItemStack is used instead.
+ */
+ @Inject(method = "getContainerItems", at = @At("HEAD"), cancellable = true)
+ default void getEmptyStacks(Map