|
1 | 1 | package de.hysky.skyblocker.mixins;
|
2 | 2 |
|
3 | 3 | import com.llamalad7.mixinextras.injector.ModifyReturnValue;
|
| 4 | +import com.llamalad7.mixinextras.sugar.Local; |
| 5 | + |
4 | 6 | import de.hysky.skyblocker.config.SkyblockerConfigManager;
|
5 | 7 | import de.hysky.skyblocker.injected.SkyblockerStack;
|
6 | 8 | import de.hysky.skyblocker.skyblock.item.PetInfo;
|
|
14 | 16 | import net.minecraft.item.ItemStack;
|
15 | 17 | import net.minecraft.item.tooltip.TooltipAppender;
|
16 | 18 | import net.minecraft.text.Text;
|
| 19 | +import net.minecraft.util.Formatting; |
| 20 | + |
| 21 | +import java.util.List; |
| 22 | + |
17 | 23 | import org.jetbrains.annotations.NotNull;
|
18 | 24 | import org.spongepowered.asm.mixin.Mixin;
|
19 | 25 | import org.spongepowered.asm.mixin.Shadow;
|
20 | 26 | import org.spongepowered.asm.mixin.Unique;
|
21 | 27 | import org.spongepowered.asm.mixin.injection.At;
|
22 | 28 | import org.spongepowered.asm.mixin.injection.Inject;
|
23 | 29 | import org.spongepowered.asm.mixin.injection.ModifyVariable;
|
| 30 | +import org.spongepowered.asm.mixin.injection.Slice; |
24 | 31 | import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
| 32 | +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; |
25 | 33 |
|
26 | 34 | @Mixin(ItemStack.class)
|
27 | 35 | public abstract class ItemStackMixin implements ComponentHolder, SkyblockerStack {
|
@@ -63,6 +71,20 @@ public abstract class ItemStackMixin implements ComponentHolder, SkyblockerStack
|
63 | 71 | return Utils.isOnSkyblock() && original instanceof ItemEnchantmentsComponent component ? component.withShowInTooltip(false) : original;
|
64 | 72 | }
|
65 | 73 |
|
| 74 | + @Inject(method = "getTooltip", |
| 75 | + slice = @Slice(from = @At(value = "INVOKE", target = "Lnet/minecraft/registry/DefaultedRegistry;getId(Ljava/lang/Object;)Lnet/minecraft/util/Identifier;")), |
| 76 | + at = @At(value = "INVOKE", target = "Ljava/util/List;add(Ljava/lang/Object;)Z", shift = At.Shift.AFTER, ordinal = 0) |
| 77 | + ) |
| 78 | + private void skyblocker$skyblockIdTooltip(CallbackInfoReturnable<List<Text>> cir, @Local List<Text> lines) { |
| 79 | + if (Utils.isOnSkyblock()) { |
| 80 | + String skyblockId = getSkyblockId(); |
| 81 | + |
| 82 | + if (!skyblockId.isEmpty()) { |
| 83 | + lines.add(Text.literal("skyblock:" + skyblockId).formatted(Formatting.DARK_GRAY)); |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + |
66 | 88 | /**
|
67 | 89 | * Updates the durability of this item stack every tick when in the inventory.
|
68 | 90 | */
|
|
0 commit comments