Skip to content

Commit

Permalink
Merge branch '3.3.0' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jonafanho authored Mar 16, 2023
2 parents e75efb6 + a56aefd commit 87c987f
Show file tree
Hide file tree
Showing 33 changed files with 1,002 additions and 90 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ jobs:
strategy:
fail-fast: false
matrix:
minecraft: [ 1.16.5, 1.17.1, 1.18.2, 1.19.2, 1.19.3 ]
minecraft: [ 1.16.5, 1.17.1, 1.18.2, 1.19.2, 1.19.3, 1.19.4 ]
variation: [ normal, server, lifts ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@main
- name: Validate gradle wrapper
uses: gradle/wrapper-validation-action@v1
uses: gradle/wrapper-validation-action@main
- name: Setup JDK 17
uses: actions/setup-java@main
with:
Expand Down Expand Up @@ -67,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
minecraft: [ 1.16.5, 1.17.1, 1.18.2, 1.19.2, 1.19.3 ]
minecraft: [ 1.16.5, 1.17.1, 1.18.2, 1.19.2, 1.19.3, 1.19.4 ]
runs-on: ubuntu-latest
steps:
- name: Checkout repository
Expand Down
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ def minecraft_version = rootProject.properties.containsKey("buildVersion") ? roo
def minecraft_main_version = minecraft_version.split("\\.")[1] as int
def minecraft_mod_api_tools_version = "b33012bd4098a807dca91dc469f2b0018df6ff96" // TODO getJson("https://api.github.com/repos/jonafanho/Minecraft-Mod-API-Tools/git/refs/heads/master")["object"]["sha"]
def patreon_api_key = rootProject.properties.containsKey("patreonApiKey") ? rootProject.getProperties().get("patreonApiKey").toString() : ""
def is_1_19_3 = minecraft_version == "1.19.3"
def parchment_version = getXml("https://ldtteam.jfrog.io/artifactory/parchmentmc-internal/org/parchmentmc/data/parchment-${minecraft_version}/maven-metadata.xml").versioning.release
def is_1_19_3 = minecraft_version == "1.19.3" || minecraft_version == "1.19.4"
def parchment_version = getXml("https://ldtteam.jfrog.io/artifactory/parchmentmc-internal/org/parchmentmc/data/parchment-${is_1_19_3 ? "1.19.3" : minecraft_version}/maven-metadata.xml").versioning.release
def testServer = rootProject.properties.containsKey("testServer") ? rootProject.getProperties().get("testServer").toString() : ""

rootProject.ext.fabric_loader_version = [minecraft_version, getJson("https://meta.fabricmc.net/v2/versions/loader/" + minecraft_version)[0]["loader"]["version"]]
Expand Down Expand Up @@ -52,7 +52,7 @@ subprojects {
minecraft "com.mojang:minecraft:${minecraft_version}"
mappings loom.layered() {
officialMojangMappings()
parchment("org.parchmentmc.data:parchment-${minecraft_version}:${parchment_version}@zip")
parchment("org.parchmentmc.data:parchment-${is_1_19_3 ? "1.19.3" : minecraft_version}:${parchment_version}@zip")
}
implementation name: "Dynmap-3.2.1"
implementation name: "BlueMapAPI-2.1.1"
Expand Down Expand Up @@ -89,7 +89,7 @@ task setupFiles() {
System.out.println("Parchment: " + parchment_version)

download {
src "https://github.com/jonafanho/Minecraft-Mappings/archive/refs/heads/1.${minecraft_main_version}${is_1_19_3 ? ".3" : ""}.zip"
src "https://github.com/jonafanho/Minecraft-Mappings/archive/refs/heads/${is_1_19_3 ? minecraft_version : "1." + minecraft_main_version}.zip"
dest "common/src/main/java/mtr/mappings/mappings.zip"
overwrite true
retries - 1
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/ModUpload.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

public class ModUpload {

private static final String[] MINECRAFT_VERSIONS = {"1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.3"};
private static final String[] MINECRAFT_VERSIONS = {"1.16.5", "1.17.1", "1.18.2", "1.19.2", "1.19.3", "1.19.4"};

public static void main(String[] args) throws IOException {
if (args.length == 2) {
Expand Down
11 changes: 11 additions & 0 deletions common/src/main/java/mtr/MTRClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import mtr.sound.LoopingSoundInstance;
import net.minecraft.client.Minecraft;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.core.BlockPos;
import net.minecraft.world.item.Item;

import java.util.ArrayList;
Expand Down Expand Up @@ -347,6 +348,16 @@ public static void init() {
}
}

public static int getStationColor(BlockPos pos) {
final int defaultColor = 0x7F7F7F;
if (pos == null) {
return defaultColor;
} else {
final Station station = RailwayData.getStation(ClientData.STATIONS, ClientData.DATA_CACHE, pos);
return station == null ? defaultColor : station.color;
}
}

public static void initItemModelPredicate() {
if (!Keys.LIFTS_ONLY) {
RegistryClient.registerItemModelPredicate(MTR.MOD_ID + ":selected", Items.RAIL_CONNECTOR_20.get(), ItemBlockClickingBase.TAG_POS);
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/mtr/client/IDrawing.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ static void drawStringWithFont(PoseStack matrices, Font textRenderer, MultiBuffe
final int b = (int) (((isCJK ? textColorCjk : textColor) & 0xFF) * shade);

if (immediate != null) {
textRenderer.drawInBatch(orderedTexts.get(i), xOffset / extraScale, offset / extraScale, (a << 24) + (r << 16) + (g << 8) + b, shadow, matrices.last().pose(), immediate, false, 0, light);
UtilitiesClient.drawInBatch(textRenderer, orderedTexts.get(i), xOffset / extraScale, offset / extraScale, (a << 24) + (r << 16) + (g << 8) + b, shadow, matrices.last().pose(), immediate, 0, light);
}

if (isCJK) {
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/java/mtr/client/TrainClientRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public static void reset() {
register(TrainType.CLASS_802_TPE, "British_Rail_Class_802", new ModelClass802(), "mtr:textures/entity/class_802_tpe", 0x00A6E6, "mtr:textures/entity/sp1900", "", 7.75F, false, "class_802", new JonTrainSound.JonTrainSoundConfig("class_802", 120, 1, false));
register(TrainType.CLASS_802_TPE_MINI, "British_Rail_Class_802", new ModelClass802Mini(), "mtr:textures/entity/class_802_tpe", 0x00A6E6, "mtr:textures/entity/sp1900", "", 4.94F, false, "class_802", new JonTrainSound.JonTrainSoundConfig("class_802", 120, 1, false));
register(TrainType.MPL_85, "MPL_85", new ModelMPL85(), "mtr:textures/entity/mpl_85", 0xEF7011, "", "", 6.75F, false, "mpl_85", new JonTrainSound.JonTrainSoundConfig("mpl_85", 48, 1, false));
register(TrainType.BR_423, "DBAG_Class_423", new ModelBR423(), "mtr:textures/entity/br_423", 0xE3010F, "mtr:textures/entity/sp1900", "", 5.5F, false, "mpl_85", new JonTrainSound.JonTrainSoundConfig("mpl_85", 48, 1, false));
register(TrainType.MINECART, "Minecart", null, "textures/entity/minecart", 0x666666, -0.5F, 0);
register(TrainType.OAK_BOAT, "Boat", null, "textures/entity/boat/oak", 0x8F7748, -1.5F, 0);
register(TrainType.SPRUCE_BOAT, "Boat", null, "textures/entity/boat/spruce", 0x8F7748, -1.5F, 0);
Expand All @@ -154,6 +155,8 @@ public static void reset() {
register(TrainType.DARK_OAK_BOAT, "Boat", null, "textures/entity/boat/dark_oak", 0x8F7748, -1.5F, 0);
register(TrainType.NGONG_PING_360_CRYSTAL, "Ngong_Ping_360", new ModelNgongPing360(false), "mtr:textures/entity/ngong_ping_360_crystal", 0x062540, 0, 0);
register(TrainType.NGONG_PING_360_CRYSTAL_RHT, "Ngong_Ping_360", new ModelNgongPing360(true), "mtr:textures/entity/ngong_ping_360_crystal", 0x062540, 0, 0);
register(TrainType.NGONG_PING_360_CRYSTAL_PLUS, "Ngong_Ping_360", new ModelNgongPing360(false), "mtr:textures/entity/ngong_ping_360_crystal_plus", 0x062540, 0, 0);
register(TrainType.NGONG_PING_360_CRYSTAL_PLUS_RHT, "Ngong_Ping_360", new ModelNgongPing360(true), "mtr:textures/entity/ngong_ping_360_crystal_plus", 0x062540, 0, 0);
register(TrainType.NGONG_PING_360_NORMAL_RED, "Ngong_Ping_360", new ModelNgongPing360(false), "mtr:textures/entity/ngong_ping_360_normal_red", 0x062540, 0, 0);
register(TrainType.NGONG_PING_360_NORMAL_RED_RHT, "Ngong_Ping_360", new ModelNgongPing360(true), "mtr:textures/entity/ngong_ping_360_normal_red", 0x062540, 0, 0);
register(TrainType.NGONG_PING_360_NORMAL_ORANGE, "Ngong_Ping_360", new ModelNgongPing360(false), "mtr:textures/entity/ngong_ping_360_normal_orange", 0x062540, 0, 0);
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/mtr/data/AreaBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public boolean intersecting(AreaBase areaBase) {
}

public BlockPos getCenter() {
return nonNullCorners(this) ? new BlockPos((corner1.getA() + corner2.getA()) / 2, 0, (corner1.getB() + corner2.getB()) / 2) : null;
return nonNullCorners(this) ? RailwayData.newBlockPos((corner1.getA() + corner2.getA()) / 2, 0, (corner1.getB() + corner2.getB()) / 2) : null;
}

private void setCorners(int corner1a, int corner1b, int corner2a, int corner2b) {
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/mtr/data/Lift.java
Original file line number Diff line number Diff line change
Expand Up @@ -339,15 +339,15 @@ protected float getYaw() {
}

private BlockPos getBlockPos() {
return new BlockPos(currentPositionX, currentPositionY, currentPositionZ);
return RailwayData.newBlockPos(currentPositionX, currentPositionY, currentPositionZ);
}

private boolean checkDoor(Level world, boolean front) {
final Direction directionClockwise = facing.getClockWise();
final int sign = front ? 1 : -1;
boolean hasDoor = false;
for (int i = -1; i <= 1; i++) {
final BlockPos checkPos = new BlockPos(currentPositionX + liftOffsetX / 2F - facing.getStepX() * sign * (liftDepth / 2F + 0.5) + directionClockwise.getStepX() * i, currentPositionY + liftOffsetY, currentPositionZ + liftOffsetZ / 2F - facing.getStepZ() * sign * (liftDepth / 2F + 0.5) + directionClockwise.getStepZ() * i);
final BlockPos checkPos = RailwayData.newBlockPos(currentPositionX + liftOffsetX / 2F - facing.getStepX() * sign * (liftDepth / 2F + 0.5) + directionClockwise.getStepX() * i, currentPositionY + liftOffsetY, currentPositionZ + liftOffsetZ / 2F - facing.getStepZ() * sign * (liftDepth / 2F + 0.5) + directionClockwise.getStepZ() * i);
if (world.getNearestPlayer(currentPositionX, currentPositionY, currentPositionZ, Train.MAX_CHECK_DISTANCE, entity -> true) != null && RailwayData.chunkLoaded(world, checkPos) && RailwayData.chunkLoaded(world, checkPos.above())) {
final BlockEntity entity1 = world.getBlockEntity(checkPos);
final BlockEntity entity2 = world.getBlockEntity(checkPos.above());
Expand Down
8 changes: 4 additions & 4 deletions common/src/main/java/mtr/data/Rail.java
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ public void writePacket(FriendlyByteBuf packet) {

private boolean createTunnel() {
return create(true, editPos -> {
final BlockPos pos = new BlockPos(editPos);
final BlockPos pos = RailwayData.newBlockPos(editPos);
if (!blacklistedPos.contains(pos) && canPlace(world, pos)) {
world.setBlockAndUpdate(pos, Blocks.AIR.defaultBlockState());
blacklistedPos.add(pos);
Expand All @@ -536,7 +536,7 @@ private boolean createTunnel() {

private boolean createTunnelWall() {
return create(false, editPos -> {
final BlockPos pos = new BlockPos(editPos);
final BlockPos pos = RailwayData.newBlockPos(editPos);
if (!blacklistedPos.contains(pos) && canPlace(world, pos)) {
world.setBlockAndUpdate(pos, state);
blacklistedPos.add(pos);
Expand All @@ -546,7 +546,7 @@ private boolean createTunnelWall() {

private boolean createBridge() {
return create(false, editPos -> {
final BlockPos pos = new BlockPos(editPos);
final BlockPos pos = RailwayData.newBlockPos(editPos);
final boolean isTopHalf = editPos.y - Math.floor(editPos.y) >= 0.5;
blacklistedPos.add(getHalfPos(pos, isTopHalf));

Expand Down Expand Up @@ -617,7 +617,7 @@ private static boolean canPlace(Level world, BlockPos pos) {
}

private static BlockPos getHalfPos(BlockPos pos, boolean isTopHalf) {
return new BlockPos(pos.getX(), pos.getY() * 2 + (isTopHalf ? 1 : 0), pos.getZ());
return RailwayData.newBlockPos(pos.getX(), pos.getY() * 2 + (isTopHalf ? 1 : 0), pos.getZ());
}
}

Expand Down
16 changes: 16 additions & 0 deletions common/src/main/java/mtr/data/RailwayData.java
Original file line number Diff line number Diff line change
Expand Up @@ -735,6 +735,22 @@ public static String prettyPrint(JsonElement jsonElement) {
return new GsonBuilder().setPrettyPrinting().create().toJson(jsonElement);
}

public static BlockPos newBlockPos(Vec3 vec3) {
return newBlockPos(vec3.x, vec3.y, vec3.z);
}

public static BlockPos newBlockPos(double x, double y, double z) {
return RailwayData.newBlockPos((int) x, (int) y, (int) z);
}

public static BlockPos newBlockPos(int x, int y, int z) {
return new BlockPos(x, y, z);
}

public static BlockPos offsetBlockPos(BlockPos pos, double x, double y, double z) {
return pos.offset((int) x, (int) y, (int) z);
}

public static RailwayData getInstance(Level world) {
return getInstance(world, () -> new RailwayData(world), NAME);
}
Expand Down
4 changes: 2 additions & 2 deletions common/src/main/java/mtr/data/SavedRailBase.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public BlockPos getMidPos() {

public BlockPos getMidPos(boolean zeroY) {
final BlockPos pos = getPosition(0).offset(getPosition(1));
return new BlockPos(pos.getX() / 2, zeroY ? 0 : pos.getY() / 2, pos.getZ() / 2);
return RailwayData.newBlockPos(pos.getX() / 2, zeroY ? 0 : pos.getY() / 2, pos.getZ() / 2);
}

public Direction.Axis getAxis() {
Expand Down Expand Up @@ -172,7 +172,7 @@ protected void writeDwellTimePacket(FriendlyByteBuf packet, int newDwellTime) {
}

private BlockPos getPosition(int index) {
return positions.size() > index ? new ArrayList<>(positions).get(index) : new BlockPos(0, 0, 0);
return positions.size() > index ? new ArrayList<>(positions).get(index) : RailwayData.newBlockPos(0, 0, 0);
}

public static boolean isInvalidSavedRail(Map<BlockPos, Map<BlockPos, Rail>> rails, BlockPos pos1, BlockPos pos2) {
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/mtr/data/Siding.java
Original file line number Diff line number Diff line change
Expand Up @@ -448,7 +448,7 @@ private void setTrainDetails(String trainId, String baseTrainType, boolean force
private void generateDefaultPath(Map<BlockPos, Map<BlockPos, Rail>> rails) {
trains.clear();

final List<BlockPos> orderedPositions = getOrderedPositions(new BlockPos(0, 0, 0), false);
final List<BlockPos> orderedPositions = getOrderedPositions(RailwayData.newBlockPos(0, 0, 0), false);
final BlockPos pos1 = orderedPositions.get(0);
final BlockPos pos2 = orderedPositions.get(1);
if (RailwayData.containsRail(rails, pos1, pos2)) {
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/mtr/data/Train.java
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ private boolean scanDoors(Level world, double trainX, double trainY, double trai
for (int checkX = 1; checkX <= 3; checkX++) {
for (int checkY = -2; checkY <= 3; checkY++) {
for (double checkZ = -halfSpacing; checkZ <= halfSpacing; checkZ++) {
final BlockPos checkPos = new BlockPos(trainX + offsetVec.x * checkX + traverseVec.x * checkZ, trainY + checkY, trainZ + offsetVec.z * checkX + traverseVec.z * checkZ);
final BlockPos checkPos = RailwayData.newBlockPos(trainX + offsetVec.x * checkX + traverseVec.x * checkZ, trainY + checkY, trainZ + offsetVec.z * checkX + traverseVec.z * checkZ);
final Block block = world.getBlockState(checkPos).getBlock();

if (block instanceof BlockPlatform || block instanceof BlockPSDAPGBase) {
Expand Down
12 changes: 9 additions & 3 deletions common/src/main/java/mtr/data/TrainClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ protected void simulateCar(
return;
}

final BlockPos soundPos = new BlockPos(carX, carY, carZ);
final BlockPos soundPos = RailwayData.newBlockPos(carX, carY, carZ);
trainSound.playAllCars(world, soundPos, ridingCar);
if (doorLeftOpen || doorRightOpen) {
trainSound.playAllCarsDoorOpening(world, soundPos, ridingCar);
Expand Down Expand Up @@ -193,7 +193,7 @@ protected boolean handlePositions(Level world, Vec3[] positions, float ticksElap
nearestDistance = checkDistance;
}
}
final BlockPos soundPos = new BlockPos(positions[nearestCar].x, positions[nearestCar].y, positions[nearestCar].z);
final BlockPos soundPos = RailwayData.newBlockPos(positions[nearestCar].x, positions[nearestCar].y, positions[nearestCar].z);
trainSound.playNearestCar(world, soundPos, nearestCar);

return true;
Expand Down Expand Up @@ -221,7 +221,13 @@ protected boolean openDoors(Level world, Block block, BlockPos checkPos, int dwe

@Override
protected float getModelZOffset() {
return baseTrainType.startsWith("london_underground_199") || trainId.startsWith("london_underground_199") || baseTrainType.equals("mpl_85") || trainId.equals("mpl_85") ? reversed ? -0.5F : 0.5F : 0; // TODO integrate this into TrainClientRegistry
return baseTrainType.startsWith("london_underground_199")
|| trainId.startsWith("london_underground_199")
|| baseTrainType.equals("mpl_85")
|| trainId.equals("mpl_85")
|| baseTrainType.equals("br_423")
|| trainId.equals("br_423") ?
reversed ? -0.5F : 0.5F : 0; // TODO integrate this into TrainClientRegistry
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/mtr/data/TrainServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected boolean handlePositions(Level world, Vec3[] positions, float ticksElap
}
});

final BlockPos frontPos = new BlockPos(positions[reversed ? positions.length - 1 : 0]);
final BlockPos frontPos = RailwayData.newBlockPos(positions[reversed ? positions.length - 1 : 0]);
if (RailwayData.chunkLoaded(world, frontPos)) {
checkBlock(frontPos, checkPos -> {
if (RailwayData.chunkLoaded(world, checkPos)) {
Expand Down
3 changes: 3 additions & 0 deletions common/src/main/java/mtr/data/TrainType.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public enum TrainType {
CLASS_802_TPE("train_24_2"),
CLASS_802_TPE_MINI("train_18_2"),
MPL_85("train_21_2"),
BR_423("train_15_2"),
MINECART("train_1_1"),
OAK_BOAT("boat_1_1"),
SPRUCE_BOAT("boat_1_1"),
Expand All @@ -107,6 +108,8 @@ public enum TrainType {
DARK_OAK_BOAT("boat_1_1"),
NGONG_PING_360_CRYSTAL("cable_car_1_1"),
NGONG_PING_360_CRYSTAL_RHT("cable_car_1_1"),
NGONG_PING_360_CRYSTAL_PLUS("cable_car_1_1"),
NGONG_PING_360_CRYSTAL_PLUS_RHT("cable_car_1_1"),
NGONG_PING_360_NORMAL_RED("cable_car_1_1"),
NGONG_PING_360_NORMAL_RED_RHT("cable_car_1_1"),
NGONG_PING_360_NORMAL_ORANGE("cable_car_1_1"),
Expand Down
Loading

0 comments on commit 87c987f

Please sign in to comment.