simplify Flock's Gambit, use formatting for display components, add first-party type names
This commit is contained in:
parent
0193da311d
commit
2e152f9b08
7 changed files with 34 additions and 12 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<T extends Iota> {
|
|||
* 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())));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,8 +22,7 @@ object OpLastNToList : Action {
|
|||
stack.removeLast()
|
||||
val output = mutableListOf<Iota>()
|
||||
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)
|
||||
|
|
|
@ -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",
|
||||
|
|
Loading…
Reference in a new issue