mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +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
|
@ -116,7 +116,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
|
|||
private CarriageSyncData getCarriageData() {
|
||||
return entityData.get(CARRIAGE_DATA);
|
||||
}
|
||||
|
||||
|
||||
public boolean hasSchedule() {
|
||||
return entityData.get(SCHEDULED);
|
||||
}
|
||||
|
@ -175,7 +175,9 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
|
|||
|
||||
if (!level.isClientSide) {
|
||||
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, carriageData);
|
||||
carriageData.setDirty(false);
|
||||
|
@ -267,7 +269,7 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity {
|
|||
Couple<Boolean> sides = Couple.create(false, false);
|
||||
if (!(contraption instanceof CarriageContraption cc))
|
||||
return sides;
|
||||
|
||||
|
||||
sides.setFirst(cc.blazeBurnerConductors.getFirst());
|
||||
sides.setSecond(cc.blazeBurnerConductors.getSecond());
|
||||
|
||||
|
|
|
@ -45,15 +45,16 @@ public class CarriageContraptionInstance extends EntityInstance<CarriageContrapt
|
|||
ms.pushPose();
|
||||
|
||||
TransformStack.cast(ms)
|
||||
.translate(getInstancePosition(partialTicks))
|
||||
.translate(0, -1.5 - 1 / 128f, 0);;
|
||||
.translate(getInstancePosition(partialTicks));
|
||||
|
||||
for (BogeyInstance instance : bogeys) {
|
||||
if (instance != null) {
|
||||
ms.pushPose();
|
||||
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);
|
||||
ms.popPose();
|
||||
|
|
|
@ -91,6 +91,7 @@ public class Train {
|
|||
public int migrationCooldown;
|
||||
public boolean derailed;
|
||||
|
||||
int tickOffset;
|
||||
double[] stress;
|
||||
|
||||
public Train(UUID id, UUID owner, TrackGraph graph, List<Carriage> carriages, List<Integer> carriageSpacing,
|
||||
|
@ -117,6 +118,7 @@ public class Train {
|
|||
manualSteer = SteerDirection.NONE;
|
||||
occupiedSignalBlocks = new HashMap<>();
|
||||
reservedSignalBlocks = new HashSet<>();
|
||||
tickOffset = Create.RANDOM.nextInt(100);
|
||||
}
|
||||
|
||||
public void earlyTick(Level level) {
|
||||
|
@ -762,6 +764,10 @@ public class Train {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
public boolean shouldCarriageSyncThisTick(long gameTicks, int updateInterval) {
|
||||
return (gameTicks + tickOffset) % updateInterval == 0;
|
||||
}
|
||||
|
||||
public Couple<Couple<TrackNode>> getEndpointEdges() {
|
||||
return Couple.create(carriages.get(0)
|
||||
|
|
Loading…
Reference in a new issue