Paper/Spigot-Server-Patches/0452-Prevent-opening-inventories-when-frozen.patch
Prof-Bloodstone 42433c2626
Updated Upstream (Bukkit/CraftBukkit) (#3980)
Upstream has released updates that appears to apply and compile correctly.
This update has not been tested by PaperMC and as with ANY update, please do your own testing

Bukkit Changes:
09f10fd9 SPIGOT-5950: Add PrepareSmithingEvent event

CraftBukkit Changes:
7c03d257 SPIGOT-6011: End Gateways do not work on Non-Main End Worlds
d492e363 SPIGOT-6015: Small Armor Stand doesn't drop items
5db13eea SPIGOT-5950: Add PrepareSmithingEvent event
2020-07-22 19:35:44 -04:00

60 lines
3.8 KiB
Diff

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/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index 48ee5d7beaf336f7eb440a4a8a6e3bba2321b0b9..99513a682c0b1bbe141098427883ee561a4d5e9d 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -420,7 +420,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;
}
@@ -1276,7 +1276,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);
@@ -2071,7 +2071,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 00d67c9911c52ddcdf48fda7998bcd2a8a35f0eb..75aa141e86e301254b25ede3da67513aae76fa5c 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);
}