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 (!(scheduleEntry.instruction instanceof DestinationInstruction instruction)) if (text.isBlank()) {
return null; for (int i = 1; i < size; i++) {
int j = (index + i) % size;
ScheduleEntry scheduleEntry = schedule.entries.get(j);
if (!(scheduleEntry.instruction instanceof DestinationInstruction instruction))
continue;
text = instruction.getFilter()
.replaceAll("\\*", "")
.trim();
break;
}
}
return new TrainDeparturePrediction(train, time, return new TrainDeparturePrediction(train, time, new TextComponent(text), destination);
new TextComponent(currentTitle.isBlank() ? instruction.getFilter()
.replaceAll("\\*", "")
.trim() : currentTitle),
destination);
} }
public CompoundTag write() { public CompoundTag write() {