mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-29 08:27:03 +01:00
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:
parent
4638148560
commit
b66a722826
3 changed files with 15 additions and 6 deletions
|
@ -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);
|
||||||
|
|
|
@ -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();
|
||||||
|
|
|
@ -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(),
|
||||||
|
|
Loading…
Reference in a new issue