From c36c4e756eb62d927817cfa22a782f581e623325 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Thu, 7 Jul 2022 13:18:03 +0200 Subject: [PATCH] Double Trouble - Fixed an item duplication issue with belts - Spectators can no longer interact with contraptions --- .../components/structureMovement/ContraptionHandlerClient.java | 2 ++ .../contraptions/relays/belt/transport/BeltInventory.java | 2 ++ .../logistics/trains/entity/CarriageContraptionEntity.java | 2 ++ .../create/content/logistics/trains/entity/TrainRelocator.java | 2 ++ .../trains/management/schedule/ScheduleItemRetrieval.java | 2 ++ 5 files changed, 10 insertions(+) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java index beca5f07c..f9d40b9cb 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionHandlerClient.java @@ -75,6 +75,8 @@ public class ContraptionHandlerClient { if (player == null) return; + if (player.isSpectator()) + return; if (mc.level == null) return; if (!event.isUseItem()) diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java index adf8811fe..dbfecf2e0 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/transport/BeltInventory.java @@ -428,6 +428,8 @@ public class BeltInventory { Function processFunction) { boolean dirty = false; for (TransportedItemStack transported : items) { + if (toRemove.contains(transported)) + continue; ItemStack stackBefore = transported.stack.copy(); if (Math.abs(position - transported.beltPosition) >= maxDistanceToPosition) continue; diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java index cab1ce204..5081a8d0f 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/CarriageContraptionEntity.java @@ -511,6 +511,8 @@ public class CarriageContraptionEntity extends OrientedContraptionEntity { @Override public boolean startControlling(BlockPos controlsLocalPos, Player player) { + if (player == null || player.isSpectator()) + return false; if (carriage == null) return false; if (carriage.train.derailed) diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocator.java b/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocator.java index 4133be722..838a536cc 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocator.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/entity/TrainRelocator.java @@ -79,6 +79,8 @@ public class TrainRelocator { LocalPlayer player = mc.player; if (player == null) return; + if (player.isSpectator()) + return; if (!player.position() .closerThan(relocatingOrigin, 24) || player.isSteppingCarefully()) { diff --git a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleItemRetrieval.java b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleItemRetrieval.java index 4408539b8..3ff2d3395 100644 --- a/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleItemRetrieval.java +++ b/src/main/java/com/simibubi/create/content/logistics/trains/management/schedule/ScheduleItemRetrieval.java @@ -28,6 +28,8 @@ public class ScheduleItemRetrieval { Player player = event.getPlayer(); if (player == null || entity == null) return; + if (player.isSpectator()) + return; Entity rootVehicle = entity.getRootVehicle(); if (!(rootVehicle instanceof CarriageContraptionEntity))