show quantity in item links

This commit is contained in:
Draycia committed 2026-01-10 23:35:22 -08:00
1 parent 833e6fa9a8
commit 7809c640a3
2 files changed
+26 -2

No files matched your search

@@ -38,6 +38,7 @@ import net.kyori.adventure.audience.ForwardingAudience;
import net.kyori.adventure.identity.Identity;
import net.kyori.adventure.platform.modcommon.MinecraftServerAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.TextColor;
import net.minecraft.server.level.ServerPlayer;
import net.minecraft.world.entity.EquipmentSlot;
import net.minecraft.world.item.ItemStack;
@@ -157,7 +158,18 @@ public class CarbonPlayerFabric extends WrappedCarbonPlayer implements Forwardin
return null;
}
return MinecraftServerAudiences.of(player.level().getServer()).asAdventure(item.getDisplayName());
final int amount = Math.min(item.getCount(), 99);
final Component quantity = amount <= 1 ? Component.empty() : Component.text(" x" + amount);
final Component interim = MinecraftServerAudiences.of(player.level().getServer()).asAdventure(item.getDisplayName());
return Component.empty().append(
Component.text("["),
interim,
quantity,
Component.text("]")
)
.hoverEvent(item)
.colorIfAbsent(TextColor.color(item.getRarity().color().getColor()));
}
@Override