2020-05-06 11:48:49 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2020-04-13 08:33:46 +02: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
2020-06-30 07:20:29 +02:00
index 03e1b76a8b6850a26ed8a7b1992e09756166f5b8..27926559a665a5af14f11b8b4331cdb5f120eb41 100644
2020-04-13 08:33:46 +02:00
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
2020-06-30 07:20:29 +02:00
@@ -420,7 +420,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2020-04-26 09:26:21 +02: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;
}
2020-06-30 07:20:29 +02:00
@@ -1276,7 +1276,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2020-04-26 09:26:21 +02: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);
2020-06-30 07:20:29 +02:00
@@ -2071,7 +2071,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
2020-04-13 08:33:46 +02: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-06-26 03:58:00 +02:00
index f6209e9c0b9e0ab99693025d23847bc62a06225d..1c271ee568a02f1ab9c8722b840444f5cf5d657f 100644
2020-04-13 08:33:46 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
2020-06-26 03:58:00 +02:00
@@ -318,7 +318,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
2020-04-13 08:33:46 +02:00
2020-04-26 09:26:21 +02:00
String title = container.getBukkitView().getTitle();
2020-06-26 03:58:00 +02: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 09:26:21 +02:00
getHandle().activeContainer = container;
getHandle().activeContainer.addSlotListener(player);
}
2020-06-26 03:58:00 +02:00
@@ -388,7 +388,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
2020-04-26 09:26:21 +02:00
// Now open the window
Containers<?> windowType = CraftContainer.getNotchInventoryType(inventory.getTopInventory());
String title = inventory.getTitle();
2020-06-26 03:58:00 +02: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 09:26:21 +02:00
player.activeContainer = container;
player.activeContainer.addSlotListener(player);
}