From 2e152f9b0873288d05365409ac621e5dd73e6b07 Mon Sep 17 00:00:00 2001 From: "yrsegal@gmail.com" Date: Fri, 11 Nov 2022 19:48:59 -0500 Subject: [PATCH] simplify Flock's Gambit, use formatting for display components, add first-party type names --- .../hexcasting/api/spell/iota/BooleanIota.java | 2 +- .../hexcasting/api/spell/iota/IotaType.java | 11 +++++++++++ .../hexcasting/api/spell/iota/ListIota.java | 5 ++--- .../hexcasting/api/spell/iota/NullIota.java | 3 +-- .../hexcasting/api/spell/iota/PatternIota.java | 7 +++---- .../casting/operators/lists/OpLastNToList.kt | 3 +-- .../resources/assets/hexcasting/lang/en_us.json | 15 +++++++++++++++ 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/BooleanIota.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/BooleanIota.java index 70ce915c..3dad4ed7 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/BooleanIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/BooleanIota.java @@ -62,7 +62,7 @@ public class BooleanIota extends Iota { } public static Component display(boolean b) { - return Component.literal(b ? "True" : "False") + return Component.literal(b ? "hexcasting.tooltip.boolean_true" : "hexcasting.tooltip.boolean_false") .withStyle(b ? ChatFormatting.DARK_GREEN : ChatFormatting.DARK_RED); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/IotaType.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/IotaType.java index c0a8ec28..1ee95de6 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/IotaType.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/IotaType.java @@ -1,8 +1,10 @@ package at.petrak.hexcasting.api.spell.iota; +import at.petrak.hexcasting.common.lib.HexIotaTypes; import net.minecraft.client.gui.Font; import net.minecraft.nbt.Tag; import net.minecraft.network.chat.Component; +import net.minecraft.network.chat.TextColor; import net.minecraft.server.level.ServerLevel; import net.minecraft.util.FormattedCharSequence; @@ -42,4 +44,13 @@ public abstract class IotaType { * Get the color associated with this datum type. */ public abstract int color(); + + /** + * Get a display component that's the name of this iota type. + */ + public Component typeName() { + var key = HexIotaTypes.REGISTRY.getKey(this); + return Component.translatable("hexcasting.iota." + key) + .withStyle(style -> style.withColor(TextColor.fromRgb(color()))); + } } diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ListIota.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ListIota.java index a2296009..aaf1cd8b 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ListIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/ListIota.java @@ -97,7 +97,7 @@ public class ListIota extends Iota { @Override public Component display(Tag tag) { - var out = Component.literal("[").withStyle(ChatFormatting.DARK_PURPLE); + var out = Component.empty(); var list = HexUtils.downcast(tag, ListTag.TYPE); for (int i = 0; i < list.size(); i++) { Tag sub = list.get(i); @@ -109,8 +109,7 @@ public class ListIota extends Iota { out.append(", "); } } - out.append(Component.literal("]").withStyle(ChatFormatting.DARK_PURPLE)); - return out; + return Component.translatable("hexcasting.tooltip.list_contents", out).withStyle(ChatFormatting.DARK_PURPLE); } @Override diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/NullIota.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/NullIota.java index 6b80c7a7..e656024f 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/NullIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/NullIota.java @@ -15,8 +15,7 @@ import org.jetbrains.annotations.Nullable; public class NullIota extends Iota { private static final Object NULL_SUBSTITUTE = new Object(); - public static final Component DISPLAY = Component.literal("NULL") - .withStyle(ChatFormatting.GRAY); + public static final Component DISPLAY = Component.translatable("hexcasting.tooltip.null_iota").withStyle(ChatFormatting.GRAY); public NullIota() { // We have to pass *something* here, but there's nothing that actually needs to go there, diff --git a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/PatternIota.java b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/PatternIota.java index 56c0362b..537a02e0 100644 --- a/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/PatternIota.java +++ b/Common/src/main/java/at/petrak/hexcasting/api/spell/iota/PatternIota.java @@ -67,7 +67,6 @@ public class PatternIota extends Iota { } public static Component display(HexPattern pat) { - var component = Component.literal("HexPattern(").withStyle(ChatFormatting.GOLD); var bob = new StringBuilder(); bob.append(pat.getStartDir()); @@ -76,8 +75,8 @@ public class PatternIota extends Iota { bob.append(" "); bob.append(sig); } - component.append(Component.literal(bob.toString()).withStyle(ChatFormatting.WHITE)); - component.append(Component.literal(")").withStyle(ChatFormatting.GOLD)); - return component; + return Component.translatable("hexcasting.tooltip.pattern_iota", + Component.literal(bob.toString()).withStyle(ChatFormatting.WHITE)) + .withStyle(ChatFormatting.GOLD); } } diff --git a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt index 9eab4247..2121ddc1 100644 --- a/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt +++ b/Common/src/main/java/at/petrak/hexcasting/common/casting/operators/lists/OpLastNToList.kt @@ -22,8 +22,7 @@ object OpLastNToList : Action { stack.removeLast() val output = mutableListOf() output.addAll(stack.takeLast(yoinkCount)) - val endSize = stack.size - output.toList().size - while (stack.size != endSize) { + for (i in 0 until yoinkCount) { stack.removeLast() } stack.addAll(output.asActionResult) diff --git a/Common/src/main/resources/assets/hexcasting/lang/en_us.json b/Common/src/main/resources/assets/hexcasting/lang/en_us.json index 5d7b875a..874a80cd 100644 --- a/Common/src/main/resources/assets/hexcasting/lang/en_us.json +++ b/Common/src/main/resources/assets/hexcasting/lang/en_us.json @@ -146,6 +146,21 @@ "hexcasting.tooltip.media_amount": "Contains: %s (%s)", "hexcasting.tooltip.media_amount.advanced": "Contains: %s/%s (%s)", + "hexcasting.tooltip.list_contents": "[%s]", + "hexcasting.tooltip.pattern_iota": "HexPattern(%s)", + "hexcasting.tooltip.null_iota": "NULL", + "hexcasting.tooltip.boolean_true": "True", + "hexcasting.tooltip.boolean_false": "False", + + "hexcasting.iota.hexcasting:null": "Null", + "hexcasting.iota.hexcasting:double": "Number", + "hexcasting.iota.hexcasting:boolean": "Boolean", + "hexcasting.iota.hexcasting:entity": "Entity", + "hexcasting.iota.hexcasting:list": "List", + "hexcasting.iota.hexcasting:pattern": "Pattern", + "hexcasting.iota.hexcasting:garbage": "Garbage", + "hexcasting.iota.hexcasting:vec3": "Vector", + "gui.hexcasting.spellcasting": "Hex Grid", "tag.hexcasting.staves": "Hex Staves", "tag.hexcasting.edified_logs": "Edified Logs",