feat: navigate in projected area

This commit is contained in:
xtex 2023-07-02 11:55:38 +08:00
parent 3f168dbd8e
commit 5ae62c00d0
Signed by: xtex
GPG Key ID: B918086ED8045B91
2 changed files with 20 additions and 0 deletions

View File

@ -104,4 +104,6 @@ class ProjectedPersonEntity(entityType: EntityType<out PathfinderMob>, level: Le
override fun getNameTagOffsetY() = super.getNameTagOffsetY() - (BOUNDING_HEIGHT * (1.2f - shape.scaleY))
override fun createNavigation(level: Level) = ProjectedPersonNavigation(this, level)
}

View File

@ -0,0 +1,18 @@
package quaedam.projection.swarm
import net.minecraft.core.BlockPos
import net.minecraft.world.entity.ai.navigation.GroundPathNavigation
import net.minecraft.world.level.Level
import net.minecraft.world.level.pathfinder.Path
import quaedam.projector.Projector
class ProjectedPersonNavigation(val entity: ProjectedPersonEntity, level: Level) : GroundPathNavigation(entity, level) {
override fun createPath(set: MutableSet<BlockPos>, i: Int, bl: Boolean, j: Int, f: Float): Path? {
if (set.any { Projector.findNearbyProjections(level, it, SwarmProjection.effect.get()).isEmpty() }) {
return null
}
return super.createPath(set, i, bl, j, f)
}
}