Destination display hotfix

This commit is contained in:
simibubi 2022-04-12 04:02:10 +02:00
parent 0c6a23db83
commit 517fad7a62

View file

@ -332,21 +332,28 @@ public class ScheduleRuntime {
} }
private TrainDeparturePrediction createPrediction(int index, String destination, String currentTitle, int time) { private TrainDeparturePrediction createPrediction(int index, String destination, String currentTitle, int time) {
if (index >= schedule.entries.size()) { int size = schedule.entries.size();
if (index >= size) {
if (!schedule.cyclic) if (!schedule.cyclic)
return new TrainDeparturePrediction(train, time, new TextComponent(" "), destination); return new TrainDeparturePrediction(train, time, new TextComponent(" "), destination);
index %= schedule.entries.size(); index %= size;
} }
ScheduleEntry scheduleEntry = schedule.entries.get(index); String text = currentTitle;
if (text.isBlank()) {
for (int i = 1; i < size; i++) {
int j = (index + i) % size;
ScheduleEntry scheduleEntry = schedule.entries.get(j);
if (!(scheduleEntry.instruction instanceof DestinationInstruction instruction)) if (!(scheduleEntry.instruction instanceof DestinationInstruction instruction))
return null; continue;
text = instruction.getFilter()
return new TrainDeparturePrediction(train, time,
new TextComponent(currentTitle.isBlank() ? instruction.getFilter()
.replaceAll("\\*", "") .replaceAll("\\*", "")
.trim() : currentTitle), .trim();
destination); break;
}
}
return new TrainDeparturePrediction(train, time, new TextComponent(text), destination);
} }
public CompoundTag write() { public CompoundTag write() {