From c5e178de80027f3e8162483866818779682afc72 Mon Sep 17 00:00:00 2001 From: Falxie_ <94479957+falxie@users.noreply.github.com> Date: Thu, 10 Nov 2022 22:45:56 -0800 Subject: [PATCH 1/2] Fix StationUnloadedCondition not working in other dimensions --- .../condition/StationUnloadedCondition.java | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java index 8f5ccbd92..104fc3f42 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java @@ -13,6 +13,9 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; import net.minecraft.world.item.ItemStack; import net.minecraft.world.level.Level; +import net.minecraft.core.BlockPos; +import net.minecraft.resources.ResourceKey; +import net.minecraft.server.MinecraftServer; public class StationUnloadedCondition extends ScheduleWaitCondition { @Override @@ -25,9 +28,16 @@ public class StationUnloadedCondition extends ScheduleWaitCondition { GlobalStation currentStation = train.getCurrentStation(); if (currentStation == null) return false; - if (level instanceof ServerLevel serverLevel) - return !serverLevel.isPositionEntityTicking(currentStation.getTilePos()); - return false; + BlockPos stationPos = currentStation.getTilePos(); + ResourceKey stationDim = currentStation.getTileDimension(); + MinecraftServer server = level.getServer(); + if (server == null) + return false; + ServerLevel stationLevel = server.getLevel(stationDim); + if (stationLevel == null) { + return false; + } + return !stationLevel.isPositionEntityTicking(currentStation.getTilePos()); } @Override @@ -45,4 +55,4 @@ public class StationUnloadedCondition extends ScheduleWaitCondition { public MutableComponent getWaitingStatus(Level level, Train train, CompoundTag tag) { return Lang.translateDirect("schedule.condition.unloaded.status"); } -} \ No newline at end of file +} From c06d9bf81c214ee797cf0a1a4528c421e6dddee9 Mon Sep 17 00:00:00 2001 From: Falxie_ <94479957+falxie@users.noreply.github.com> Date: Sat, 12 Nov 2022 02:02:58 +0000 Subject: [PATCH 2/2] Remove unnecessary variable --- .../management/schedule/condition/StationUnloadedCondition.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java index 104fc3f42..4b09cba39 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/condition/StationUnloadedCondition.java @@ -28,7 +28,6 @@ public class StationUnloadedCondition extends ScheduleWaitCondition { GlobalStation currentStation = train.getCurrentStation(); if (currentStation == null) return false; - BlockPos stationPos = currentStation.getTilePos(); ResourceKey stationDim = currentStation.getTileDimension(); MinecraftServer server = level.getServer(); if (server == null)