From 50d6ee071805f6cf081b83ab9034c54bf0d787cf Mon Sep 17 00:00:00 2001 From: Nathat23 Date: Sat, 15 Apr 2023 14:42:49 +0100 Subject: [PATCH] Fix for #264 Bees coming from hives trigger creature spawn event with SpawnReason BEEHIVE, however when using Paper's Entity#getEntitySpawnReason they retain their original spawn reason. We could change it so that the spawn event uses the Paper method for checking blacklists etc, but there would be problems for spigot users, requiring checks for use of Paper. But if an entity was previously destacked - they would become stacked again. --- .../uk/antiperson/stackmob/listeners/SpawnListener.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/main/java/uk/antiperson/stackmob/listeners/SpawnListener.java b/src/main/java/uk/antiperson/stackmob/listeners/SpawnListener.java index fbdcc98f..328a8130 100644 --- a/src/main/java/uk/antiperson/stackmob/listeners/SpawnListener.java +++ b/src/main/java/uk/antiperson/stackmob/listeners/SpawnListener.java @@ -1,5 +1,6 @@ package uk.antiperson.stackmob.listeners; +import org.bukkit.entity.Bee; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Mob; @@ -23,6 +24,11 @@ public void onSpawn(CreatureSpawnEvent event) { if (!(event.getEntity() instanceof Mob)) { return; } + if (event.getEntity() instanceof Bee) { + if (event.getSpawnReason() == CreatureSpawnEvent.SpawnReason.BEEHIVE) { + return; + } + } sm.getServer().getScheduler().runTask(sm, () -> { if (sm.getEntityManager().isStackedEntity(event.getEntity())) { StackEntity stackEntity = sm.getEntityManager().getStackEntity(event.getEntity());