2020-05-06 09:48:49 +00:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-04-13 06:33:46 +00:00
From: Shane Freeder <theboyetronic@gmail.com>
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
2021-01-29 00:32:08 +00:00
index 67eaac661a03742051e63551e6f18e1475a19e99..18f50189032b710dbdd4e81b079b57b48db49630 100644
2020-04-13 06:33:46 +00:00
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
2021-01-29 00:32:08 +00:00
@@ -428,7 +428,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2020-04-26 07:26:21 +00:00
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;
}
2021-01-29 00:32:08 +00:00
@@ -1273,7 +1273,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2020-04-26 07:26:21 +00:00
} 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);
2021-01-29 00:32:08 +00:00
@@ -2069,7 +2069,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2020-04-13 06:33:46 +00:00
}
@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
2020-08-31 12:30:51 +00:00
index ebcd2d043b3e6cf90b62eda1ea7a2d8c01f1c7a8..c3a51843a58138270bd24e51b5bead2c43e2cbe3 100644
2020-04-13 06:33:46 +00:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
2020-07-01 23:41:58 +00:00
@@ -319,7 +319,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
2020-04-13 06:33:46 +00:00
2020-04-26 07:26:21 +00:00
String title = container.getBukkitView().getTitle();
2020-06-26 01:58:00 +00:00
- 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
2020-04-26 07:26:21 +00:00
getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player);
}
2020-07-01 23:41:58 +00:00
@@ -389,7 +389,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
2020-04-26 07:26:21 +00:00
// Now open the window
Containers<?> windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory());
String title = inventory.getTitle();
2020-06-26 01:58:00 +00:00
- 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
2020-04-26 07:26:21 +00:00
player.activeContainer = container;
player.activeContainer.addSlotListener(player);
}