fix: drop equipment

This commit is contained in:
xtex 2023-07-03 16:03:21 +08:00
parent 16a2728ac1
commit f5b1372693
Signed by: xtex
GPG Key ID: B918086ED8045B91
2 changed files with 14 additions and 3 deletions

View File

@ -158,7 +158,10 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
override fun tick() { override fun tick() {
super.tick() super.tick()
if (tickCount % 20 == 0) { if (tickCount % 20 == 0) {
if (!checkProjectionEffect()) remove(RemovalReason.KILLED) if (!checkProjectionEffect()) {
dropEquipment()
remove(RemovalReason.KILLED)
}
} }
} }
@ -167,7 +170,10 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
override fun checkDespawn() { override fun checkDespawn() {
super.checkDespawn() super.checkDespawn()
if (!checkProjectionEffect()) remove(RemovalReason.KILLED) if (!checkProjectionEffect()) {
dropEquipment()
remove(RemovalReason.KILLED)
}
} }
private val inventory = SimpleContainer(10) private val inventory = SimpleContainer(10)
@ -217,4 +223,9 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
brain.eraseMemory(MemoryModuleType.HOME) brain.eraseMemory(MemoryModuleType.HOME)
} }
override fun dropEquipment() {
super.dropEquipment()
inventory.removeAllItems().forEach(::spawnAtLocation)
}
} }

View File

@ -10,7 +10,7 @@ import quaedam.projector.ProjectorBlockEntity
import kotlin.math.min import kotlin.math.min
data class SwarmProjectionEffect( data class SwarmProjectionEffect(
var maxCount: Int = 100, var maxCount: Int = 180,
) : ProjectionEffect() { ) : ProjectionEffect() {
companion object { companion object {