fix: re-add default spawn option and disclude armour stands (#4240)

- Fixes #4238
This commit is contained in:
Jordan 2023-11-25 20:30:48 +00:00 committed by GitHub
parent eb63e4351d
commit cdb44d4884
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 7 deletions

View File

@ -143,6 +143,10 @@ public class EntityEventListener implements Listener {
if (area == null) {
return;
}
// Armour-stands are handled elsewhere and should not be handled by area-wide entity-spawn options
if (entity.getType() == EntityType.ARMOR_STAND) {
return;
}
CreatureSpawnEvent.SpawnReason reason = event.getSpawnReason();
switch (reason.toString()) {
case "DISPENSE_EGG", "EGG", "OCELOT_BABY", "SPAWNER_EGG" -> {
@ -153,7 +157,7 @@ public class EntityEventListener implements Listener {
}
case "REINFORCEMENTS", "NATURAL", "MOUNT", "PATROL", "RAID", "SHEARED", "SILVERFISH_BLOCK", "ENDER_PEARL",
"TRAP", "VILLAGE_DEFENSE", "VILLAGE_INVASION", "BEEHIVE", "CHUNK_GEN", "NETHER_PORTAL",
"DUPLICATION", "FROZEN", "SPELL" -> {
"DUPLICATION", "FROZEN", "SPELL", "DEFAULT" -> {
if (!area.isMobSpawning()) {
event.setCancelled(true);
return;
@ -166,7 +170,7 @@ public class EntityEventListener implements Listener {
}
}
case "BUILD_IRONGOLEM", "BUILD_SNOWMAN", "BUILD_WITHER", "CUSTOM" -> {
if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) {
if (!area.isSpawnCustom()) {
event.setCancelled(true);
return;
}

View File

@ -124,7 +124,7 @@ public class PaperListener implements Listener {
}
Slime slime = event.getEntity();
Block b = slime.getTargetBlock(4);
Block b = slime.getTargetBlockExact(4);
if (b == null) {
return;
}
@ -166,12 +166,16 @@ public class PaperListener implements Listener {
}
Location location = BukkitUtil.adapt(event.getSpawnLocation());
PlotArea area = location.getPlotArea();
if (!location.isPlotArea()) {
if (area == null) {
return;
}
//If entities are spawning... the chunk should be loaded?
// Armour-stands are handled elsewhere and should not be handled by area-wide entity-spawn options
if (event.getType() == EntityType.ARMOR_STAND) {
return;
}
// If entities are spawning... the chunk should be loaded?
Entity[] entities = event.getSpawnLocation().getChunk().getEntities();
if (entities.length > Settings.Chunk_Processor.MAX_ENTITIES) {
if (entities.length >= Settings.Chunk_Processor.MAX_ENTITIES) {
event.setShouldAbortSpawn(true);
event.setCancelled(true);
return;
@ -200,7 +204,7 @@ public class PaperListener implements Listener {
}
}
case "BUILD_IRONGOLEM", "BUILD_SNOWMAN", "BUILD_WITHER", "CUSTOM" -> {
if (!area.isSpawnCustom() && event.getType() != EntityType.ARMOR_STAND) {
if (!area.isSpawnCustom()) {
event.setShouldAbortSpawn(true);
event.setCancelled(true);
return;