Folia/patches/server/0017-Fix-destroying-beehive-without-any-players-nearby-th.patch
Spottedleaf f8a17538e6 Fix destroying beehive without any players nearby throwing an exception
If the player moves out of range by the time the block is destroyed,
then the exception would throw and remove the player from the world

Additionally, when players fail to tick instead of removing
the player from the world, kick them to prevent a limbo state
2023-04-03 21:26:16 -07:00

26 lines
1.3 KiB
Diff

From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Spottedleaf <Spottedleaf@users.noreply.github.com>
Date: Mon, 3 Apr 2023 21:14:19 -0700
Subject: [PATCH] Fix destroying beehive without any players nearby throwing an
exception
If the player moves out of range by the time the block is destroyed,
then the exception would throw and remove the player from the world
diff --git a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
index 7867333757c300cd52110c2cf5d0a5bb19f9505d..f28d5fd2510424f2ed5232a4f16b2c4d55b8ecf3 100644
--- a/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/BeehiveBlock.java
@@ -98,6 +98,11 @@ public class BeehiveBlock extends BaseEntityBlock {
if (!list.isEmpty()) {
List<Player> list1 = world.getEntitiesOfClass(Player.class, (new AABB(pos)).inflate(8.0D, 6.0D, 8.0D));
+ // Folia start - if there are no players nearby, then nextInt() will throw
+ if (list1.isEmpty()) {
+ return;
+ }
+ // Folia end - if there are no players nearby, then nextInt() will throw
int i = list1.size();
Iterator iterator = list.iterator();