replace explicit use of chatformatting characters with proper use
This commit is contained in:
parent
a282c8d530
commit
bccca64e19
5 changed files with 37 additions and 29 deletions
|
@ -152,14 +152,14 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
|||
throw IllegalArgumentException("Expected exactly one kv pair: $nbt")
|
||||
|
||||
return when (val key = keys.iterator().next()) {
|
||||
TAG_DOUBLE -> TextComponent(String.format("§a%.4f§r", nbt.getDouble(TAG_DOUBLE)))
|
||||
TAG_DOUBLE -> TextComponent(String.format("%.4f", nbt.getDouble(TAG_DOUBLE))).withStyle(ChatFormatting.GREEN)
|
||||
TAG_VEC3 -> {
|
||||
val vec = HexUtils.DeserializeVec3FromNBT(nbt.getLongArray(key))
|
||||
// the focus color is really more red, but we don't want to show an error-y color
|
||||
TextComponent(String.format("§d(%.2f, %.2f, %.2f)§r", vec.x, vec.y, vec.z))
|
||||
TextComponent(String.format("(%.2f, %.2f, %.2f)", vec.x, vec.y, vec.z)).withStyle(ChatFormatting.LIGHT_PURPLE)
|
||||
}
|
||||
TAG_LIST -> {
|
||||
val out = TextComponent("[")
|
||||
val out = TextComponent("[").withStyle(ChatFormatting.WHITE)
|
||||
|
||||
val arr = nbt.getList(key, Tag.TAG_COMPOUND.toInt())
|
||||
for ((i, subtag) in arr.withIndex()) {
|
||||
|
@ -171,27 +171,18 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
|||
}
|
||||
|
||||
out.append("]")
|
||||
out
|
||||
}
|
||||
TAG_WIDGET -> {
|
||||
val widget = Widget.valueOf(nbt.getString(key))
|
||||
TextComponent(
|
||||
if (widget == Widget.GARBAGE) {
|
||||
"§8§karimfexendrapuse§r"
|
||||
} else {
|
||||
// use dark purple instead of pink, so that vec3 can be pink instead of error red
|
||||
"§5$widget§r"
|
||||
}
|
||||
)
|
||||
if (widget == Widget.GARBAGE) TextComponent("arimfexendrapuse").withStyle(ChatFormatting.DARK_GRAY, ChatFormatting.OBFUSCATED)
|
||||
// use dark purple instead of pink, so that vec3 can be pink instead of error red
|
||||
else TextComponent(widget.toString()).withStyle(ChatFormatting.DARK_PURPLE)
|
||||
}
|
||||
TAG_PATTERN -> {
|
||||
val pat = HexPattern.DeserializeFromNBT(nbt.getCompound(TAG_PATTERN))
|
||||
val out = TextComponent("§6HexPattern(")
|
||||
out.append(pat.startDir.toString())
|
||||
out.append(" ")
|
||||
out.append(pat.anglesSignature())
|
||||
out.append(")§r")
|
||||
out
|
||||
val out = TextComponent("HexPattern(").withStyle(ChatFormatting.GOLD)
|
||||
out.append(TextComponent("${pat.startDir} ${pat.anglesSignature()}").withStyle(ChatFormatting.WHITE))
|
||||
out.append(")")
|
||||
}
|
||||
TAG_ENTITY -> {
|
||||
// handle pre-0.5.0 foci not having the tag
|
||||
|
@ -199,10 +190,9 @@ class SpellDatum<T : Any> private constructor(val payload: T) {
|
|||
val subtag = nbt.getCompound(TAG_ENTITY)
|
||||
val json = subtag.getString(TAG_ENTITY_NAME_CHEATY)
|
||||
val out = Component.Serializer.fromJson(json)!!
|
||||
out.style = Style.EMPTY.withColor(ChatFormatting.AQUA)
|
||||
out
|
||||
out.withStyle(ChatFormatting.AQUA)
|
||||
} catch (exn: NullPointerException) {
|
||||
TranslatableComponent("hexcasting.spelldata.entity.whoknows")
|
||||
TranslatableComponent("hexcasting.spelldata.entity.whoknows").withStyle(ChatFormatting.WHITE)
|
||||
}
|
||||
}
|
||||
else -> throw IllegalArgumentException("Unknown key $key: $nbt")
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package at.petrak.hexcasting.common.items;
|
||||
|
||||
import at.petrak.hexcasting.api.spell.SpellDatum;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TextComponent;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
@ -30,7 +32,17 @@ public class ItemSpellbook extends ItemDataHolder {
|
|||
if (tag.contains(TAG_SELECTED_PAGE)) {
|
||||
var pageIdx = tag.getInt(TAG_SELECTED_PAGE);
|
||||
var pages = tag.getCompound(ItemSpellbook.TAG_PAGES);
|
||||
tooltip.add(new TranslatableComponent("hexcasting.tooltip.spellbook.page", pageIdx, HighestPage(pages)));
|
||||
int highest = HighestPage(pages);
|
||||
if (highest != 0) {
|
||||
tooltip.add(new TranslatableComponent("hexcasting.tooltip.spellbook.page",
|
||||
new TextComponent(String.valueOf(pageIdx)).withStyle(ChatFormatting.WHITE),
|
||||
new TextComponent(String.valueOf(highest)).withStyle(ChatFormatting.WHITE))
|
||||
.withStyle(ChatFormatting.GRAY));
|
||||
} else {
|
||||
tooltip.add(new TranslatableComponent("hexcasting.tooltip.spellbook.empty").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
} else {
|
||||
tooltip.add(new TranslatableComponent("hexcasting.tooltip.spellbook.empty").withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
|
||||
super.appendHoverText(stack, level, tooltip, isAdvanced);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package at.petrak.hexcasting.common.items.magic;
|
||||
|
||||
import at.petrak.hexcasting.common.casting.ManaHelper;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.nbt.CompoundTag;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
|
@ -85,7 +86,7 @@ public abstract class ItemManaHolder extends Item {
|
|||
new TranslatableComponent("item.hexcasting.manaholder.amount",
|
||||
String.format("%,d", imh.getManaAmt(tag)),
|
||||
String.format("%,d", imh.getMaxManaAmt(tag)),
|
||||
100f * imh.getManaFullness(tag)));
|
||||
100f * imh.getManaFullness(tag)).withStyle(ChatFormatting.GRAY));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import at.petrak.hexcasting.common.items.ItemAbacus;
|
|||
import at.petrak.hexcasting.common.items.ItemSpellbook;
|
||||
import at.petrak.hexcasting.common.lib.HexSounds;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
import net.minecraft.network.chat.TranslatableComponent;
|
||||
import net.minecraft.server.level.ServerPlayer;
|
||||
|
@ -87,7 +88,10 @@ public record MsgShiftScrollSyn(InteractionHand hand, double scrollDelta, boolea
|
|||
sender.level.playSound(null, sender.getX(), sender.getY(), sender.getZ(),
|
||||
HexSounds.ABACUS.get(), SoundSource.PLAYERS, 0.5f, pitch);
|
||||
|
||||
var popup = SpellDatum.DisplayFromTag(HexItems.ABACUS.get().readDatumTag(stack));
|
||||
sender.displayClientMessage(new TranslatableComponent("hexcasting.tooltip.abacus", popup), true);
|
||||
var datumTag = HexItems.ABACUS.get().readDatumTag(stack);
|
||||
if (datumTag != null) {
|
||||
var popup = SpellDatum.DisplayFromTag(datumTag);
|
||||
sender.displayClientMessage(new TranslatableComponent("hexcasting.tooltip.abacus", popup).withStyle(ChatFormatting.GREEN, ChatFormatting.BOLD), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
"item.hexcasting.trinket": "Trinket",
|
||||
"item.hexcasting.artifact": "Artifact",
|
||||
"item.hexcasting.battery": "Phial of Media",
|
||||
"item.hexcasting.manaholder.amount": "§7N*merical Mana: %s/%s (%.0f%%)§r",
|
||||
"item.hexcasting.manaholder.amount": "N*merical Mana: %s/%s (%.0f%%)",
|
||||
"item.hexcasting.amethyst_dust": "Amethyst Dust",
|
||||
"item.hexcasting.charged_amethyst": "Charged Amethyst",
|
||||
"item.hexcasting.lens": "Scrying Lens",
|
||||
|
@ -69,8 +69,9 @@
|
|||
|
||||
"itemGroup.hexcasting": "Hexcasting",
|
||||
|
||||
"hexcasting.tooltip.spellbook.page": "§7Selected Page §a§l%d§7/§a§l%d§r",
|
||||
"hexcasting.tooltip.abacus": "§a§l%d§r",
|
||||
"hexcasting.tooltip.spellbook.page": "Selected Page %d/%d",
|
||||
"hexcasting.tooltip.spellbook.empty": "Empty",
|
||||
"hexcasting.tooltip.abacus": "%d",
|
||||
"hexcasting.tooltip.abacus.reset": "Reset to 0",
|
||||
"hexcasting.tooltip.abacus.reset.nice": "nice",
|
||||
"hexcasting.tooltip.lens.impetus.mana": "%s Dusts",
|
||||
|
@ -82,7 +83,7 @@
|
|||
"hexcasting.tooltip.brainsweep.biome": "Biome: %s",
|
||||
"hexcasting.tooltip.brainsweep.biome.any": "Any Biome",
|
||||
"hexcasting.tooltip.brainsweep.min_level": "Level %d or higher",
|
||||
"hexcasting.spelldata.onitem": "§7Contains: §r%s",
|
||||
"hexcasting.spelldata.onitem": "Contains: %s",
|
||||
"hexcasting.spelldata.entity.whoknows": "An Entity (this should only show up if this was stored before the 0.5.0 update, use Scribe's Reflection, Scribe's Gambit to fix)",
|
||||
|
||||
"advancement.hexcasting:root": "Hexcasting Research",
|
||||
|
|
Loading…
Reference in a new issue