mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-30 06:45:03 +01:00
Fix backtanks getting incompatible enchants via smithing tables (#7057)
This commit is contained in:
parent
e065bb386b
commit
b3662c45f4
3 changed files with 54 additions and 3 deletions
|
@ -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}")
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -15,6 +15,7 @@
|
|||
"LavaSwimmingMixin",
|
||||
"MainMixin",
|
||||
"MapItemSavedDataMixin",
|
||||
"SmithingMenuMixin",
|
||||
"TestCommandMixin",
|
||||
"WaterWheelFluidSpreadMixin",
|
||||
"accessor.AbstractProjectileDispenseBehaviorAccessor",
|
||||
|
|
Loading…
Reference in a new issue