aboutsummaryrefslogtreecommitdiffhomepage
path: root/patches/server/0382-Prevent-opening-inventories-when-frozen.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/server/0382-Prevent-opening-inventories-when-frozen.patch')
-rw-r--r--patches/server/0382-Prevent-opening-inventories-when-frozen.patch50
1 files changed, 50 insertions, 0 deletions
diff --git a/patches/server/0382-Prevent-opening-inventories-when-frozen.patch b/patches/server/0382-Prevent-opening-inventories-when-frozen.patch
new file mode 100644
index 0000000000..a16f3603df
--- /dev/null
+++ b/patches/server/0382-Prevent-opening-inventories-when-frozen.patch
@@ -0,0 +1,50 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Shane Freeder <[email protected]>
+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/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+index eb0e5c43b995e778d28ecfad813ca3882cabe0fa..baff31a9dd003eef6191b59598523e387bc759a1 100644
+--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
++++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
+@@ -622,7 +622,7 @@ public class ServerPlayer extends Player {
+ containerUpdateDelay = level.paperConfig().tickRates.containerUpdate;
+ }
+ // Paper end
+- if (!this.level.isClientSide && !this.containerMenu.stillValid(this)) {
++ if (!this.level.isClientSide && this.containerMenu != this.inventoryMenu && (isImmobile() || !this.containerMenu.stillValid(this))) { // Paper - auto close while frozen
+ this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper
+ this.containerMenu = this.inventoryMenu;
+ }
+@@ -1492,7 +1492,7 @@ public class ServerPlayer extends Player {
+ } else {
+ // CraftBukkit start
+ this.containerMenu = container;
+- this.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(), container.getTitle()));
++ if (!isImmobile()) this.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(), container.getTitle())); // Paper
+ // CraftBukkit end
+ this.initMenu(container);
+ return OptionalInt.of(this.containerCounter);
+diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+index 883b6245f44f3fb82d7678e1092177ca646d484a..f5f30e1408892b4e728053bc5005e551396583a5 100644
+--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
++++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+@@ -326,7 +326,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
+ if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper
+
+ //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
+- player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
++ if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
+ player.containerMenu = container;
+ player.initMenu(container);
+ }
+@@ -400,7 +400,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
+ net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper
+ if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper
+ //player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
+- player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
++ if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
+ player.containerMenu = container;
+ player.initMenu(container);
+ }