feat: remove projected entity out of projection

This commit is contained in:
xtex 2023-07-02 12:00:35 +08:00
parent 5ae62c00d0
commit f4799eca51
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -16,6 +16,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes
import net.minecraft.world.level.Level
import net.minecraft.world.level.ServerLevelAccessor
import quaedam.Quaedam
import quaedam.projector.Projector
class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Level) :
PathfinderMob(entityType, level) {
@ -106,4 +107,17 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
override fun createNavigation(level: Level) = ProjectedPersonNavigation(this, level)
override fun tick() {
super.tick()
if (tickCount % 20 == 0) {
tickProjectionCheck()
}
}
private fun tickProjectionCheck() {
if (Projector.findNearbyProjections(level(), blockPosition(), SwarmProjection.effect.get()).isEmpty()) {
remove(RemovalReason.KILLED)
}
}
}