From ea3ebea7e1ba5877b2a512afefe7d31a96351b7c Mon Sep 17 00:00:00 2001 From: booky10 Date: Tue, 26 Dec 2023 05:08:58 +0100 Subject: [PATCH] Simplify shulkerbox-opening-bug patch --- ...e-synced-opencount-for-shulker-boxes.patch | 23 +++++++ .../0013-Save-shulker-box-openers.patch | 61 ------------------- 2 files changed, 23 insertions(+), 61 deletions(-) create mode 100644 patches/server/0013-Don-t-apply-de-synced-opencount-for-shulker-boxes.patch delete mode 100644 patches/server/0013-Save-shulker-box-openers.patch diff --git a/patches/server/0013-Don-t-apply-de-synced-opencount-for-shulker-boxes.patch b/patches/server/0013-Don-t-apply-de-synced-opencount-for-shulker-boxes.patch new file mode 100644 index 0000000..3f42777 --- /dev/null +++ b/patches/server/0013-Don-t-apply-de-synced-opencount-for-shulker-boxes.patch @@ -0,0 +1,23 @@ +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 +From: booky10 +Date: Tue, 21 Mar 2023 15:24:33 +0100 +Subject: [PATCH] Don't apply de-synced opencount for shulker boxes + +Would bug out when opening a shulker box multiple times in a tick, caused by ping or fast clicking. + +The issue is caused by how block events in minecraft work. Just commenting this line out prevents +the wrong data from being set - there isn't a reason to do this on the server anyway. + +diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +index 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..89c0fbe124cdb9a2f2ed2253eece86c755504f1d 100644 +--- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java ++++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java +@@ -179,7 +179,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl + @Override + public boolean triggerEvent(int type, int data) { + if (type == 1) { +- this.openCount = data; ++ // this.openCount = data; // CloudPlane + if (data == 0) { + this.animationStatus = ShulkerBoxBlockEntity.AnimationStatus.CLOSING; + } diff --git a/patches/server/0013-Save-shulker-box-openers.patch b/patches/server/0013-Save-shulker-box-openers.patch deleted file mode 100644 index c791862..0000000 --- a/patches/server/0013-Save-shulker-box-openers.patch +++ /dev/null @@ -1,61 +0,0 @@ -From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 -From: booky10 -Date: Tue, 21 Mar 2023 15:24:33 +0100 -Subject: [PATCH] Save shulker box openers - -Would bug out when opening a shulker box multiple times in a tick, caused by ping or fast clicking - -diff --git a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -index 1fa22445a4ecc8c08dbcf0cc6bd39dc5003604c4..7f5ee798a5ea8c8ac4a9b2dc1d0f81475f9672a0 100644 ---- a/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -+++ b/src/main/java/net/minecraft/world/level/block/entity/ShulkerBoxBlockEntity.java -@@ -48,7 +48,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl - public static final String ITEMS_TAG = "Items"; - private static final int[] SLOTS = IntStream.range(0, 27).toArray(); - private NonNullList itemStacks; -- public int openCount; -+ public java.util.Collection openers = new org.bukkit.craftbukkit.util.WeakCollection<>(); // CloudPlane - private ShulkerBoxBlockEntity.AnimationStatus animationStatus; - private float progress; - private float progressOld; -@@ -179,7 +179,7 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl - @Override - public boolean triggerEvent(int type, int data) { - if (type == 1) { -- this.openCount = data; -+ // this.openCount = data; // CloudPlane - if (data == 0) { - this.animationStatus = ShulkerBoxBlockEntity.AnimationStatus.CLOSING; - } -@@ -202,14 +202,10 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl - @Override - public void startOpen(Player player) { - if (!this.remove && !player.isSpectator()) { -- if (this.openCount < 0) { -- this.openCount = 0; -- } -- -- ++this.openCount; -+ this.openers.add(player); // CloudPlane - if (this.opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. -- this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); -- if (this.openCount == 1) { -+ this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openers.size()); // CloudPlane -+ if (this.openers.size() == 1) { // CloudPlane - this.level.gameEvent((Entity) player, GameEvent.CONTAINER_OPEN, this.worldPosition); - this.level.playSound((Player) null, this.worldPosition, SoundEvents.SHULKER_BOX_OPEN, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F); - } -@@ -220,10 +216,10 @@ public class ShulkerBoxBlockEntity extends RandomizableContainerBlockEntity impl - @Override - public void stopOpen(Player player) { - if (!this.remove && !player.isSpectator()) { -- --this.openCount; -+ this.openers.remove(player); // CloudPlane - if (this.opened) return; // CraftBukkit - only animate if the ShulkerBox hasn't been forced open already by an API call. -- this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openCount); -- if (this.openCount <= 0) { -+ this.level.blockEvent(this.worldPosition, this.getBlockState().getBlock(), 1, this.openers.size()); // CloudPlane -+ if (this.openers.isEmpty()) { // CloudPlane - this.level.gameEvent((Entity) player, GameEvent.CONTAINER_CLOSE, this.worldPosition); - this.level.playSound((Player) null, this.worldPosition, SoundEvents.SHULKER_BOX_CLOSE, SoundSource.BLOCKS, 0.5F, this.level.random.nextFloat() * 0.1F + 0.9F); - }