Skip to content

Commit

Permalink
em
Browse files Browse the repository at this point in the history
  • Loading branch information
xiewuzhiying committed Oct 11, 2024
1 parent 5dca4bc commit 4632cd5
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
}

plugins {
id 'net.minecraftforge.gradle' version '5.1.+'
id 'net.minecraftforge.gradle' version '[6.0.16,6.2)'
}

apply plugin: 'org.spongepowered.mixin'
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -23,20 +23,13 @@ public class ComputerizedRedstoneLinkPeripheral extends SmartPeripheral {
public HashMap<UUID, RedstoneHandle> handles = new HashMap<>();

public void removeHandle(UUID hd) {
handles.values().forEach(a -> {
if (a.handle.equals(hd)) {
a.close();
handles.remove(hd, a);
}
});
}

public void killHandles(UUID hd) {
handles.values().forEach(a -> {
if (a.handle.equals(hd)) {
a.close();
handles.remove(a.handle, a);
}
parent.tasks.add(() -> {
handles.entrySet().removeIf(entry -> entry.getKey().equals(hd));
parent.pairs.forEach((b,a) -> {
if (b.equals(hd)) {
parent.remove(a);
}
});
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<Train> first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
Train train = first.get();
return MethodResult.of(new Gson().fromJson(Component.Serializer.toJson(train.name), Map.class));
});
addMethod("getTrainSchedule", (iComputerAccess, iLuaContext, iArguments) -> {
String b = iArguments.getString(0);
Optional<Train> first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
Train train = first.get();
Map<Object, Object> map = new HashMap<>();
if (train.runtime.getSchedule() == null)
return MethodResult.of(null);
return MethodResult.of((Object) null);
int bidx = 1;
for (ScheduleEntry entry : train.runtime.getSchedule().entries) {
Map<Object, Object> data = new HashMap<>();
Expand Down Expand Up @@ -118,7 +118,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<Train> first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
Train train = first.get();

Optional<Carriage.DimensionalCarriageEntity> carr = Optional.empty();
Expand All @@ -130,7 +130,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
carr = Optional.of(a1);

if (carr.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
Carriage.DimensionalCarriageEntity car = carr.get();
CarriageContraptionEntity ent = car.entity.get();
return MethodResult.of(ent.getX(), ent.getY(), ent.getZ(), ent.level().dimension().registry().toString());
Expand All @@ -139,20 +139,20 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<Train> first = getTrains().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
Train train = first.get();
return MethodResult.of(train.speed);
});
addMethod("getTrainStopped", (iComputerAccess, iLuaContext, iArguments) -> {
String b = iArguments.getString(0);
Optional<Train> first = getTrains().stream().filter(a -> a.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
Train train = first.get();
GlobalStation currentStation = train.getCurrentStation();
if (currentStation != null)
return MethodResult.of(currentStation.getId().toString(), currentStation.name);
return MethodResult.of(null);
return MethodResult.of((Object) null);
});
// STOPS
addMethod("getStops", ((iComputerAccess, iLuaContext, iArguments) -> {
Expand All @@ -163,15 +163,15 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<GlobalStation> first = getStations().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
GlobalStation station = first.get();
return MethodResult.of(station.name);
});
addMethod("getStopWorldPosition", (iComputerAccess, iLuaContext, iArguments) -> {
String b = iArguments.getString(0);
Optional<GlobalStation> first = getStations().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
GlobalStation station = first.get();
BlockPos pos = station.getBlockEntityPos();
return MethodResult.of(pos.getX(), pos.getY(), pos.getZ());
Expand All @@ -180,7 +180,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<GlobalStation> first = getStations().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
GlobalStation station = first.get();
List<GlobalTrainDisplayData.TrainDeparturePrediction> prepare = GlobalTrainDisplayData.prepare(station.name, 200);
Map<Integer, Map<String, Object>> data = new HashMap();
Expand All @@ -205,7 +205,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<SignalBoundary> first = getSignals().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
SignalBoundary signal = first.get();
Map<Integer, Map<Integer, Integer>> returned = new HashMap<>();
int idx = 1;
Expand Down Expand Up @@ -233,7 +233,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
boolean toPos = iArguments.getBoolean(1);
Optional<SignalBoundary> first = getSignals().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
SignalBoundary signal = first.get();
SignalBlockEntity.SignalState stateFor = signal.cachedStates.get(toPos);
return switch (stateFor) {
Expand All @@ -252,7 +252,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<TrackObserver> first = getObservers().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
TrackObserver obs = first.get();
BlockPos pos = obs.getBlockEntityPos();
return MethodResult.of(pos.getX(), pos.getY(), pos.getZ());
Expand All @@ -261,7 +261,7 @@ public TrainNetworkObserverPeripheral(TrainNetworkObserverTile tile) {
String b = iArguments.getString(0);
Optional<TrackObserver> first = getObservers().stream().filter(a -> a.id.toString().equals(b)).findFirst();
if (first.isEmpty())
return MethodResult.of(null);
return MethodResult.of((Object) null);
TrackObserver obs = first.get();
return MethodResult.of(blowFilter(obs.getFilter().item()));
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ public void addDeferred(LinkPair pair) {
}

public void remove(LinkPair pair) {
if (PERIPHERAL.isPresent())
PERIPHERAL.resolve().get().killHandles(pair.index);
/*if (PERIPHERAL.isPresent())
PERIPHERAL.resolve().get().removeHandle(pair.index);*/
pairs.remove(pair.index, pair);
pair.sendSignal = 0;
pair.transmit.notifySignalChange();
Expand Down

0 comments on commit 4632cd5

Please sign in to comment.