mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-12-04 18:07:58 +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());
|
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))) {
|
if (!(stack.hasTag() && stack.getTag().contains("spell_traits", NbtElement.COMPOUND_TYPE))) {
|
||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,7 +78,10 @@ public class TraitDiscovery implements NbtSerialisable {
|
||||||
|
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public void appendTooltip(ItemStack stack, @Nullable World world, List<Text> tooltip) {
|
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
|
@Override
|
||||||
|
|
|
@ -52,14 +52,14 @@ public class ItemTraitsTooltipRenderer extends BaseText implements OrderedText,
|
||||||
var entries = traits.stream().toList();
|
var entries = traits.stream().toList();
|
||||||
|
|
||||||
for (int i = 0; i < entries.size(); i++) {
|
for (int i = 0; i < entries.size(); i++) {
|
||||||
int xx = x + (i % columns);
|
int xx = x + (i % columns) * 10;
|
||||||
int yy = y + (i / columns);
|
int yy = y + (i / columns) * 10;
|
||||||
Entry<Trait, Float> entry = entries.get(i);
|
Entry<Trait, Float> entry = entries.get(i);
|
||||||
|
|
||||||
RenderSystem.setShaderTexture(0, entry.getKey().getSprite());
|
RenderSystem.setShaderTexture(0, entry.getKey().getSprite());
|
||||||
DrawableHelper.drawTexture(matrices, xx, yy, 1, 0, 0, 8, 8, 8, 8);
|
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();
|
matrices.push();
|
||||||
|
|
||||||
xx += 19 - 2 - textRenderer.getWidth(string);
|
xx += 19 - 2 - textRenderer.getWidth(string);
|
||||||
|
|
Loading…
Reference in a new issue