mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-27 23:47:38 +01:00
parent
f8cc7ab73c
commit
c013173265
1 changed files with 10 additions and 2 deletions
|
@ -151,6 +151,13 @@ public class StationPeripheral extends SyncedPeripheral<StationBlockEntity> {
|
||||||
|
|
||||||
@LuaFunction(mainThread = true)
|
@LuaFunction(mainThread = true)
|
||||||
public final void setSchedule(IArguments arguments) throws LuaException {
|
public final void setSchedule(IArguments arguments) throws LuaException {
|
||||||
|
if (arguments.getTable(0).size() != 2)
|
||||||
|
throw new LuaException("Not a valid schedule");
|
||||||
|
|
||||||
|
Object entries = arguments.getTable(0).get("entries");
|
||||||
|
if (entries instanceof Map<?, ?> map && map.isEmpty())
|
||||||
|
throw new LuaException("Schedule must have at least one entry");
|
||||||
|
|
||||||
Train train = getTrainOrThrow();
|
Train train = getTrainOrThrow();
|
||||||
Schedule schedule = Schedule.fromTag(toCompoundTag(new CreateLuaTable(arguments.getTable(0))));
|
Schedule schedule = Schedule.fromTag(toCompoundTag(new CreateLuaTable(arguments.getTable(0))));
|
||||||
boolean autoSchedule = train.runtime.getSchedule() == null || train.runtime.isAutoSchedule;
|
boolean autoSchedule = train.runtime.getSchedule() == null || train.runtime.isAutoSchedule;
|
||||||
|
@ -233,8 +240,9 @@ public class StationPeripheral extends SyncedPeripheral<StationBlockEntity> {
|
||||||
return StringTag.valueOf(v);
|
return StringTag.valueOf(v);
|
||||||
else if (value instanceof Map<?, ?> v && v.containsKey(1.0)) { // List
|
else if (value instanceof Map<?, ?> v && v.containsKey(1.0)) { // List
|
||||||
ListTag list = new ListTag();
|
ListTag list = new ListTag();
|
||||||
for (Object o : v.values()) {
|
for (double i = 1; i <= v.size(); i++) {
|
||||||
list.add(toNBTTag(null, o));
|
if (v.get(i) != null)
|
||||||
|
list.add(toNBTTag(null, v.get(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
|
|
Loading…
Reference in a new issue