mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-03 17:37:59 +01:00
Fixed traits not appearing correctly in tooltips
This commit is contained in:
parent
c8fc88711d
commit
8124731f58
3 changed files with 8 additions and 5 deletions
|
@ -148,7 +148,7 @@ public final class SpellTraits implements Iterable<Map.Entry<Trait, Float>> {
|
|||
return of(block.asItem());
|
||||
}
|
||||
|
||||
private static Optional<SpellTraits> getEmbeddedTraits(ItemStack stack) {
|
||||
public static Optional<SpellTraits> getEmbeddedTraits(ItemStack stack) {
|
||||
if (!(stack.hasTag() && stack.getTag().contains("spell_traits", NbtElement.COMPOUND_TYPE))) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
|
|
@ -78,7 +78,10 @@ public class TraitDiscovery implements NbtSerialisable {
|
|||
|
||||
@Environment(EnvType.CLIENT)
|
||||
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip) {
|
||||
getKnownTraits(stack.getItem()).appendTooltip(tooltip);
|
||||
SpellTraits.getEmbeddedTraits(stack)
|
||||
.flatMap(embedded -> SpellTraits.fromEntries(embedded.entries().stream().filter(e -> isKnown(e.getKey()))))
|
||||
.orElseGet(() -> getKnownTraits(stack.getItem()))
|
||||
.appendTooltip(tooltip);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -52,14 +52,14 @@ public class ItemTraitsTooltipRenderer extends BaseText implements OrderedText,
|
|||
var entries = traits.stream().toList();
|
||||
|
||||
for (int i = 0; i < entries.size(); i++) {
|
||||
int xx = x + (i % columns);
|
||||
int yy = y + (i / columns);
|
||||
int xx = x + (i % columns) * 10;
|
||||
int yy = y + (i / columns) * 10;
|
||||
Entry<Trait, Float> entry = entries.get(i);
|
||||
|
||||
RenderSystem.setShaderTexture(0, entry.getKey().getSprite());
|
||||
DrawableHelper.drawTexture(matrices, xx, yy, 1, 0, 0, 8, 8, 8, 8);
|
||||
|
||||
String string = String.valueOf(entry.getValue());
|
||||
String string = String.format("%.2f", entry.getValue());
|
||||
matrices.push();
|
||||
|
||||
xx += 19 - 2 - textRenderer.getWidth(string);
|
||||
|
|
Loading…
Reference in a new issue