Prevent ContainerOpenersCounter openCount from going negative

This commit is contained in:
Shane Freeder 2021-11-30 05:30:35 +00:00
parent 0919b52439
commit c472c71eca

View File

@ -45,11 +45,12 @@
if (i == 0) {
this.onOpen(world, pos, state);
world.gameEvent((Entity) player, (Holder) GameEvent.CONTAINER_OPEN, pos);
@@ -42,8 +68,19 @@
@@ -42,8 +68,20 @@
}
public void decrementOpeners(Player player, Level world, BlockPos pos, BlockState state) {
+ int oldPower = Math.max(0, Math.min(15, this.openCount)); // CraftBukkit - Get power before new viewer is added
+ if (this.openCount == 0) return; // Paper - Prevent ContainerOpenersCounter openCount from going negative
int i = this.openCount--;
+ // CraftBukkit start - Call redstone event
@ -65,7 +66,7 @@
if (this.openCount == 0) {
this.onClose(world, pos, state);
world.gameEvent((Entity) player, (Holder) GameEvent.CONTAINER_CLOSE, pos);
@@ -72,6 +109,7 @@
@@ -72,6 +110,7 @@
}
int i = list.size();