From f5b1372693ce5da1bb6c0c30a98526ab2c332239 Mon Sep 17 00:00:00 2001 From: xtex Date: Mon, 3 Jul 2023 16:03:21 +0800 Subject: [PATCH] fix: drop equipment --- .../projection/swarm/ProjectedPersonEntity.kt | 15 +++++++++++++-- .../projection/swarm/SwarmProjectionEffect.kt | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt index a573480..1a14781 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/ProjectedPersonEntity.kt @@ -158,7 +158,10 @@ class ProjectedPersonEntity(entityType: EntityType, level: Le override fun tick() { super.tick() if (tickCount % 20 == 0) { - if (!checkProjectionEffect()) remove(RemovalReason.KILLED) + if (!checkProjectionEffect()) { + dropEquipment() + remove(RemovalReason.KILLED) + } } } @@ -167,7 +170,10 @@ class ProjectedPersonEntity(entityType: EntityType, level: Le override fun checkDespawn() { super.checkDespawn() - if (!checkProjectionEffect()) remove(RemovalReason.KILLED) + if (!checkProjectionEffect()) { + dropEquipment() + remove(RemovalReason.KILLED) + } } private val inventory = SimpleContainer(10) @@ -217,4 +223,9 @@ class ProjectedPersonEntity(entityType: EntityType, level: Le brain.eraseMemory(MemoryModuleType.HOME) } + override fun dropEquipment() { + super.dropEquipment() + inventory.removeAllItems().forEach(::spawnAtLocation) + } + } \ No newline at end of file diff --git a/common/src/main/kotlin/quaedam/projection/swarm/SwarmProjectionEffect.kt b/common/src/main/kotlin/quaedam/projection/swarm/SwarmProjectionEffect.kt index 01683ea..ec3b66d 100644 --- a/common/src/main/kotlin/quaedam/projection/swarm/SwarmProjectionEffect.kt +++ b/common/src/main/kotlin/quaedam/projection/swarm/SwarmProjectionEffect.kt @@ -10,7 +10,7 @@ import quaedam.projector.ProjectorBlockEntity import kotlin.math.min data class SwarmProjectionEffect( - var maxCount: Int = 100, + var maxCount: Int = 180, ) : ProjectionEffect() { companion object {