diff --git a/gradle.properties b/gradle.properties index 945533f..f27a6f9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -3,6 +3,6 @@ org.gradle.jvmargs = -Xmx1G org.gradle.parallel = true # Mod Properties -version = 2.1.1 +version = 2.1.2 maven_group = folk.sisby archives_base_name = tinkerers_smithing diff --git a/src/main/java/folk/sisby/tinkerers_smithing/mixin/AnvilScreenHandlerMixin.java b/src/main/java/folk/sisby/tinkerers_smithing/mixin/AnvilScreenHandlerMixin.java index 4199c72..948c510 100644 --- a/src/main/java/folk/sisby/tinkerers_smithing/mixin/AnvilScreenHandlerMixin.java +++ b/src/main/java/folk/sisby/tinkerers_smithing/mixin/AnvilScreenHandlerMixin.java @@ -1,9 +1,11 @@ package folk.sisby.tinkerers_smithing.mixin; import folk.sisby.tinkerers_smithing.TinkerersSmithing; +import folk.sisby.tinkerers_smithing.TinkerersSmithingItem; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.PlayerInventory; +import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.screen.*; @@ -33,6 +35,14 @@ private int noLevelsNoWork(int i) { return this.levelCost.get() == 0 ? i : AnvilScreenHandler.getNextCost(i); } + @Redirect(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/Item;canRepair(Lnet/minecraft/item/ItemStack;Lnet/minecraft/item/ItemStack;)Z")) + private boolean overrideRepairMaterials(Item instance, ItemStack stack, ItemStack ingredient) { + if (instance instanceof TinkerersSmithingItem tsi && !tsi.tinkerersSmithing$getUnitCosts().isEmpty()) { + return tsi.tinkerersSmithing$getUnitCost(ingredient) > 0; + } + return instance.canRepair(stack, ingredient); + } + @ModifyVariable(method = "updateResult", at = @At(value = "INVOKE", target = "Lnet/minecraft/item/ItemStack;setDamage(I)V", ordinal = 0), ordinal = 0) private int unitRepairNoLevels(int original) { return original - 1; diff --git a/src/main/java/folk/sisby/tinkerers_smithing/mixin/ItemMixin.java b/src/main/java/folk/sisby/tinkerers_smithing/mixin/ItemMixin.java index 7e1f235..9eb91bb 100644 --- a/src/main/java/folk/sisby/tinkerers_smithing/mixin/ItemMixin.java +++ b/src/main/java/folk/sisby/tinkerers_smithing/mixin/ItemMixin.java @@ -1,5 +1,6 @@ package folk.sisby.tinkerers_smithing.mixin; +import folk.sisby.tinkerers_smithing.TinkerersSmithing; import folk.sisby.tinkerers_smithing.TinkerersSmithingItem; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; @@ -51,8 +52,10 @@ public class ItemMixin implements TinkerersSmithingItem { @Inject(method = "canRepair", at = @At(value = "RETURN"), cancellable = true) private void overrideAnvilRepairIngredients(ItemStack stack, ItemStack ingredient, CallbackInfoReturnable cir) { - if (tinkerersSmithing$getUnitCost(ingredient) > 0) { - cir.setReturnValue(true); + TinkerersSmithing.LOGGER.info("OVERRIDE CHECK"); + if (!tinkerersSmithing$getUnitCosts().isEmpty()) { + TinkerersSmithing.LOGGER.info("OVERRIDE {}", tinkerersSmithing$getUnitCost(ingredient) > 0); + cir.setReturnValue(tinkerersSmithing$getUnitCost(ingredient) > 0); cir.cancel(); } } diff --git a/src/main/java/folk/sisby/tinkerers_smithing/mixin/ItemStackMixin.java b/src/main/java/folk/sisby/tinkerers_smithing/mixin/ItemStackMixin.java new file mode 100644 index 0000000..7bf5321 --- /dev/null +++ b/src/main/java/folk/sisby/tinkerers_smithing/mixin/ItemStackMixin.java @@ -0,0 +1,8 @@ +package folk.sisby.tinkerers_smithing.mixin; + +import net.minecraft.item.ItemStack; +import org.spongepowered.asm.mixin.Mixin; + +@Mixin(ItemStack.class) +public class ItemStackMixin { +} diff --git a/src/main/resources/tinkerers_smithing.mixins.json b/src/main/resources/tinkerers_smithing.mixins.json index 1cdf296..2531a1a 100644 --- a/src/main/resources/tinkerers_smithing.mixins.json +++ b/src/main/resources/tinkerers_smithing.mixins.json @@ -1,17 +1,18 @@ { - "required": true, - "minVersion": "0.8", - "package": "folk.sisby.tinkerers_smithing.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "AnvilScreenHandlerMixin", - "ItemMixin", - "SmithingScreenHandlerMixin" - ], - "client": [ - "client.AnvilScreenMixin" - ], - "injectors": { - "defaultRequire": 1 + "required": true, + "minVersion": "0.8", + "package": "folk.sisby.tinkerers_smithing.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "AnvilScreenHandlerMixin", + "ItemMixin", + "ItemStackMixin", + "SmithingScreenHandlerMixin" + ], + "client": [ + "client.AnvilScreenMixin" + ], + "injectors": { + "defaultRequire": 1 } }