Skip to content

Commit

Permalink
made netherite *not* repairable with netherite
Browse files Browse the repository at this point in the history
  • Loading branch information
sisby-folk committed May 30, 2023
1 parent 5ec8b3a commit 8b6f02a
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
@@ -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.*;
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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<Boolean> 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();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}
29 changes: 15 additions & 14 deletions src/main/resources/tinkerers_smithing.mixins.json
Original file line number Diff line number Diff line change
@@ -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
}
}

0 comments on commit 8b6f02a

Please sign in to comment.