Skip to content

Commit

Permalink
fix: re-add default spawn option and disclude armour stands (#4240)
Browse files Browse the repository at this point in the history
- Fixes #4238
  • Loading branch information
dordsor21 authored Nov 25, 2023
1 parent eb63e43 commit cdb44d4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
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" -> {
Expand All @@ -153,7 +157,7 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
}
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;
Expand All @@ -166,7 +170,7 @@ public void creatureSpawnEvent(CreatureSpawnEvent event) {
}
}
case "BUILD_IRONGOLEM", "BUILD_SNOWMAN", "BUILD_WITHER", "CUSTOM" -> {
if (!area.isSpawnCustom() && entity.getType() != EntityType.ARMOR_STAND) {
if (!area.isSpawnCustom()) {
event.setCancelled(true);
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void onEntityPathfind(SlimePathfindEvent event) {
}
Slime slime = event.getEntity();

Block b = slime.getTargetBlock(4);
Block b = slime.getTargetBlockExact(4);
if (b == null) {
return;
}
Expand Down Expand Up @@ -166,12 +166,16 @@ public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) {
}
Location location = BukkitUtil.adapt(event.getSpawnLocation());
PlotArea area = location.getPlotArea();
if (!location.isPlotArea()) {
if (area == null) {
return;
}
// 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?
// 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;
Expand Down Expand Up @@ -200,7 +204,7 @@ public void onPreCreatureSpawnEvent(PreCreatureSpawnEvent event) {
}
}
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;
Expand Down

0 comments on commit cdb44d4

Please sign in to comment.