Fix backtanks getting incompatible enchants via smithing tables (#7057)

This commit is contained in:
IThundxr 2025-01-10 12:10:45 -05:00 committed by GitHub
parent e065bb386b
commit b3662c45f4
Failed to generate hash of commit
3 changed files with 54 additions and 3 deletions

View file

@ -167,6 +167,11 @@ dependencies {
jarJar.ranged(it, '[1.0,2.0)')
}
compileOnly(annotationProcessor("io.github.llamalad7:mixinextras-common:0.4.1"))
implementation(jarJar("io.github.llamalad7:mixinextras-forge:0.4.1")) {
jarJar.ranged(it, "[0.4.1,)")
}
implementation fg.deobf("com.tterrag.registrate:Registrate:${registrate_version}")
compileOnly fg.deobf("dev.engine_room.flywheel:flywheel-forge-api-${flywheel_minecraft_version}:${flywheel_version}")
@ -192,12 +197,12 @@ dependencies {
// implementation fg.deobf("curse.maven:ic2-classic-242942:5555152")
// implementation fg.deobf("curse.maven:druidcraft-340991:3101903")
// implementation fg.deobf("com.railwayteam.railways:railways-1.19.2-1.6.4:all") { transitive = false }
implementation fg.deobf("dev.architectury:architectury-forge:9.1.12")
implementation fg.deobf("dev.ftb.mods:ftb-chunks-forge:2001.3.1")
implementation fg.deobf("dev.ftb.mods:ftb-teams-forge:2001.3.0")
implementation fg.deobf("dev.ftb.mods:ftb-library-forge:2001.2.4")
implementation fg.deobf("curse.maven:journeymap-32274:5457831")
// implementation fg.deobf("ignored:journeymap-1.20.1-5.10.1-forge")

View file

@ -0,0 +1,45 @@
package com.simibubi.create.foundation.mixin;
import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
import com.simibubi.create.AllItems;
import com.simibubi.create.content.equipment.armor.BacktankItem;
import net.minecraft.world.inventory.SmithingMenu;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.enchantment.Enchantment;
import net.minecraft.world.item.enchantment.EnchantmentHelper;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import java.util.HashMap;
import java.util.Map;
@Mixin(SmithingMenu.class)
public class SmithingMenuMixin {
// Only add enchantments to the backtank if it supports them
@ModifyExpressionValue(
method = "createResult",
at = @At(
value = "INVOKE",
target = "Lnet/minecraft/world/item/crafting/SmithingRecipe;assemble(Lnet/minecraft/world/Container;Lnet/minecraft/core/RegistryAccess;)Lnet/minecraft/world/item/ItemStack;"
)
)
private ItemStack create$preventUnbreakingOnBacktanks(ItemStack original) {
if (AllItems.COPPER_BACKTANK.is(original) || AllItems.NETHERITE_BACKTANK.is(original)) {
Map<Enchantment, Integer> enchantments = new HashMap<>();
EnchantmentHelper.getEnchantments(original).forEach((enchantment, level) -> {
if (enchantment.canEnchant(original))
enchantments.put(enchantment, level);
});
EnchantmentHelper.setEnchantments(enchantments, original);
}
return original;
}
}

View file

@ -15,6 +15,7 @@
"LavaSwimmingMixin",
"MainMixin",
"MapItemSavedDataMixin",
"SmithingMenuMixin",
"TestCommandMixin",
"WaterWheelFluidSpreadMixin",
"accessor.AbstractProjectileDispenseBehaviorAccessor",
@ -47,7 +48,7 @@
"client.MapRendererMapInstanceMixin",
"client.PlayerRendererMixin",
"client.WindowResizeMixin",
"compat.JourneyFullscreenMapMixin"
"compat.JourneyFullscreenMapMixin"
],
"injectors": {
"defaultRequire": 1