From bd3ff6a3e5d62f85d0d77542fa535c2f0316d9da Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Mon, 2 May 2022 17:29:52 -0400 Subject: [PATCH 1/4] merge --- src/main/resources/blanket-client-tweaks.mixins.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/blanket-client-tweaks.mixins.json b/src/main/resources/blanket-client-tweaks.mixins.json index 9665236..4368314 100644 --- a/src/main/resources/blanket-client-tweaks.mixins.json +++ b/src/main/resources/blanket-client-tweaks.mixins.json @@ -6,6 +6,7 @@ "client": [ "clientCommands.ClientPlayerEntity_clientCommandsMixin", "clientCommands.ClientPlayNetworkHandler_clientCommandsMixin", + "fixes.AmethystBlock_AmethystSoundFix", "fixes.EnderDragonEntityRenderer_crystalMixin", "fixes.Entity_clientDamageMixin", "fixes.Entity_lavaDamageMixin", @@ -14,8 +15,7 @@ "fixes.HandledScreen_mouseCloseMixin", "fixes.WolfEntity_tailSpinMixin", "fixes.YggdrasilUserApiService_syncBlockListMixin", - "performance.BiomeAccess_predictionMixin", - "fixes.AmethystBlock_AmethystSoundFix" + "performance.BiomeAccess_predictionMixin" ], "injectors": { "defaultRequire": 1 From fd990e55490af5609f61f3ff7987290b6c12364a Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Mon, 2 May 2022 17:30:08 -0400 Subject: [PATCH 2/4] New Config: `itemStackTooltipUUIDFix` --- build.gradle | 4 ++ .../io/github/blanketmc/blanket/Config.java | 7 ++ .../EntityAttributeModifierAccessor.java | 14 ++++ .../mixin/fixes/ItemStack_tooltipMixin.java | 64 +++++++++++++++++++ .../blanket-client-tweaks.accesswidener | 2 + .../blanket-client-tweaks.mixins.json | 2 + src/main/resources/fabric.mod.json | 2 + 7 files changed, 95 insertions(+) create mode 100644 src/main/java/io/github/blanketmc/blanket/mixin/accessors/EntityAttributeModifierAccessor.java create mode 100644 src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java create mode 100644 src/main/resources/blanket-client-tweaks.accesswidener diff --git a/build.gradle b/build.gradle index d01d2a0..d06ea9d 100644 --- a/build.gradle +++ b/build.gradle @@ -40,6 +40,10 @@ dependencies { compileOnly("com.google.code.findbugs:annotations:3.0.1") } +loom { + accessWidenerPath = file("src/main/resources/blanket-client-tweaks.accesswidener") +} + processResources { inputs.property "version", project.version diff --git a/src/main/java/io/github/blanketmc/blanket/Config.java b/src/main/java/io/github/blanketmc/blanket/Config.java index f32cf99..eaf4e13 100644 --- a/src/main/java/io/github/blanketmc/blanket/Config.java +++ b/src/main/java/io/github/blanketmc/blanket/Config.java @@ -101,6 +101,13 @@ public final class Config { ) public static boolean fixSwappedAmethystSound = true; + //by FX - PR0CESS + @ConfigEntry( + description = "Fixes Custom attribute modifiers that use the vanilla UUIDs don't display in tooltip properly", + categories = BUGFIX + ) + public static boolean itemStackTooltipUUIDFix = true; + /* Entry Listeners diff --git a/src/main/java/io/github/blanketmc/blanket/mixin/accessors/EntityAttributeModifierAccessor.java b/src/main/java/io/github/blanketmc/blanket/mixin/accessors/EntityAttributeModifierAccessor.java new file mode 100644 index 0000000..eef71ab --- /dev/null +++ b/src/main/java/io/github/blanketmc/blanket/mixin/accessors/EntityAttributeModifierAccessor.java @@ -0,0 +1,14 @@ +package io.github.blanketmc.blanket.mixin.accessors; + +import net.minecraft.entity.attribute.EntityAttributeModifier; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.gen.Accessor; + +import java.util.UUID; + +@Mixin(EntityAttributeModifier.class) +public interface EntityAttributeModifierAccessor { + @Accessor("uuid") @Mutable + void setUuid(UUID id); +} diff --git a/src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java b/src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java new file mode 100644 index 0000000..3e53987 --- /dev/null +++ b/src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java @@ -0,0 +1,64 @@ +package io.github.blanketmc.blanket.mixin.fixes; + +import com.google.common.collect.Multimap; +import io.github.blanketmc.blanket.Config; +import io.github.blanketmc.blanket.mixin.accessors.EntityAttributeModifierAccessor; +import net.minecraft.client.item.TooltipContext; +import net.minecraft.entity.EquipmentSlot; +import net.minecraft.entity.attribute.EntityAttribute; +import net.minecraft.entity.attribute.EntityAttributeModifier; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraft.text.MutableText; +import net.minecraft.text.Text; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.Slice; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; +import org.spongepowered.asm.mixin.injection.callback.LocalCapture; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +@Mixin(ItemStack.class) +public class ItemStack_tooltipMixin { + + + @Inject( + method = "getTooltip(Lnet/minecraft/entity/player/PlayerEntity;" + + "Lnet/minecraft/client/item/TooltipContext;)Ljava/util/List;", + locals = LocalCapture.CAPTURE_FAILSOFT, + slice = @Slice( + from = @At( + value = "INVOKE", + target = "Lnet/minecraft/item/ItemStack;getAttributeModifiers(" + + "Lnet/minecraft/entity/EquipmentSlot;)Lcom/google/common/collect/Multimap;", + ordinal = 0, + shift = At.Shift.AFTER + ), + to = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/attribute/EntityAttributeModifier;getOperation()" + + "Lnet/minecraft/entity/attribute/EntityAttributeModifier$Operation;", + ordinal = 0, + shift = At.Shift.BEFORE + ) + ), + at = @At( + value = "INVOKE", + target = "Lnet/minecraft/entity/attribute/EntityAttributeModifier;getId()Ljava/util/UUID;" + ) + ) + private void getTooltip(PlayerEntity player, TooltipContext context, CallbackInfoReturnable> cir, + List list, MutableText mutableText, int i, EquipmentSlot[] var6, int var7, int var8, + EquipmentSlot equipmentSlot, Multimap multimap, + Iterator> var11, + Map.Entry entry, + EntityAttributeModifier entityAttributeModifier, double d, boolean bl) { + if (Config.itemStackTooltipUUIDFix && entityAttributeModifier.getId().equals(Item.ATTACK_DAMAGE_MODIFIER_ID)) + ((EntityAttributeModifierAccessor)entityAttributeModifier).setUuid(Item.ATTACK_DAMAGE_MODIFIER_ID); + } +} diff --git a/src/main/resources/blanket-client-tweaks.accesswidener b/src/main/resources/blanket-client-tweaks.accesswidener new file mode 100644 index 0000000..47bfb8a --- /dev/null +++ b/src/main/resources/blanket-client-tweaks.accesswidener @@ -0,0 +1,2 @@ +accessWidener v1 named +accessible field net/minecraft/item/Item ATTACK_DAMAGE_MODIFIER_ID Ljava/util/UUID; \ No newline at end of file diff --git a/src/main/resources/blanket-client-tweaks.mixins.json b/src/main/resources/blanket-client-tweaks.mixins.json index 4368314..d7b0de5 100644 --- a/src/main/resources/blanket-client-tweaks.mixins.json +++ b/src/main/resources/blanket-client-tweaks.mixins.json @@ -4,6 +4,7 @@ "package": "io.github.blanketmc.blanket.mixin", "compatibilityLevel": "JAVA_16", "client": [ + "accessors.EntityAttributeModifierAccessor", "clientCommands.ClientPlayerEntity_clientCommandsMixin", "clientCommands.ClientPlayNetworkHandler_clientCommandsMixin", "fixes.AmethystBlock_AmethystSoundFix", @@ -13,6 +14,7 @@ "fixes.Entity_localIdMixin", "fixes.FireworkRocketEntity_particleMixin", "fixes.HandledScreen_mouseCloseMixin", + "fixes.ItemStack_tooltipMixin", "fixes.WolfEntity_tailSpinMixin", "fixes.YggdrasilUserApiService_syncBlockListMixin", "performance.BiomeAccess_predictionMixin" diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 47b124f..eb6010e 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -17,6 +17,8 @@ "license": "MIT", "icon": "assets/blanket-client-tweaks/icon.png", + "accessWidener" : "blanket-client-tweaks.accesswidener", + "environment": "client", "entrypoints": { "preLaunch": [ From 549155c5fc72879c0657917002c2a1d947584033 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Mon, 2 May 2022 17:31:34 -0400 Subject: [PATCH 3/4] Make sure only to do this for the first id --- .../blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java b/src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java index 3e53987..723499a 100644 --- a/src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java +++ b/src/main/java/io/github/blanketmc/blanket/mixin/fixes/ItemStack_tooltipMixin.java @@ -49,7 +49,8 @@ public class ItemStack_tooltipMixin { ), at = @At( value = "INVOKE", - target = "Lnet/minecraft/entity/attribute/EntityAttributeModifier;getId()Ljava/util/UUID;" + target = "Lnet/minecraft/entity/attribute/EntityAttributeModifier;getId()Ljava/util/UUID;", + ordinal = 0 ) ) private void getTooltip(PlayerEntity player, TooltipContext context, CallbackInfoReturnable> cir, From 5020e6363698d357e74c3c5e0bc2eabf71f3bd77 Mon Sep 17 00:00:00 2001 From: FX - PR0CESS Date: Mon, 2 May 2022 17:33:41 -0400 Subject: [PATCH 4/4] I didn't forget the issue --- src/main/java/io/github/blanketmc/blanket/Config.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/io/github/blanketmc/blanket/Config.java b/src/main/java/io/github/blanketmc/blanket/Config.java index eaf4e13..53bd3b9 100644 --- a/src/main/java/io/github/blanketmc/blanket/Config.java +++ b/src/main/java/io/github/blanketmc/blanket/Config.java @@ -104,6 +104,7 @@ public final class Config { //by FX - PR0CESS @ConfigEntry( description = "Fixes Custom attribute modifiers that use the vanilla UUIDs don't display in tooltip properly", + issues = "MC-251252", categories = BUGFIX ) public static boolean itemStackTooltipUUIDFix = true;