Simplify train and rail logic and consolidate integration tests

This commit is contained in:
2026-09-13 21:55:44 +03:00
parent c39e91d836
commit 2c651a12fc
46 changed files with 2660 additions and 1233 deletions
@@ -1,15 +1,32 @@
package online.astradev.content.rail;
import net.minecraft.resources.Identifier;
public record RailKind(int age, boolean waxed) {
public RailKind { if (age < 0 || age > 3) throw new IllegalArgumentException("Oxidation: " + age); }
public int speed() { return 20 - 4 * age; }
public int code() { return age + (waxed ? 4 : 0); }
public static RailKind decode(int code) { return new RailKind(code & 3, (code & 4) != 0); }
public Identifier id() {
return Identifier.fromNamespaceAndPath("astracontent", (waxed ? "waxed_" : "")
+ new String[]{"", "exposed_", "weathered_", "oxidized_"}[age] + "copper_rail");
public RailKind {
if (age < 0 || age > 3) throw new IllegalArgumentException("Oxidation: " + age);
}
public int speed() {
return 20 - 4 * age;
}
public int code() {
return age + (waxed ? 4 : 0);
}
public static RailKind decode(int code) {
return new RailKind(code & 3, (code & 4) != 0);
}
public Identifier id() {
return Identifier.fromNamespaceAndPath(
"astracontent",
(waxed ? "waxed_" : "")
+ new String[] {"", "exposed_", "weathered_", "oxidized_"}[age]
+ "copper_rail");
}
public static RailKind fromId(Identifier id) {
for (int code = 0; code < 8; code++) if (decode(code).id().equals(id)) return decode(code);
return null;