From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Mon, 13 Apr 2020 07:31:44 +0100 Subject: [PATCH] Prevent opening inventories when frozen diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java index cc7710ab19e4805dff4336a22e0b29af564f8955..4d117ed0de75672fe95341832ec032b665179b39 100644 --- a/src/main/java/net/minecraft/server/EntityPlayer.java +++ b/src/main/java/net/minecraft/server/EntityPlayer.java @@ -424,7 +424,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { containerUpdateDelay = world.paperConfig.containerUpdateTickRate; } // Paper end - if (!this.world.isClientSide && !this.activeContainer.canUse(this)) { + if (!this.world.isClientSide && this.activeContainer != this.defaultContainer && (isFrozen() || !this.activeContainer.canUse(this))) { // Paper - auto close while frozen this.closeInventory(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper this.activeContainer = this.defaultContainer; } @@ -1252,7 +1252,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } else { // CraftBukkit start this.activeContainer = container; - this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle())); + if (!isFrozen()) this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, container.getType(), container.getTitle())); // Paper // CraftBukkit end container.addSlotListener(this); return OptionalInt.of(this.containerCounter); @@ -2043,7 +2043,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting { } @Override - protected boolean isFrozen() { + public boolean isFrozen() { // Paper - protected > public return super.isFrozen() || (this.playerConnection != null && this.playerConnection.isDisconnected()); // Paper } diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java index af95aff8b0252917dd324faadf0dbc773cb38ba6..867443784d685d8f200d00b50e4b11474cee5ebe 100644 --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java @@ -319,7 +319,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { String title = container.getBukkitView().getTitle(); - player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); + if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper getHandle().activeContainer = container; getHandle().activeContainer.addSlotListener(player); } @@ -389,7 +389,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity { // Now open the window Containers windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory()); String title = inventory.getTitle(); - player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); + if (!player.isFrozen()) player.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, windowType, CraftChatMessage.fromString(title)[0])); // Paper player.activeContainer = container; player.activeContainer.addSlotListener(player); }