From 92a1395b147cbf1e204eb3ba480694836c2f9357 Mon Sep 17 00:00:00 2001 From: Snownee Date: Tue, 26 Jan 2021 15:26:01 +0800 Subject: [PATCH] Fix spectator can interact with blocks --- .../block/mechanicalArm/ArmInteractionPointHandler.java | 4 +++- .../behaviour/edgeInteraction/EdgeInteractionHandler.java | 2 +- .../tileEntity/behaviour/filtering/FilteringHandler.java | 2 +- .../foundation/tileEntity/behaviour/linked/LinkHandler.java | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java index 7cf1e883b..a6d305883 100644 --- a/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java +++ b/src/main/java/com/simibubi/create/content/logistics/block/mechanicalArm/ArmInteractionPointHandler.java @@ -48,6 +48,9 @@ public class ArmInteractionPointHandler { World world = event.getWorld(); if (!world.isRemote) return; + PlayerEntity player = event.getPlayer(); + if (player != null && player.isSpectator()) + return; ArmInteractionPoint selected = getSelected(pos); @@ -60,7 +63,6 @@ public class ArmInteractionPointHandler { } selected.cycleMode(); - PlayerEntity player = event.getPlayer(); if (player != null) { String key = selected.mode == Mode.DEPOSIT ? "mechanical_arm.deposit_to" : "mechanical_arm.extract_from"; TextFormatting colour = selected.mode == Mode.DEPOSIT ? TextFormatting.GOLD : TextFormatting.AQUA; diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java index 3c7c90323..53124201c 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/edgeInteraction/EdgeInteractionHandler.java @@ -37,7 +37,7 @@ public class EdgeInteractionHandler { Hand hand = event.getHand(); ItemStack heldItem = player.getHeldItem(hand); - if (player.isSneaking()) + if (player.isSneaking() || player.isSpectator()) return; EdgeInteractionBehaviour behaviour = TileEntityBehaviour.get(world, pos, EdgeInteractionBehaviour.TYPE); if (behaviour == null) diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringHandler.java index dd605d425..d542f5039 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/filtering/FilteringHandler.java @@ -43,7 +43,7 @@ public class FilteringHandler { PlayerEntity player = event.getPlayer(); Hand hand = event.getHand(); - if (player.isSneaking()) + if (player.isSneaking() || player.isSpectator()) return; FilteringBehaviour behaviour = TileEntityBehaviour.get(world, pos, FilteringBehaviour.TYPE); diff --git a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java index b7538fdd7..30a88de18 100644 --- a/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java +++ b/src/main/java/com/simibubi/create/foundation/tileEntity/behaviour/linked/LinkHandler.java @@ -28,7 +28,7 @@ public class LinkHandler { PlayerEntity player = event.getPlayer(); Hand hand = event.getHand(); - if (player.isSneaking()) + if (player.isSneaking() || player.isSpectator()) return; LinkBehaviour behaviour = TileEntityBehaviour.get(world, pos, LinkBehaviour.TYPE);