Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import at.petrak.hexcasting.api.HexAPI;
import at.petrak.hexcasting.api.utils.HexUtils;
import at.petrak.hexcasting.common.lib.hex.HexIotaTypes;
import com.mojang.datafixers.util.Pair;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.Font;
import net.minecraft.nbt.CompoundTag;
Expand Down Expand Up @@ -53,6 +52,13 @@ public Component typeName() {
.withStyle(style -> style.withColor(TextColor.fromRgb(color())));
}

/**
* If commas should be omitted when the iota is inside of a list iota
*/
public boolean omitCommas() {
return false;
}

public static CompoundTag serialize(Iota iota) {
var type = iota.getType();
var typeId = HexIotaTypes.REGISTRY.getKey(type);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,12 +132,13 @@ public Component display(Tag tag) {
out.append(IotaType.getDisplay(csub));

// only add a comma between 2 non-patterns (commas don't look good with Inline patterns)
// TODO: maybe add a method on IotaType to allow it to opt out of commas?
if (i < list.size() - 1) {
var thisIotaNeedsComma = IotaType.getTypeFromTag(csub) != PatternIota.TYPE;
var nextIotaNeedsComma = IotaType.getTypeFromTag(HexUtils.downcast(list.get(i+1), CompoundTag.TYPE)) != PatternIota.TYPE;
var thisType = IotaType.getTypeFromTag(csub);
var nextType = IotaType.getTypeFromTag(HexUtils.downcast(list.get(i+1), CompoundTag.TYPE));
var thisIotaOmitsComma = thisType != null && thisType.omitCommas();
var nextIotaOmitsComma = nextType != null && nextType.omitCommas();
var alwaysShowCommas = HexConfig.client() != null && HexConfig.client().alwaysShowListCommas();
if (thisIotaNeedsComma || nextIotaNeedsComma || alwaysShowCommas)
if (!thisIotaOmitsComma || !nextIotaOmitsComma || alwaysShowCommas)
out.append(", ");
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,11 @@ public Component display(Tag tag) {
public int color() {
return 0xff_ffaa00;
}

@Override
public boolean omitCommas() {
return true;
}
};

public static PatternIota deserialize(Tag tag) throws IllegalArgumentException {
Expand Down