Stutter as one

- Carriage entities of a train now ensure their packets are sent during the same tick
- Fixed misaligned pitch of instanced bogeys on slopes
This commit is contained in:
simibubi 2022-04-08 22:48:15 +02:00
parent 4638148560
commit b66a722826
3 changed files with 15 additions and 6 deletions

View file

@ -175,7 +175,9 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
if (!level.isClientSide) { if (!level.isClientSide) {
entityData.set(SCHEDULED, carriage.train.runtime.getSchedule() != null); entityData.set(SCHEDULED, carriage.train.runtime.getSchedule() != null);
if (tickCount % getType().updateInterval() == 0 && carriageData.isDirty()) { boolean shouldCarriageSyncThisTick =
carriage.train.shouldCarriageSyncThisTick(level.getGameTime(), getType().updateInterval());
if (shouldCarriageSyncThisTick && carriageData.isDirty()) {
entityData.set(CARRIAGE_DATA, null); entityData.set(CARRIAGE_DATA, null);
entityData.set(CARRIAGE_DATA, carriageData); entityData.set(CARRIAGE_DATA, carriageData);
carriageData.setDirty(false); carriageData.setDirty(false);

View file

@ -45,15 +45,16 @@ public class CarriageContraptionInstance extends EntityInstance<CarriageContrapt
ms.pushPose(); ms.pushPose();
TransformStack.cast(ms) TransformStack.cast(ms)
.translate(getInstancePosition(partialTicks)) .translate(getInstancePosition(partialTicks));
.translate(0, -1.5 - 1 / 128f, 0);;
for (BogeyInstance instance : bogeys) { for (BogeyInstance instance : bogeys) {
if (instance != null) { if (instance != null) {
ms.pushPose(); ms.pushPose();
CarriageBogey bogey = instance.bogey; CarriageBogey bogey = instance.bogey;
CarriageContraptionEntityRenderer.translateBogey(ms, bogey, bogeySpacing, viewYRot, viewXRot, partialTicks); CarriageContraptionEntityRenderer.translateBogey(ms, bogey, bogeySpacing, viewYRot, viewXRot,
partialTicks);
ms.translate(0, -1.5 - 1 / 128f, 0);
instance.beginFrame(bogey.wheelAngle.getValue(partialTicks), ms); instance.beginFrame(bogey.wheelAngle.getValue(partialTicks), ms);
ms.popPose(); ms.popPose();

View file

@ -91,6 +91,7 @@ public class Train {
public int migrationCooldown; public int migrationCooldown;
public boolean derailed; public boolean derailed;
int tickOffset;
double[] stress; double[] stress;
public Train(UUID id, UUID owner, TrackGraph graph, List<Carriage> carriages, List<Integer> carriageSpacing, public Train(UUID id, UUID owner, TrackGraph graph, List<Carriage> carriages, List<Integer> carriageSpacing,
@ -117,6 +118,7 @@ public class Train {
manualSteer = SteerDirection.NONE; manualSteer = SteerDirection.NONE;
occupiedSignalBlocks = new HashMap<>(); occupiedSignalBlocks = new HashMap<>();
reservedSignalBlocks = new HashSet<>(); reservedSignalBlocks = new HashSet<>();
tickOffset = Create.RANDOM.nextInt(100);
} }
public void earlyTick(Level level) { public void earlyTick(Level level) {
@ -763,6 +765,10 @@ public class Train {
} }
public boolean shouldCarriageSyncThisTick(long gameTicks, int updateInterval) {
return (gameTicks + tickOffset) % updateInterval == 0;
}
public Couple<Couple<TrackNode>> getEndpointEdges() { public Couple<Couple<TrackNode>> getEndpointEdges() {
return Couple.create(carriages.get(0) return Couple.create(carriages.get(0)
.getLeadingPoint(), .getLeadingPoint(),