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 @Override
protected void handle(ServerPlayerEntity player, ItemStack heldItem) { protected void handle(ServerPlayerEntity player, ItemStack heldItem) {
if (player.isSpectator())
return;
ItemStackHandler frequencyItems = LinkedControllerItem.getFrequencyItems(heldItem); ItemStackHandler frequencyItems = LinkedControllerItem.getFrequencyItems(heldItem);
LinkBehaviour linkBehaviour = TileEntityBehaviour.get(player.world, linkLocation, LinkBehaviour.TYPE); LinkBehaviour linkBehaviour = TileEntityBehaviour.get(player.world, linkLocation, LinkBehaviour.TYPE);
if (linkBehaviour == null) if (linkBehaviour == null)

View file

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

View file

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