From 7fd672c903e0666f136fa1cea9b9a556d4f56d54 Mon Sep 17 00:00:00 2001 From: DancingSnow <1121149616@qq.com> Date: Mon, 29 Apr 2024 02:03:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dforge=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E5=90=AF=E5=8A=A8=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mixin}/EnchantmentHelperMixin.java | 2 +- .../resources/anvilcraft-common.mixins.json | 67 ++++++++++--------- .../src/main/resources/anvilcraft.mixins.json | 1 - .../mixin/forge/ForgeItemStackMixin.java | 26 ------- .../src/main/resources/anvilcraft.mixins.json | 1 - 5 files changed, 35 insertions(+), 62 deletions(-) rename {fabric/src/main/java/dev/dubhe/anvilcraft/mixin/fabric => common/src/main/java/dev/dubhe/anvilcraft/mixin}/EnchantmentHelperMixin.java (96%) delete mode 100644 forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/ForgeItemStackMixin.java diff --git a/fabric/src/main/java/dev/dubhe/anvilcraft/mixin/fabric/EnchantmentHelperMixin.java b/common/src/main/java/dev/dubhe/anvilcraft/mixin/EnchantmentHelperMixin.java similarity index 96% rename from fabric/src/main/java/dev/dubhe/anvilcraft/mixin/fabric/EnchantmentHelperMixin.java rename to common/src/main/java/dev/dubhe/anvilcraft/mixin/EnchantmentHelperMixin.java index 33bae92df..a59d3b6ff 100644 --- a/fabric/src/main/java/dev/dubhe/anvilcraft/mixin/fabric/EnchantmentHelperMixin.java +++ b/common/src/main/java/dev/dubhe/anvilcraft/mixin/EnchantmentHelperMixin.java @@ -1,4 +1,4 @@ -package dev.dubhe.anvilcraft.mixin.fabric; +package dev.dubhe.anvilcraft.mixin; import dev.dubhe.anvilcraft.item.HasDefaultEnchantment; import net.minecraft.world.item.ItemStack; diff --git a/common/src/main/resources/anvilcraft-common.mixins.json b/common/src/main/resources/anvilcraft-common.mixins.json index 0273d9ecb..24b7d2c2a 100644 --- a/common/src/main/resources/anvilcraft-common.mixins.json +++ b/common/src/main/resources/anvilcraft-common.mixins.json @@ -1,35 +1,36 @@ { - "required": true, - "minVersion": "0.8", - "package": "dev.dubhe.anvilcraft.mixin", - "compatibilityLevel": "JAVA_17", - "mixins": [ - "AbstractCauldronBlockMixin", - "AnvilBlockMixin", - "BeaconMenuMixin", - "BucketItemMixin", - "ClientboundUpdateRecipesPacketMixin", - "DiggerItemMixin", - "DispenseItemEmptyBottleBehaviorMixin", - "DispenseItemEmptyBucketBehaviorMixin", - "DispenseItemWaterBottleBehaviorMixin", - "FlyingHitEntityMixin", - "HoeItemMixin", - "ItemEntityMixin", - "LivingEntityMixin", - "PlayerHitEntityMixin", - "SolidBucketItemMixin", - "accessor.BaseSpawnerAccessor", - "accessor.FallingBlockEntityAccessor", - "accessor.LootContextParamSetsAccessor" - ], - "client": [ - "LevelRendererMixin", - "PowerGridInformationRenderMixin", - "accessor.ItemInHandRendererAccessor", - "accessor.MinecraftAccessor" - ], - "injectors": { - "defaultRequire": 1 - } + "required": true, + "minVersion": "0.8", + "package": "dev.dubhe.anvilcraft.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "AbstractCauldronBlockMixin", + "AnvilBlockMixin", + "BeaconMenuMixin", + "BucketItemMixin", + "ClientboundUpdateRecipesPacketMixin", + "DiggerItemMixin", + "DispenseItemEmptyBottleBehaviorMixin", + "DispenseItemEmptyBucketBehaviorMixin", + "DispenseItemWaterBottleBehaviorMixin", + "EnchantmentHelperMixin", + "FlyingHitEntityMixin", + "HoeItemMixin", + "ItemEntityMixin", + "LivingEntityMixin", + "PlayerHitEntityMixin", + "SolidBucketItemMixin", + "accessor.BaseSpawnerAccessor", + "accessor.FallingBlockEntityAccessor", + "accessor.LootContextParamSetsAccessor" + ], + "client": [ + "LevelRendererMixin", + "PowerGridInformationRenderMixin", + "accessor.ItemInHandRendererAccessor", + "accessor.MinecraftAccessor" + ], + "injectors": { + "defaultRequire": 1 + } } diff --git a/fabric/src/main/resources/anvilcraft.mixins.json b/fabric/src/main/resources/anvilcraft.mixins.json index 2110c6f75..6b7eb33f2 100644 --- a/fabric/src/main/resources/anvilcraft.mixins.json +++ b/fabric/src/main/resources/anvilcraft.mixins.json @@ -4,7 +4,6 @@ "package": "dev.dubhe.anvilcraft.mixin.fabric", "compatibilityLevel": "JAVA_17", "mixins": [ - "EnchantmentHelperMixin", "FallingBlockEntityMixin", "LightningBoltMixin", "PistonMovingBlockEntityMixin", diff --git a/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/ForgeItemStackMixin.java b/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/ForgeItemStackMixin.java deleted file mode 100644 index 8c20272b9..000000000 --- a/forge/src/main/java/dev/dubhe/anvilcraft/mixin/forge/ForgeItemStackMixin.java +++ /dev/null @@ -1,26 +0,0 @@ -package dev.dubhe.anvilcraft.mixin.forge; - -import dev.dubhe.anvilcraft.item.HasDefaultEnchantment; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.Enchantment; -import net.minecraftforge.common.extensions.IForgeItemStack; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -@Mixin(value = IForgeItemStack.class, remap = false) -abstract class ForgeItemStackMixin implements IForgeItemStack { - @Shadow - protected abstract ItemStack self(); - - @Inject(method = "getEnchantmentLevel", at = @At("RETURN"), cancellable = true) - private void getEnchantmentLevel(Enchantment enchantment, CallbackInfoReturnable cir) { - ItemStack self = self(); - if (!(self.getItem() instanceof HasDefaultEnchantment item)) return; - int level = cir.getReturnValue(); - int defaultLevel = item.getDefaultEnchantmentLevel(enchantment); - cir.setReturnValue(Math.max(level, defaultLevel)); - } -} diff --git a/forge/src/main/resources/anvilcraft.mixins.json b/forge/src/main/resources/anvilcraft.mixins.json index 989928bd7..f32e060c9 100644 --- a/forge/src/main/resources/anvilcraft.mixins.json +++ b/forge/src/main/resources/anvilcraft.mixins.json @@ -6,7 +6,6 @@ "mixins": [ "CraftingHelperMixin", "FallingBlockEntityMixin", - "ForgeItemStackMixin", "LevelChunkMixin", "LightningBoltMixin", "MinecraftServerMixin",