fix: projection people spawn on ocean surface

This commit is contained in:
xtex 2023-07-27 16:42:15 +08:00
parent cb9102be74
commit ca87f6704c
Signed by: xtex
GPG Key ID: B918086ED8045B91

View File

@ -45,7 +45,11 @@ data class SwarmProjectionEffect(
level.random.nextInt(area.minZ(), area.maxZ()),
)
spawnPos = spawnPos.atY(level.getHeight(Heightmap.Types.WORLD_SURFACE, spawnPos.x, spawnPos.z))
if (level.getBlockState(spawnPos.below()).isAir)
val belowState = level.getBlockState(spawnPos.below())
if (belowState.isAir || !belowState.fluidState.isEmpty || !belowState.canOcclude())
return
val state = level.getBlockState(spawnPos)
if (state.canOcclude() || !state.fluidState.isEmpty)
return
ProjectedPersonEntity.entity.get().spawn(level, spawnPos, MobSpawnType.TRIGGERED)
}