Skip to content

Commit

Permalink
only cancel if would be successful spawn
Browse files Browse the repository at this point in the history
  • Loading branch information
Gutin1 committed Jan 25, 2025
1 parent 754c98c commit 0d6c4b1
Showing 1 changed file with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ class CustomMobSpawner(val world: IonWorld, mobs: List<WorldSettings.SpawnedMob>
if (event.entity !is Monster) return
if (event.entity.persistentDataContainer.get(CUSTOM_ENTITY, BOOLEAN) == true) return

event.isCancelled = true

val location = event.location

val mob = mobs.weightedRandomOrNull { it.spawningWeight } ?: return

if (!mob.function.get()) return

event.isCancelled = true

val name = mob.namePool.entries.weightedRandomOrNull { it.value }

world.world.spawnEntity(location, mob.getEntityType(), CreatureSpawnEvent.SpawnReason.NATURAL) { entity ->
Expand Down

0 comments on commit 0d6c4b1

Please sign in to comment.