mirror of
https://github.com/Sollace/Unicopia.git
synced 2024-11-24 05:47:59 +01:00
Wrap text in the gemstone's tooltips
This commit is contained in:
parent
3d2a50655b
commit
301c68218e
2 changed files with 24 additions and 1 deletions
|
@ -0,0 +1,22 @@
|
||||||
|
package com.minelittlepony.unicopia.client;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import net.minecraft.client.MinecraftClient;
|
||||||
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.Style;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
|
|
||||||
|
public interface FlowingText {
|
||||||
|
static Stream<Text> wrap(Text text, int maxWidth) {
|
||||||
|
return MinecraftClient.getInstance().textRenderer.getTextHandler().wrapLines(text, maxWidth, Style.EMPTY).stream().map(line -> {
|
||||||
|
LiteralText compiled = new LiteralText("");
|
||||||
|
line.visit((s, t) -> {
|
||||||
|
compiled.append(new LiteralText(t).setStyle(s));
|
||||||
|
return Optional.empty();
|
||||||
|
}, text.getStyle());
|
||||||
|
return compiled;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.ability.magic.spell.Spell;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.CustomisedSpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
import com.minelittlepony.unicopia.ability.magic.spell.effect.SpellType;
|
||||||
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
import com.minelittlepony.unicopia.ability.magic.spell.trait.SpellTraits;
|
||||||
|
import com.minelittlepony.unicopia.client.FlowingText;
|
||||||
import com.minelittlepony.unicopia.entity.player.PlayerCharmTracker;
|
import com.minelittlepony.unicopia.entity.player.PlayerCharmTracker;
|
||||||
import com.minelittlepony.unicopia.entity.player.Pony;
|
import com.minelittlepony.unicopia.entity.player.Pony;
|
||||||
|
|
||||||
|
@ -66,7 +67,7 @@ public class GemstoneItem extends Item {
|
||||||
line = line.formatted(Formatting.OBFUSCATED);
|
line = line.formatted(Formatting.OBFUSCATED);
|
||||||
}
|
}
|
||||||
|
|
||||||
lines.add(line);
|
lines.addAll(FlowingText.wrap(line, 180).toList());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue