Fix spectator can interact with blocks

This commit is contained in:
Snownee 2021-01-26 15:26:01 +08:00
parent 2c3a866494
commit 92a1395b14
4 changed files with 6 additions and 4 deletions

View file

@ -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;

View file

@ -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)

View file

@ -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);

View file

@ -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);