Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
05f7254
test pitch
Deepseasaltyfish Jan 1, 2026
934079a
Merge remote-tracking branch 'origin/master'
Deepseasaltyfish Jan 1, 2026
c280158
fix id
Deepseasaltyfish Jan 1, 2026
cf546c4
rename
Deepseasaltyfish Jan 2, 2026
b859150
add cubicParabola
Deepseasaltyfish Jan 3, 2026
e09ce12
add multiSwitch basic frame
Deepseasaltyfish Jan 6, 2026
d80eeac
rewrite multiSwitch and did some other work
Deepseasaltyfish Jan 11, 2026
24f9040
Merge remote-tracking branch 'origin/master'
Deepseasaltyfish Jan 11, 2026
b4edee5
fix some rendering problem
Deepseasaltyfish Jan 12, 2026
82c727c
finished most multiSwitch work and did some fix
Deepseasaltyfish Jan 13, 2026
969e40d
Merge remote-tracking branch 'origin/master'
Deepseasaltyfish Jan 13, 2026
4dc5b55
close to finished
Deepseasaltyfish Jan 14, 2026
a01f763
remove debug output
Deepseasaltyfish Jan 15, 2026
dd6b9c3
add placement and custom offset
Deepseasaltyfish Jan 15, 2026
afa40b0
add some limit for pitch and height slider
Deepseasaltyfish Jan 15, 2026
c979741
fixed some gui logic and clean
Deepseasaltyfish Jan 16, 2026
62e270d
fixed some bugs of rendering,redstone and changed some gui component
Deepseasaltyfish Jan 16, 2026
4453160
changed gui component and added part of translation
Deepseasaltyfish Jan 16, 2026
f24d189
changed gui component and finished translation
Deepseasaltyfish Jan 17, 2026
45237df
fix a gui bug
Deepseasaltyfish Jan 17, 2026
a5b7ee8
clean and refactor
Deepseasaltyfish Jan 18, 2026
3497918
clean
Deepseasaltyfish Jan 18, 2026
ea8c5ec
clean format
Deepseasaltyfish Jan 19, 2026
34349d4
clean format
Deepseasaltyfish Jan 19, 2026
a19bd58
change height offset range
Deepseasaltyfish Feb 10, 2026
c7736a1
change height offset range
Deepseasaltyfish Feb 10, 2026
a7e4115
clean, change track uniqueId format, added pickType(so that we can ge…
Deepseasaltyfish Feb 21, 2026
dbaa89f
rename
Deepseasaltyfish Feb 22, 2026
a3c16ac
override multiSwitchInfo toString()
Deepseasaltyfish Feb 25, 2026
699a3bb
List cant be directly modified outside, make them unmodifiable to pub…
Deepseasaltyfish Feb 27, 2026
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 @@ -95,11 +95,14 @@ public void draw(IScreenBuilder builder) {
// This could be more efficient...
RailSettings settings = new RailSettings(gauge,
track,
TrackItems.STRAIGHT,
TrackItems.STRAIGHT,TrackItems.STRAIGHT,
10,
0,
1, TrackPositionType.FIXED,
TrackSmoothing.BOTH,
0,0,
0,0,
true,-1,
TrackDirection.NONE,
railBed,
ItemStack.EMPTY,
Expand Down
627 changes: 589 additions & 38 deletions src/main/java/cam72cam/immersiverailroading/gui/TrackGui.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@
import cam72cam.immersiverailroading.registry.TrackDefinition;
import cam72cam.immersiverailroading.tile.TileRailBase;
import cam72cam.immersiverailroading.tile.TileRailPreview;
import cam72cam.immersiverailroading.util.BlockUtil;
import cam72cam.immersiverailroading.util.IRFuzzy;
import cam72cam.immersiverailroading.util.PlacementInfo;
import cam72cam.immersiverailroading.util.RailInfo;
import cam72cam.immersiverailroading.util.*;
import cam72cam.mod.entity.Player;
import cam72cam.mod.item.*;
import cam72cam.mod.math.Vec3d;
Expand Down Expand Up @@ -56,6 +53,7 @@ public void onClickAir(Player player, World world, Player.Hand hand) {
public ClickResult onClickBlock(Player player, World world, Vec3i pos, Player.Hand hand, Facing facing, Vec3d hit) {
ItemStack stack = player.getHeldItem(hand);
RailSettings stackInfo = RailSettings.from(stack);
MultiSwitchInfo.Mutable multiSwitchInfo = MultiSwitchInfo.from(stack).mutable();

if (world.isServer && hand == Player.Hand.SECONDARY) {
ItemStack blockinfo = world.getItemStack(pos);
Expand All @@ -65,6 +63,7 @@ public ClickResult onClickBlock(Player player, World world, Vec3i pos, Player.Ha
stackInfo = stackInfo.with(b -> b.railBed = blockinfo);
}
stackInfo.write(stack);
multiSwitchInfo.immutable().write(stack);
return ClickResult.ACCEPTED;
}

Expand All @@ -89,8 +88,11 @@ public ClickResult onClickBlock(Player player, World world, Vec3i pos, Player.Ha
return ClickResult.ACCEPTED;
}


PlacementInfo placementInfo = new PlacementInfo(stack, player.getYawHead(), hit.subtract(0, hit.y, 0));
RailInfo info = new RailInfo(stack, placementInfo, null);
multiSwitchInfo.writePlacement(placementInfo);
RailInfo info = new RailInfo(stack, placementInfo, null, multiSwitchInfo.immutable());

info.build(player, pos);
return ClickResult.ACCEPTED;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,16 @@
public class RailSettings {
public final Gauge gauge;
public final TrackItems type;
public final TrackItems pickType;//pickType stores origin type in subCurves
public final int length;
public final float degrees;
public final float curvosity;
public final float pitchStart;
public final float pitchEnd;
public final float placementOffset;
public final float customOffset;
public final boolean isForward;
public final int farRadius;
public final TrackPositionType posType;
public final TrackSmoothing smoothing;
public final TrackDirection direction;
Expand All @@ -25,10 +32,11 @@ public class RailSettings {
public final int transfertableEntryCount;
public final int transfertableEntrySpacing;

public RailSettings(Gauge gauge, String track, TrackItems type, int length, float degrees, float curvosity, TrackPositionType posType, TrackSmoothing smoothing, TrackDirection direction, ItemStack railBed, ItemStack railBedFill, boolean isPreview, boolean isGradeCrossing, int count, int spacing) {
public RailSettings(Gauge gauge, String track, TrackItems type, TrackItems pickType, int length, float degrees, float curvosity, TrackPositionType posType, TrackSmoothing smoothing, float pitchStart, float pitchEnd, float placementOffset, float customOffset, boolean isForward, int farRadius, TrackDirection direction, ItemStack railBed, ItemStack railBedFill, boolean isPreview, boolean isGradeCrossing, int count, int spacing) {
this.gauge = gauge;
this.track = track;
this.type = type;
this.pickType = pickType;
this.length = length;
this.degrees = degrees;
this.posType = posType;
Expand All @@ -41,21 +49,44 @@ public RailSettings(Gauge gauge, String track, TrackItems type, int length, floa
this.curvosity = curvosity;
this.transfertableEntryCount = count;
this.transfertableEntrySpacing = spacing;
this.pitchStart = pitchStart;
this.pitchEnd = pitchEnd;
this.placementOffset = placementOffset;
this.customOffset = customOffset;
this.isForward = isForward;
this.farRadius = farRadius;
}

public void write(ItemStack stack) {
TagCompound root = stack.getTagCompound();
if (root == null) {
root = new TagCompound();
}

TagCompound data = new TagCompound();
try {
TagSerializer.serialize(data, mutable());
} catch (SerializationException e) {
ImmersiveRailroading.catching(e);
}
stack.setTagCompound(data);

root.set("settings", data);
stack.setTagCompound(root);
}

public static RailSettings from(ItemStack stack) {
TagCompound root = stack.getTagCompound();
if (root == null || !root.hasKey("settings")) {
//legacy data
try {
return new Mutable(stack.getTagCompound()).immutable();
} catch (SerializationException e) {
throw new RuntimeException(e);
}
}

try {
return new Mutable(stack.getTagCompound()).immutable();
TagCompound data = root.get("settings");
return new Mutable(data).immutable();
} catch (SerializationException e) {
throw new RuntimeException(e);
}
Expand Down Expand Up @@ -113,6 +144,8 @@ public static class Mutable {
public Gauge gauge;
@TagField("type")
public TrackItems type;
@TagField("pickType")
public TrackItems pickType;
@TagField("length")
public int length;
@TagField(value = "degrees", mapper = DegreesMapper.class)
Expand All @@ -135,7 +168,12 @@ public static class Mutable {
public boolean isGradeCrossing;
@TagField("track")
public String track;

@TagField(value = "pitch")
public TagCompound pitchTag;
@TagField(value = "posOffset")
public TagCompound posOffsetTag;
@TagField(value = "transitionCurves")
public TagCompound transitionCurvesTag;
@TagField("transfertableEntryCount")
public int transfertableEntryCount;
@TagField("transfertableEntrySpacing")
Expand All @@ -144,7 +182,21 @@ public static class Mutable {
private Mutable(RailSettings settings) {
this.gauge = settings.gauge;
this.track = settings.track;

pitchTag = new TagCompound();
pitchTag.setFloat("start", settings.pitchStart);
pitchTag.setFloat("end", settings.pitchEnd);

posOffsetTag = new TagCompound();
posOffsetTag.setFloat("placementOffset", settings.placementOffset);
posOffsetTag.setFloat("customOffset", settings.customOffset);

transitionCurvesTag = new TagCompound();
transitionCurvesTag.setBoolean("isForward", settings.isForward);
transitionCurvesTag.setInteger("farRadius", settings.farRadius);

this.type = settings.type;
this.pickType = settings.pickType;
this.length = settings.length;
this.degrees = settings.degrees;
this.curvosity = settings.curvosity;
Expand All @@ -163,7 +215,21 @@ private Mutable(TagCompound data) throws SerializationException {
// Defaults
gauge = Gauge.from(Gauge.STANDARD);
type = TrackItems.STRAIGHT;
pickType = type;
track = "default";

pitchTag = new TagCompound();
pitchTag.setFloat("start", 0.0f);
pitchTag.setFloat("end", 0.0f);

posOffsetTag = new TagCompound();
posOffsetTag.setFloat("placementOffset", 0.0f);
posOffsetTag.setFloat("customOffset", 0.0f);

transitionCurvesTag = new TagCompound();
transitionCurvesTag.setBoolean("isForward", true);
transitionCurvesTag.setInteger("farRadius", -1);

length = 10;
degrees = 90;
posType = TrackPositionType.FIXED;
Expand All @@ -185,11 +251,18 @@ public RailSettings immutable() {
gauge,
track,
type,
pickType,
length,
degrees,
curvosity,
posType,
smoothing,
pitchTag.getFloat("start"),
pitchTag.getFloat("end"),
posOffsetTag.getFloat("placementOffset"),
posOffsetTag.getFloat("customOffset"),
transitionCurvesTag.getBoolean("isForward"),
transitionCurvesTag.getInteger("farRadius"),
direction,
railBed,
railBedFill,
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/cam72cam/immersiverailroading/library/GuiText.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public enum GuiText {
SELECTOR_TRACK("selector.track"),
SELECTOR_TRANSFER_TABLE_ENTRY_COUNT("selector.transfer_table_entry_count"),
SELECTOR_TRANSFER_TABLE_ENTRY_SPACING("selector.transfer_table_entry_spacing"),
SELECTOR_SUB_TYPE("selector.sub_type"),
SELECTOR_AUGMENT_DETECT("selector.augment.detect"),
SELECTOR_AUGMENT_REDSTONE("selector.augment.redstone"),
SELECTOR_AUGMENT_PUSHPULL("selector.augment.pushpull"),
Expand All @@ -45,8 +46,18 @@ public enum GuiText {
TRACK_POSITION("track.position"),
TRACK_SMOOTHING("track.smoothing"),
TRACK_DIRECTION("track.direction"),
TRACK_FAR_RADIUS("track.far_radius"),
TRACK_IS_FORWARD("track.is_forward"),
TRACK_NEAR_HEIGHT_OFFSET("track.near_height_offset"),
TRACK_FAR_HEIGHT_OFFSET("track.far_height_offset"),
TRACK_NEAR_PITCH("track.near_pitch"),
TRACK_FAR_PITCH("track.far_pitch"),
TRACK_PLACE_BLUEPRINT_TRUE("track.place_blueprint_true"),
TRACK_PLACE_BLUEPRINT_FALSE("track.place_blueprint_false"),
TRACK_SELECTED_WAY("track.selected_way"),
TRACK_ADD_WAY("track.add_way"),
TRACK_DELETE_WAY("track.delete_way"),
TRACK_INSERT_WAY("track.insert_way"),

LOCO_WORKS("loco.works"),
// LOCO_HORSE_POWER("loco.horse_power"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
public enum SwitchState {
NONE,
STRAIGHT,
TURN;
TURN,
MID1,MID2,MID3,MID4;//multi-way(max=6) turnout:from left to right:straight->mid->turn?

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public enum TrackItems {
SWITCH(4),
TURNTABLE(5),
CUSTOM(7),
TRANSFERTABLE(6);
TRANSFERTABLE(6),
CUBICPARABOLA(8),
MULTISWITCH(9);

private final int order;

Expand All @@ -29,6 +31,8 @@ public boolean hasQuarters() {
switch (this) {
case TURN:
case SWITCH:
case CUBICPARABOLA:
case MULTISWITCH:
return true;
default:
return false;
Expand All @@ -39,6 +43,7 @@ public boolean hasCurvosity() {
switch (this) {
case SWITCH:
case CUSTOM:
case MULTISWITCH:
return true;
default:
return false;
Expand All @@ -49,7 +54,9 @@ public boolean hasSmoothing() {
switch (this) {
case SLOPE:
case TURN:
case CUBICPARABOLA:
case SWITCH:
case MULTISWITCH:
case CUSTOM:
return true;
default:
Expand All @@ -60,7 +67,9 @@ public boolean hasSmoothing() {
public boolean hasDirection() {
switch (this) {
case TURN:
case CUBICPARABOLA:
case SWITCH:
case MULTISWITCH:
return true;
default:
return false;
Expand All @@ -77,6 +86,34 @@ public boolean isTable() {
}
}

public boolean isMulti() {
switch (this) {
case MULTISWITCH:
return true;
default:
return false;
}
}

public boolean hasFarRadius() {
switch (this) {
case CUBICPARABOLA:
return true;
default:
return false;
}
}
public boolean isSwitchWay() {
switch (this) {
case CUBICPARABOLA:
case CUSTOM:
case TURN:
return true;
default:
return false;
}
}

public int getOrder() {
return this.order;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,18 @@ public enum TrackPositionType {
SMOOTH,
SMOOTH_LOCKED,
;
//TODO:
// new value:
// snapping_direction(which allows going around the nearest track path),
// snapping_pos(which locks xyz of nearest point),
// snapping_all(lock pos and direction to nearest point)
// and for pixel we can have an config option to make (or store it in item and config in gui would be better):
// pixels2,pixels4,pixels8,pixels32,pixels64, ...like LittleTiles
// TrackGui:add a button besides posType,to determine pixel level/snapping type mentioned above
// others:
// make a gui to display pos and yaw when holding itemTrackBlueprint
// for superelevation, first we need a method fits segmentation, and we need a option to determine whether to offset height with superelevation
// do we need to implement free interpolation? id so what method should we use? bezier?

@Override
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ public enum TrackSmoothing {
BOTH,
NEAR,
FAR,
NEITHER;
NEITHER,
PITCH_LOCKED_CUBIC;

@Override
public String toString() {
Expand Down
Loading