2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
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/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
2024-04-12 21:14:06 +02:00
index 04e54d2214d0ae0202490aceab54b8b10ef38229..3a856f28237246660665aef983e5e9fe2bac8c37 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
2024-01-24 13:07:40 +01:00
@@ -653,7 +653,7 @@ public class ServerPlayer extends Player {
2023-06-08 00:41:25 +02:00
containerUpdateDelay = this.level().paperConfig().tickRates.containerUpdate;
2021-06-11 14:02:28 +02:00
}
2024-01-24 11:45:17 +01:00
// Paper end - Configurable container update tick rate
2023-06-08 00:41:25 +02:00
- if (!this.level().isClientSide && !this.containerMenu.stillValid(this)) {
2024-01-21 12:11:43 +01:00
+ if (!this.level().isClientSide && this.containerMenu != this.inventoryMenu && (this.isImmobile() || !this.containerMenu.stillValid(this))) { // Paper - Prevent opening inventories when frozen
2024-01-21 19:37:09 +01:00
this.closeContainer(org.bukkit.event.inventory.InventoryCloseEvent.Reason.CANT_USE); // Paper - Inventory close reason
2021-06-11 14:02:28 +02:00
this.containerMenu = this.inventoryMenu;
}
2024-01-24 13:07:40 +01:00
@@ -1508,7 +1508,7 @@ public class ServerPlayer extends Player {
2021-06-11 14:02:28 +02:00
} else {
// CraftBukkit start
this.containerMenu = container;
- this.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(), container.getTitle()));
2024-01-21 12:11:43 +01:00
+ if (!this.isImmobile()) this.connection.send(new ClientboundOpenScreenPacket(container.containerId, container.getType(), container.getTitle())); // Paper - Prevent opening inventories when frozen
2021-06-11 14:02:28 +02:00
// CraftBukkit end
2021-06-14 03:06:38 +02:00
this.initMenu(container);
2021-06-11 14:02:28 +02:00
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
2024-04-06 21:53:39 +02:00
index 0886cb3367022c4ab7e4dbebafb70fc651bcb9aa..35f03bea2b1206b420ac46dfd77811fb485c5319 100644
2021-06-11 14:02:28 +02:00
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftHumanEntity.java
2024-04-06 21:53:39 +02:00
@@ -328,7 +328,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
2022-05-26 21:12:14 +02:00
if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(container.getBukkitView().getTitle()); // Paper
2021-06-11 14:02:28 +02:00
2022-06-11 11:02:09 +02:00
//player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
2021-06-11 14:02:28 +02:00
- player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
2024-01-21 12:11:43 +01:00
+ if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper - Prevent opening inventories when frozen
2021-06-14 03:06:38 +02:00
player.containerMenu = container;
player.initMenu(container);
2021-06-11 14:02:28 +02:00
}
2024-04-06 21:53:39 +02:00
@@ -402,7 +402,7 @@ public class CraftHumanEntity extends CraftLivingEntity implements HumanEntity {
2021-06-11 14:02:28 +02:00
net.kyori.adventure.text.Component adventure$title = inventory.title(); // Paper
2022-05-26 21:12:14 +02:00
if (adventure$title == null) adventure$title = net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer.legacySection().deserialize(inventory.getTitle()); // Paper
2022-06-11 11:02:09 +02:00
//player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, CraftChatMessage.fromString(title)[0])); // Paper - comment
2021-06-11 14:02:28 +02:00
- player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper
2024-01-21 12:11:43 +01:00
+ if (!player.isImmobile()) player.connection.send(new ClientboundOpenScreenPacket(container.containerId, windowType, io.papermc.paper.adventure.PaperAdventure.asVanilla(adventure$title))); // Paper - Prevent opening inventories when frozen
2021-06-11 14:02:28 +02:00
player.containerMenu = container;
2021-06-14 03:06:38 +02:00
player.initMenu(container);
2021-06-11 14:02:28 +02:00
}