Linked controller spectator fixes

- Deactivate controller if in spectator mode
- Prevent packet handling if in spectator mode, except for resets
- Deactivate controller if a screen is opened
- Resolves #1774
This commit is contained in:
PepperBell 2021-06-13 11:22:42 -07:00
parent 2a19b5eb41
commit ec2a66357f
3 changed files with 19 additions and 2 deletions

View file

@ -35,6 +35,9 @@ public class LinkedControllerBindPacket extends LinkedControllerPacketBase {
@Override
protected void handle(ServerPlayerEntity player, ItemStack heldItem) {
if (player.isSpectator())
return;
ItemStackHandler frequencyItems = LinkedControllerItem.getFrequencyItems(heldItem);
LinkBehaviour linkBehaviour = TileEntityBehaviour.get(player.world, linkLocation, LinkBehaviour.TYPE);
if (linkBehaviour == null)

View file

@ -108,8 +108,7 @@ public class LinkedControllerClientHandler {
ClientPlayerEntity player = mc.player;
ItemStack heldItem = player.getHeldItemMainhand();
if (mc.gameSettings.keyBindInventory.isPressed() || InputMappings.isKeyDown(mc.getWindow()
.getHandle(), GLFW.GLFW_KEY_ESCAPE)) {
if (player.isSpectator()) {
MODE = Mode.IDLE;
onReset();
return;
@ -124,6 +123,18 @@ public class LinkedControllerClientHandler {
}
}
if (mc.currentScreen != null) {
MODE = Mode.IDLE;
onReset();
return;
}
if (InputMappings.isKeyDown(mc.getWindow().getHandle(), GLFW.GLFW_KEY_ESCAPE)) {
MODE = Mode.IDLE;
onReset();
return;
}
Vector<KeyBinding> controls = getControls();
Collection<Integer> pressedKeys = new HashSet<>();
for (int i = 0; i < controls.size(); i++) {

View file

@ -42,6 +42,9 @@ public class LinkedControllerInputPacket extends LinkedControllerPacketBase {
UUID uniqueID = player.getUniqueID();
BlockPos pos = player.getBlockPos();
if (player.isSpectator() && press)
return;
LinkedControllerServerHandler.receivePressed(world, pos, uniqueID, activatedButtons.stream()
.map(i -> LinkedControllerItem.toFrequency(heldItem, i))
.collect(Collectors.toList()), press);