Skip to content

Commit

Permalink
MobKiller: Only iterate over nearby entities
Browse files Browse the repository at this point in the history
  • Loading branch information
NichtStudioCode committed Nov 17, 2024
1 parent 6ccc152 commit 39ea846
Showing 1 changed file with 2 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ class MobKiller(pos: BlockPos, blockState: NovaBlockState, data: Compound) : Net

val killLimit = min((energyHolder.energy / energyPerDamage).toInt(), KILL_LIMIT)

pos.world.entities
.asSequence()
pos.world.getNearbyEntities(region.toBoundingBox()).asSequence()
.filterIsInstance<Mob>()
.filter { it.location in region && runBlocking { ProtectionManager.canHurtEntity(this@MobKiller, it, null) } } // TODO non-blocking
.filter { runBlocking { ProtectionManager.canHurtEntity(this@MobKiller, it, null) } } // TODO non-blocking
.take(killLimit)
.forEach { entity ->
// TODO: custom damage type
Expand Down

0 comments on commit 39ea846

Please sign in to comment.