Skip to content

Commit

Permalink
Fix Dupe Bug with GT Tools and XU2 Enchanter
Browse files Browse the repository at this point in the history
Fixes Nomi-CEu/Nomi-CEu#770

Superseeds #22
  • Loading branch information
IntegerLimit committed Jul 2, 2024
1 parent 02bb13f commit 9a60008
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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.
* <p>
* 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)}.
* <p>
* This is because ItemGTTool overrides that method, in order to damage, instead of consume, GT Tools in Crafting
* Recipes.
* <p>
* 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<MachineSlotItem, ItemStack> inputItems,
Map<MachineSlotFluid, FluidStack> inputFluids,
CallbackInfoReturnable<Map<MachineSlotItem, ItemStack>> cir) {
cir.setReturnValue(ImmutableMap.of());
}
}
1 change: 1 addition & 0 deletions src/main/resources/mixins.nomilabs.extrautils2.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"minVersion": "0.8",
"compatibilityLevel": "JAVA_8",
"mixins": [
"IMachineRecipeMixin",
"ItemIngredientsMixin",
"ResonatorMixin"
],
Expand Down

0 comments on commit 9a60008

Please sign in to comment.