diff --git a/README.md b/README.md
index 292f2b1..cca6059 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# Tianjin Metro
-
+
A small mod for [Minecraft Transit Railway](https://github.com/jonafanho/Minecraft-Transit-Railway), in developing stage.
diff --git a/common/src/main/java/ziyue/tjmetro/IDrawingExtends.java b/common/src/main/java/ziyue/tjmetro/IDrawingExtends.java
index 91e5332..7a4c8f0 100644
--- a/common/src/main/java/ziyue/tjmetro/IDrawingExtends.java
+++ b/common/src/main/java/ziyue/tjmetro/IDrawingExtends.java
@@ -37,6 +37,29 @@ public interface IDrawingExtends
*/
Function LINK_STYLE = link -> Style.EMPTY.withUnderlined(true).withColor(ChatFormatting.BLUE).withClickEvent(new ClickEvent(ClickEvent.Action.OPEN_URL, link)).withHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, Text.literal(link)));
+ /**
+ * Remains the language string that the language option specified.
+ *
+ * @return filtered string
+ * @author ZiYueCommentary
+ * @see mtr.client.Config#languageOptions()
+ * @since beta-1
+ */
+ static String filterLanguage(String text) {
+ final StringBuilder noCommentString = new StringBuilder(text);
+ final int commentIndex = noCommentString.indexOf("||");
+ final int separatorIndex = noCommentString.indexOf("|");
+ if (commentIndex != -1)
+ noCommentString.delete(commentIndex, noCommentString.length());
+ if (separatorIndex != -1) {
+ switch (mtr.client.Config.languageOptions()) {
+ case 1 -> noCommentString.delete(separatorIndex, noCommentString.length());
+ case 2 -> noCommentString.delete(0, separatorIndex);
+ }
+ }
+ return noCommentString.toString();
+ }
+
/**
* Drawing string with Tianjin Metro Font.
*
@@ -56,9 +79,7 @@ static void drawStringWithFont(PoseStack matrices, Font textRenderer, MultiBuffe
style = Style.EMPTY;
}
- while (text.contains("||")) {
- text = text.replace("||", "|");
- }
+ text = IDrawingExtends.filterLanguage(text);
final String[] stringSplit = text.split("\\|");
final List isCJKList = new ArrayList<>();
diff --git a/common/src/main/java/ziyue/tjmetro/render/RenderRoadblockSign.java b/common/src/main/java/ziyue/tjmetro/render/RenderRoadblockSign.java
index fbc8368..c429acc 100644
--- a/common/src/main/java/ziyue/tjmetro/render/RenderRoadblockSign.java
+++ b/common/src/main/java/ziyue/tjmetro/render/RenderRoadblockSign.java
@@ -53,12 +53,12 @@ public void render(T entity, float tickDelta, PoseStack matrices, MultiBufferSou
matrices.mulPose(Vector3f.ZP.rotationDegrees(180));
final MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
matrices.translate(0, 0.023, 0.5 - entity.zOffset - SMALL_OFFSET);
- drawStationName(entity, matrices, vertexConsumers, immediate, entity.content, light);
+ drawString(entity, matrices, vertexConsumers, immediate, IDrawingExtends.filterLanguage(entity.content), light);
immediate.endBatch();
matrices.popPose();
}
- protected void drawStationName(T entity, PoseStack matrices, MultiBufferSource vertexConsumers, MultiBufferSource.BufferSource immediate, String content, int light) {
+ protected void drawString(T entity, PoseStack matrices, MultiBufferSource vertexConsumers, MultiBufferSource.BufferSource immediate, String content, int light) {
IDrawingExtends.drawStringWithFont(matrices, Minecraft.getInstance().font, immediate, content, HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 0.5f, -0.13f, 0.85F * 2 + 0.05f, 1f, 80, ARGB_WHITE, false, light, null);
}
}
\ No newline at end of file
diff --git a/common/src/main/java/ziyue/tjmetro/render/RenderServiceCorridorSign.java b/common/src/main/java/ziyue/tjmetro/render/RenderServiceCorridorSign.java
index 1982028..9532323 100644
--- a/common/src/main/java/ziyue/tjmetro/render/RenderServiceCorridorSign.java
+++ b/common/src/main/java/ziyue/tjmetro/render/RenderServiceCorridorSign.java
@@ -52,8 +52,8 @@ public void render(T entity, float tickDelta, PoseStack matrices, MultiBufferSou
matrices.mulPose(Vector3f.ZP.rotationDegrees(180));
matrices.translate(0, 0, 0.5 - entity.zOffset - SMALL_OFFSET);
final MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
- IDrawingExtends.drawStringWithFont(matrices, Minecraft.getInstance().font, immediate, Text.translatable("sign.tjmetro.service_corridor_sign").getString(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 0, -0.12f, 0.85F, 1F, 150, ARGB_BLACK, false, light, null);
- IDrawingExtends.drawStringWithFont(matrices, Minecraft.getInstance().font, immediate, Text.translatable("sign.tjmetro.contact_station_for_help").getString(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 0, 0.02f, 0.85F, 1F, 270, ARGB_BLACK, false, light, null);
+ IDrawingExtends.drawStringWithFont(matrices, Minecraft.getInstance().font, immediate, Text.translatable("gui.tjmetro.service_corridor_sign").getString(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 0, -0.12f, 0.85F, 1F, 150, ARGB_BLACK, false, light, null);
+ IDrawingExtends.drawStringWithFont(matrices, Minecraft.getInstance().font, immediate, Text.translatable("gui.tjmetro.contact_station_for_help").getString(), HorizontalAlignment.CENTER, VerticalAlignment.CENTER, 0, 0.02f, 0.85F, 1F, 270, ARGB_BLACK, false, light, null);
immediate.endBatch();
matrices.popPose();
}
diff --git a/common/src/main/java/ziyue/tjmetro/render/RenderStationNameSign.java b/common/src/main/java/ziyue/tjmetro/render/RenderStationNameSign.java
index 15ed38a..2bd68a2 100644
--- a/common/src/main/java/ziyue/tjmetro/render/RenderStationNameSign.java
+++ b/common/src/main/java/ziyue/tjmetro/render/RenderStationNameSign.java
@@ -64,7 +64,7 @@ public void render(T entity, float tickDelta, PoseStack matrices, MultiBufferSou
matrices.translate(0, 0, 0.5 - entity.zOffset - SMALL_OFFSET);
final MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
final Station station = RailwayData.getStation(ClientData.STATIONS, ClientData.DATA_CACHE, entity.getBlockPos());
- drawStationName(matrices, immediate, entity.content.equals("") ? station == null ? Text.translatable("gui.mtr.untitled").getString() : station.name : entity.content, color, light);
+ drawStationName(matrices, immediate, entity.content.isEmpty() ? station == null ? Text.translatable("gui.mtr.untitled").getString() : IDrawingExtends.filterLanguage(station.name) : IDrawingExtends.filterLanguage(entity.content), color, light);
immediate.endBatch();
matrices.popPose();
}
diff --git a/common/src/main/java/ziyue/tjmetro/render/RenderStationNameWallLegacy.java b/common/src/main/java/ziyue/tjmetro/render/RenderStationNameWallLegacy.java
index 68d10c6..d914c87 100644
--- a/common/src/main/java/ziyue/tjmetro/render/RenderStationNameWallLegacy.java
+++ b/common/src/main/java/ziyue/tjmetro/render/RenderStationNameWallLegacy.java
@@ -21,6 +21,7 @@
import net.minecraft.core.Direction;
import net.minecraft.world.level.BlockGetter;
import net.minecraft.world.level.block.state.BlockState;
+import ziyue.tjmetro.IDrawingExtends;
import ziyue.tjmetro.blocks.BlockStationNameWallLegacy;
/**
@@ -52,7 +53,7 @@ public void render(T entity, float f, PoseStack matrices, MultiBufferSource vert
final MultiBufferSource.BufferSource immediate = MultiBufferSource.immediate(Tesselator.getInstance().getBuilder());
final Station station = RailwayData.getStation(ClientData.STATIONS, ClientData.DATA_CACHE, pos);
matrices.translate(0, 0.023, 0.5 - entity.zOffset - SMALL_OFFSET);
- drawStationName(matrices, vertexConsumers, immediate, station == null ? Text.translatable("gui.mtr.untitled").getString() : station.name, entity.getColor(state), light);
+ drawStationName(matrices, vertexConsumers, immediate, station == null ? Text.translatable("gui.mtr.untitled").getString() : IDrawingExtends.filterLanguage(station.name), entity.getColor(state), light);
immediate.endBatch();
matrices.popPose();
}
diff --git a/common/src/main/resources/assets/tjmetro/lang/en_us.json b/common/src/main/resources/assets/tjmetro/lang/en_us.json
index 27b21ac..19c2af0 100644
--- a/common/src/main/resources/assets/tjmetro/lang/en_us.json
+++ b/common/src/main/resources/assets/tjmetro/lang/en_us.json
@@ -35,9 +35,8 @@
"block.tjmetro.railway_sign_tianjin": "Railway Sign (Tianjin)",
"block.tjmetro.service_corridor_sign": "\"Serivce Corridor\" Sign",
- "sign.tjmetro.service_corridor_sign": "Service Corridor",
- "sign.tjmetro.contact_station_for_help": "Please contact the station for help.",
-
+ "gui.tjmetro.service_corridor_sign": "Service Corridor",
+ "gui.tjmetro.contact_station_for_help": "Please contact the station for help.",
"gui.tjmetro.metal_detection_door": "Metal Detection Door",
"gui.tjmetro.options": "Tianjin Metro Options",
"gui.tjmetro.default_color": "Default Color",