Skip to content

Commit

Permalink
🌟 Brand new signs and sign system
Browse files Browse the repository at this point in the history
  • Loading branch information
ZiYueCommentary committed May 26, 2024
1 parent bb1b8ae commit 06dc947
Show file tree
Hide file tree
Showing 24 changed files with 232 additions and 193 deletions.
75 changes: 75 additions & 0 deletions common/src/main/java/ziyue/tjmetro/block/base/IRailwaySign.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package ziyue.tjmetro.block.base;

import mtr.block.IBlock;
import mtr.client.CustomResources;
import mtr.mappings.Text;
import net.minecraft.core.BlockPos;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.BlockGetter;
Expand All @@ -14,7 +17,9 @@
import net.minecraft.world.phys.shapes.CollisionContext;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
import ziyue.tjmetro.Reference;

import static mtr.client.CustomResources.CUSTOM_SIGNS;
import static net.minecraft.world.level.block.HorizontalDirectionalBlock.FACING;

/**
Expand Down Expand Up @@ -84,4 +89,74 @@ static BlockPos findEndWithDirection(Level world, BlockPos startPos, Direction d
i++;
}
}

enum SignType
{
// Tianjin Rail Transit (TRT, Tianjin Metro)
TIANJIN_METRO_LOGO_TEXT("tianjin_metro_logo", "tianjin_metro", false, false),
TIANJIN_METRO_LOGO_TEXT_FLIPPED("tianjin_metro_logo", "tianjin_metro", false, true),
TIANJIN_METRO_MOD_LOGO_TEXT("tianjin_metro_mod_logo", "tianjin_metro", false, false),
TIANJIN_METRO_MOD_LOGO_TEXT_FLIPPED("tianjin_metro_mod_logo", "tianjin_metro", false, true),
TIANJIN_METRO_OLD_LOGO_TEXT("tianjin_metro_old_logo", "tianjin_metro", false, false),
TIANJIN_METRO_OLD_LOGO_TEXT_FLIPPED("tianjin_metro_old_logo", "tianjin_metro", false, true),
TRAIN_TEXT("train", "train", false, false),
TRAIN_TEXT_FLIPPED("train", "train", false, true),
EMERGENCY_EXIT_TEXT("emergency_exit", "emergency_exit", false, false),
EMERGENCY_EXIT_TEXT_FLIPPED("emergency_exit", "emergency_exit", true, true),
NO_THROUGHFARE_TEXT("no_throughfare", "no_throughfare", false, false),
NO_THROUGHFARE_TEXT_FLIPPED("no_throughfare", "no_throughfare", false, true),
SECURITY_CHECK_TEXT("security_check", "security_check", false, false),
SECURITY_CHECK_TEXT_FLIPPED("security_check", "security_check", false, true),
AUTOMATIC_TICKET_TEXT("automatic_ticket", "automatic_ticket", false, false),
AUTOMATIC_TICKET_TEXT_FLIPPED("automatic_ticket", "automatic_ticket", false, true),
RAILWAY_STATION_TEXT("railway_station", "railway_station", false, false),
RAILWAY_STATION_TEXT_FLIPPED("railway_station", "railway_station", false, true),
ACCESSIBLE_ELEVATOR_TEXT("accessible_elevator", "accessible_elevator", false, false),
ACCESSIBLE_ELEVATOR_TEXT_FLIPPED("accessible_elevator", "accessible_elevator", false, true),
ACCESSIBLE_TOILET_TEXT("accessible_toilet", "accessible_toilet", false, false),
ACCESSIBLE_TOILET_TEXT_FLIPPED("accessible_toilet", "accessible_toilet", false, true),

TIANJIN_METRO_LOGO("tianjin_metro_logo", false),
TIANJIN_METRO_MOD_LOGO("tianjin_metro_mod_logo", false),
TIANJIN_METRO_OLD_LOGO("tianjin_metro_old_logo", false),
TRAIN("train", false),
EMERGENCY_EXIT("emergency_exit", false),
EMERGENCY_EXIT_FLIPPED("emergency_exit", true),
NO_THROUGHFARE("no_throughfare", false),
SECURITY_CHECK("security_check", false),
AUTOMATIC_TICKET("automatic_ticket", false),
RAILWAY_STATION("railway_station", false),
ACCESSIBLE_ELEVATOR("accessible_elevator", false),
ACCESSIBLE_TOILET("accessible_toilet", false),

// Tianjin Binhai Mass Transit (BMT, Tianjin Metro Line 9)
NO_ENTRY_BMT_TEXT("no_entry_bmt", "no_entry_bmt", false, false),
NO_ENTRY_BMT_TEXT_FLIPPED("no_entry_bmt", "no_entry_bmt", false, true),
TO_SUBWAY_BMT_TEXT("to_subway_bmt", "to_subway_bmt", false, false),
TO_SUBWAY_BMT_TEXT_FLIPPED("to_subway_bmt", "to_subway_bmt", true, true),

NO_ENTRY_BMT("no_entry_bmt", false),
TO_SUBWAY_BMT("to_subway_bmt", false),
TO_SUBWAY_BMT_FLIPPED("to_subway_bmt", true);
//BINHAI_MASS_TRANSIT("binhai_mass_transit", false),
//BINHAI_MASS_TRANSIT_FLIPPED("binhai_mass_transit", true);

public final String signId;
public final CustomResources.CustomSign sign;

SignType(String texture, String translation, boolean flipTexture, boolean flipCustomText, boolean hasCustomText, int backgroundColor) {
this.signId = (texture.endsWith("bmt") ? "\1tjmetro_%s_%s_%s_%s_%s_%s" : "\0tjmetro_%s_%s_%s_%s_%s_%s") // Make sure that signs will always order in front of custom signs, and BMT signs are after TRT ;)
.formatted(texture, translation, flipTexture, flipCustomText, hasCustomText, backgroundColor);
this.sign = new CustomResources.CustomSign(new ResourceLocation(Reference.MOD_ID, "textures/sign/" + texture + ".png"), flipTexture, hasCustomText ? Text.translatable("sign.tjmetro." + translation + "_cjk").append("|").append(Text.translatable("sign.tjmetro." + translation)).getString() : "", flipCustomText, true, backgroundColor);
CUSTOM_SIGNS.put(signId, sign);
}

SignType(String texture, String translation, boolean flipTexture, boolean flipCustomText) {
this(texture, translation, flipTexture, flipCustomText, true, 0);
}

SignType(String texture, boolean flipTexture) {
this(texture, texture, flipTexture, false, false, 0);
}
}
}
10 changes: 10 additions & 0 deletions common/src/main/java/ziyue/tjmetro/mixin/CustomResourcesMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,11 @@
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import ziyue.tjmetro.block.base.IRailwaySign;
import ziyue.tjmetro.client.ClientCache;

import static mtr.client.CustomResources.CUSTOM_SIGNS;

/**
* @author ZiYueCommentary
* @since beta-1
Expand All @@ -23,4 +26,11 @@ public abstract class CustomResourcesMixin implements IResourcePackCreatorProper
private static void beforeReload(ResourceManager manager, CallbackInfo ci){
ClientCache.DATA_CACHE.resetFonts();
}

@Inject(at = @At("TAIL"), method = "reload")
private static void afterReload(ResourceManager manager, CallbackInfo ci){
for (IRailwaySign.SignType value : IRailwaySign.SignType.values()) {
CUSTOM_SIGNS.put(value.signId, value.sign);
}
}
}
193 changes: 0 additions & 193 deletions common/src/main/resources/assets/mtr/mtr_custom_resources.json

This file was deleted.

23 changes: 23 additions & 0 deletions common/src/main/resources/assets/tjmetro/lang/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,29 @@
"gui.tjmetro.next_station": "Next Station",
"gui.tjmetro.station_pinyin": "%s ZHAN",

"sign.tjmetro.tianjin_metro_cjk": "天津地铁",
"sign.tjmetro.tianjin_metro": "Tianjin Metro",
"sign.tjmetro.train_cjk": "列车",
"sign.tjmetro.train": "Train",
"sign.tjmetro.emergency_exit_cjk": "紧急出口",
"sign.tjmetro.emergency_exit": "Emergency Exit",
"sign.tjmetro.no_throughfare_cjk": "禁止通行",
"sign.tjmetro.no_throughfare": "No Throughfare",
"sign.tjmetro.accessible_elevator_cjk": "无障碍电梯",
"sign.tjmetro.accessible_elevator": "Accessible Elevator",
"sign.tjmetro.security_check_cjk": "安全检查",
"sign.tjmetro.security_check": "Security Check",
"sign.tjmetro.automatic_ticket_cjk": "自动售票",
"sign.tjmetro.automatic_ticket": "Automatic Ticket",
"sign.tjmetro.railway_station_cjk": "火车站",
"sign.tjmetro.railway_station": "Railway Station",
"sign.tjmetro.accessible_toilet_cjk": "无障碍卫生间",
"sign.tjmetro.accessible_toilet": "Accessible Toilet",
"sign.tjmetro.no_entry_bmt_cjk": "乘客止步",
"sign.tjmetro.no_entry_bmt": "No Entry",
"sign.tjmetro.to_subway_bmt_cjk": "乘车",
"sign.tjmetro.to_subway_bmt": "To Subway",

"button.tjmetro.tianjin_metro_options": "Tianjin Metro Options",

"config.category.tjmetro": "Tianjin Metro",
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
35 changes: 35 additions & 0 deletions icons/accessible_toilet.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 06dc947

Please sign in to comment.