This commit is contained in:
Timo van Veen 2023-10-30 18:38:29 +01:00
parent 2565fa7605
commit aff05bf84a
4 changed files with 12 additions and 13 deletions

View file

@ -1,7 +1,6 @@
package com.simibubi.create.content.trains.entity;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
@ -55,8 +54,6 @@ import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.network.PacketDistributor;
import org.openjdk.nashorn.internal.objects.Global;
public class CarriageContraptionEntity extends OrientedContraptionEntity {
private static final EntityDataAccessor<CarriageSyncData> CARRIAGE_DATA =

View file

@ -611,6 +611,7 @@ public class Navigation {
int signalWeight = Mth.clamp(ticksWaitingForSignal * 2, Train.Penalties.RED_SIGNAL, 200);
// Apply penalties to initial edge
int initialPenalty = 0;
if (costRelevant)
initialPenalty += penalties.getOrDefault(initialEdge, 0);
@ -712,6 +713,7 @@ public class Navigation {
if (costRelevant)
newPenalty += penalties.getOrDefault(newEdge, 0);
// Apply penalty to next connected edge
boolean hasDestination = false;
EdgeData signalData = newEdge.getEdgeData();
if (signalData.hasPoints()) {
@ -758,7 +760,7 @@ public class Navigation {
continue;
double remainingDist = 0;
// Calculate remaining distance estimator for next connected edge
if (destinations != null && !destinations.isEmpty()) {
remainingDist = Double.MAX_VALUE;
Vec3 newNodePosition = newNode.getLocation().getLocation();
@ -884,9 +886,9 @@ public class Navigation {
c -> currentPath.add(Couple
.deserializeEach(c.getList("Nodes", Tag.TAG_COMPOUND), c2 -> TrackNodeLocation.read(c2, dimensions))
.map(graph::locateNode)));
removeBrokenPathEntries();
waitingForSignal = tag.contains("BlockingSignal")
? Pair.of(tag.getUUID("BlockingSignal"), tag.getBoolean("BlockingSignalSide"))
: null;
@ -901,7 +903,7 @@ public class Navigation {
* Trains might load or save with null entries in their path, this method avoids
* that anomaly from causing NPEs. The underlying issue has not been found.
*/
boolean nullEntriesPresent = false;
for (Iterator<Couple<TrackNode>> iterator = currentPath.iterator(); iterator.hasNext();) {

View file

@ -326,9 +326,9 @@ public class ScheduleRuntime {
return accumulatedTime;
if (predictionTicks.size() <= currentEntry)
return accumulatedTime;
int departureTime = estimateStayDuration(index);
if (accumulatedTime < 0) {
predictions.add(createPrediction(index, filter.getFilter(), currentTitle, accumulatedTime));
return Math.min(accumulatedTime, departureTime);
@ -344,10 +344,10 @@ public class ScheduleRuntime {
if (accumulatedTime != TBD)
accumulatedTime += departureTime;
if (departureTime == INVALID)
accumulatedTime = INVALID;
return accumulatedTime;
}
@ -375,7 +375,7 @@ public class ScheduleRuntime {
private TrainDeparturePrediction createPrediction(int index, String destination, String currentTitle, int time) {
if (time == INVALID)
return null;
int size = schedule.entries.size();
if (index >= size) {
if (!schedule.cyclic)

View file

@ -288,7 +288,7 @@ public class StationBlockEntity extends SmartBlockEntity implements ITransformab
BlockPos up = new BlockPos(track.getUpNormal(level, pos, state));
BlockPos down = new BlockPos(track.getUpNormal(level, pos, state).scale(-1));
int bogeyOffset = pos.distManhattan(edgePoint.getGlobalPosition()) - 1;
if (!isValidBogeyOffset(bogeyOffset)) {
for (boolean upsideDown : Iterate.falseAndTrue) {
for (int i = -1; i <= 1; i++) {