From f56196c21dc5c50aa8b1bcfacb0b4f7d5d74c5fb Mon Sep 17 00:00:00 2001 From: Su5eD Date: Sun, 11 Aug 2024 10:12:39 +0200 Subject: [PATCH] Update to 1.21.1 Fixes #143 --- .../mixin/item/AnvilScreenHandlerMixin.java | 12 ++++++------ .../fabric/mixin/item/EnchantCommandMixin.java | 14 ++++++-------- .../item/EnchantRandomlyLootFunctionMixin.java | 15 ++++++++------- .../fabric/mixin/item/IItemExtensionMixin.java | 5 ----- ffapi.gradle.properties | 6 +++--- 5 files changed, 23 insertions(+), 29 deletions(-) diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/AnvilScreenHandlerMixin.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/AnvilScreenHandlerMixin.java index 0460900be..5da95e3f6 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/AnvilScreenHandlerMixin.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/AnvilScreenHandlerMixin.java @@ -16,11 +16,11 @@ package net.fabricmc.fabric.mixin.item; -import com.llamalad7.mixinextras.sugar.Local; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import org.jetbrains.annotations.Nullable; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import net.fabricmc.fabric.api.item.v1.EnchantingContext; import net.minecraft.core.Holder; import net.minecraft.world.entity.player.Inventory; @@ -37,14 +37,14 @@ abstract class AnvilScreenHandlerMixin extends ItemCombinerMenu { super(type, syncId, playerInventory, context); } - @Redirect( + @WrapOperation( method = "createResult", at = @At( value = "INVOKE", - target = "Lnet/minecraft/world/item/enchantment/Enchantment;canEnchant(Lnet/minecraft/world/item/ItemStack;)Z" + target = "Lnet/minecraft/world/item/ItemStack;supportsEnchantment(Lnet/minecraft/core/Holder;)Z" ) ) - private boolean callAllowEnchantingEvent(Enchantment instance, ItemStack stack, @Local Holder registryEntry) { - return stack.canBeEnchantedWith(registryEntry, EnchantingContext.ACCEPTABLE); + private boolean callAllowEnchantingEvent(ItemStack instance, Holder registryEntry, Operation original) { + return instance.canBeEnchantedWith(registryEntry, EnchantingContext.ACCEPTABLE) || original.call(instance, registryEntry); } } diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantCommandMixin.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantCommandMixin.java index e294ba287..c15569451 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantCommandMixin.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantCommandMixin.java @@ -16,26 +16,24 @@ package net.fabricmc.fabric.mixin.item; -import java.util.Collection; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; import net.fabricmc.fabric.api.item.v1.EnchantingContext; -import net.minecraft.commands.CommandSourceStack; import net.minecraft.core.Holder; import net.minecraft.server.commands.EnchantCommand; -import net.minecraft.world.entity.Entity; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.Enchantment; @Mixin(EnchantCommand.class) abstract class EnchantCommandMixin { - @Redirect( + @WrapOperation( method = "enchant", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/Enchantment;canEnchant(Lnet/minecraft/world/item/ItemStack;)Z") + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;supportsEnchantment(Lnet/minecraft/core/Holder;)Z") ) - private static boolean callAllowEnchantingEvent(Enchantment instance, ItemStack stack, CommandSourceStack source, Collection targets, Holder enchantment) { - return stack.canBeEnchantedWith(enchantment, EnchantingContext.ACCEPTABLE); + private static boolean callAllowEnchantingEvent(ItemStack instance, Holder enchantment, Operation original) { + return instance.canBeEnchantedWith(enchantment, EnchantingContext.ACCEPTABLE) || original.call(instance, enchantment); } } diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantRandomlyLootFunctionMixin.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantRandomlyLootFunctionMixin.java index 05352d496..be78e4b29 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantRandomlyLootFunctionMixin.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/EnchantRandomlyLootFunctionMixin.java @@ -16,22 +16,23 @@ package net.fabricmc.fabric.mixin.item; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Redirect; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.fabricmc.fabric.api.item.v1.EnchantingContext; import net.minecraft.core.Holder; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.enchantment.Enchantment; import net.minecraft.world.level.storage.loot.functions.EnchantRandomlyFunction; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; @Mixin(EnchantRandomlyFunction.class) abstract class EnchantRandomlyLootFunctionMixin { - @Redirect( + @WrapOperation( method = "lambda$run$4", - at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/enchantment/Enchantment;canEnchant(Lnet/minecraft/world/item/ItemStack;)Z") + at = @At(value = "INVOKE", target = "Lnet/minecraft/world/item/ItemStack;supportsEnchantment(Lnet/minecraft/core/Holder;)Z") ) - private static boolean callAllowEnchantingEvent(Enchantment enchantment, ItemStack stack, boolean bl, ItemStack itemStack, Holder registryEntry) { - return stack.canBeEnchantedWith(registryEntry, EnchantingContext.ACCEPTABLE); + private static boolean callAllowEnchantingEvent(ItemStack stack, Holder registryEntry, Operation original) { + return stack.canBeEnchantedWith(registryEntry, EnchantingContext.ACCEPTABLE) || original.call(stack, registryEntry); } } diff --git a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/IItemExtensionMixin.java b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/IItemExtensionMixin.java index 23baf8d73..30abf2715 100644 --- a/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/IItemExtensionMixin.java +++ b/fabric-item-api-v1/src/main/java/net/fabricmc/fabric/mixin/item/IItemExtensionMixin.java @@ -1,17 +1,12 @@ package net.fabricmc.fabric.mixin.item; -import com.llamalad7.mixinextras.injector.wrapoperation.Operation; -import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import net.fabricmc.fabric.api.item.v1.EquipmentSlotProvider; import net.fabricmc.fabric.api.item.v1.FabricItem; import net.fabricmc.fabric.impl.item.ItemExtensions; import net.fabricmc.fabric.impl.item.RecursivityHelper; -import net.minecraft.core.Holder; import net.minecraft.world.entity.EquipmentSlot; import net.minecraft.world.entity.LivingEntity; -import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.enchantment.Enchantment; import net.neoforged.neoforge.common.extensions.IItemExtension; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; diff --git a/ffapi.gradle.properties b/ffapi.gradle.properties index 2ab4eb7cf..42e8c68e9 100644 --- a/ffapi.gradle.properties +++ b/ffapi.gradle.properties @@ -3,8 +3,8 @@ fabric.loom.dontRemap=true implementationVersion=2.0.10 -versionMc=1.21 -versionForge=21.0.160 +versionMc=1.21.1 +versionForge=21.1.4 versionForgifiedFabricLoader=2.5.29+0.16.0+1.21 versionFabricLoader=0.16.0 @@ -12,4 +12,4 @@ curseForgeId=889079 modrinthId=Aqlf1Shp githubRepository=Sinytra/ForgifiedFabricAPI # This is the branch the release tag will be created from -publishBranch=1.21 +publishBranch=1.21.1