SPIGOT-8041: Trying to call Beehive.addEntity with a BlockPopulator leads to IllegalStateException

This commit is contained in:
md_5 2025-04-18 11:28:49 +10:00
parent 04b1695641
commit 3b4fd5b321
No known key found for this signature in database
GPG Key ID: E8E901AC7C617C11
2 changed files with 24 additions and 7 deletions

View File

@ -386,8 +386,8 @@
public void removePlayerImmediately(EntityPlayer entityplayer, Entity.RemovalReason entity_removalreason) {
- entityplayer.remove(entity_removalreason);
+ entityplayer.remove(entity_removalreason, null); // CraftBukkit - add Bukkit remove cause
}
+ }
+
+ // CraftBukkit start
+ public boolean strikeLightning(Entity entitylightning) {
+ return this.strikeLightning(entitylightning, LightningStrikeEvent.Cause.UNKNOWN);
@ -401,9 +401,9 @@
+ }
+
+ return this.addFreshEntity(entitylightning);
+ }
}
+ // CraftBukkit end
+
@Override
public void destroyBlockProgress(int i, BlockPosition blockposition, int j) {
+ // CraftBukkit start
@ -586,16 +586,28 @@
String s1 = (String) entry.getKey();
return s1 + ":" + entry.getIntValue();
@@ -1754,6 +1978,8 @@
@@ -1716,7 +1940,11 @@
a() {}
- public void onCreated(Entity entity) {}
+ // CraftBukkit start - Mark entity as in world
+ public void onCreated(Entity entity) {
+ entity.inWorld = true;
+ // CraftBukkit end
+ }
public void onDestroyed(Entity entity) {
WorldServer.this.getScoreboard().entityRemoved(entity);
@@ -1754,6 +1982,7 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::add);
+ entity.inWorld = true; // CraftBukkit - Mark entity as in world
+ entity.valid = true; // CraftBukkit
}
public void onTrackingEnd(Entity entity) {
@@ -1780,6 +2006,14 @@
@@ -1780,6 +2009,14 @@
}
entity.updateDynamicGameEventListener(DynamicGameEventListener::remove);

View File

@ -1981,6 +1981,11 @@ public class CraftEventFactory {
return;
}
// SPIGOT-8041: Do not call event unless entity has been spawned into world
if (!entity.inWorld) {
return;
}
Bukkit.getPluginManager().callEvent(new EntityRemoveEvent(entity.getBukkitEntity(), cause));
}