Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Item stack tool tip fix #34

Open
wants to merge 4 commits into
base: 1.18
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions src/main/java/io/github/blanketmc/blanket/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,14 @@ 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",
issues = "MC-251252",
categories = BUGFIX
)
public static boolean itemStackTooltipUUIDFix = true;

/*

Entry Listeners
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
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;",
ordinal = 0
)
)
private void getTooltip(PlayerEntity player, TooltipContext context, CallbackInfoReturnable<List<Text>> cir,
List<Text> list, MutableText mutableText, int i, EquipmentSlot[] var6, int var7, int var8,
EquipmentSlot equipmentSlot, Multimap<EntityAttribute, EntityAttributeModifier> multimap,
Iterator<Map.Entry<EntityAttribute, EntityAttributeModifier>> var11,
Map.Entry<EntityAttribute, EntityAttributeModifier> 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);
}
}
2 changes: 2 additions & 0 deletions src/main/resources/blanket-client-tweaks.accesswidener
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
accessWidener v1 named
accessible field net/minecraft/item/Item ATTACK_DAMAGE_MODIFIER_ID Ljava/util/UUID;
6 changes: 4 additions & 2 deletions src/main/resources/blanket-client-tweaks.mixins.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
"package": "io.github.blanketmc.blanket.mixin",
"compatibilityLevel": "JAVA_16",
"client": [
"accessors.EntityAttributeModifierAccessor",
"clientCommands.ClientPlayerEntity_clientCommandsMixin",
"clientCommands.ClientPlayNetworkHandler_clientCommandsMixin",
"fixes.AmethystBlock_AmethystSoundFix",
"fixes.EnderDragonEntityRenderer_crystalMixin",
"fixes.Entity_clientDamageMixin",
"fixes.Entity_lavaDamageMixin",
"fixes.Entity_localIdMixin",
"fixes.FireworkRocketEntity_particleMixin",
"fixes.HandledScreen_mouseCloseMixin",
"fixes.ItemStack_tooltipMixin",
"fixes.WolfEntity_tailSpinMixin",
"fixes.YggdrasilUserApiService_syncBlockListMixin",
"performance.BiomeAccess_predictionMixin",
"fixes.AmethystBlock_AmethystSoundFix"
"performance.BiomeAccess_predictionMixin"
],
"injectors": {
"defaultRequire": 1
Expand Down
2 changes: 2 additions & 0 deletions src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
"license": "MIT",
"icon": "assets/blanket-client-tweaks/icon.png",

"accessWidener" : "blanket-client-tweaks.accesswidener",

"environment": "client",
"entrypoints": {
"preLaunch": [
Expand Down