@@ -39,6 +39,7 @@ import net.minecraft.world.level.block.state.BlockBehaviour
3939import net.minecraft.world.level.block.state.BlockState
4040import net.minecraft.world.level.chunk.LevelChunkSection
4141import net.minecraft.world.level.chunk.PalettedContainer
42+ import net.minecraft.world.phys.AABB
4243import net.minecraft.world.phys.Vec3
4344import org.bukkit.Bukkit
4445import org.bukkit.Location
@@ -276,6 +277,9 @@ object RaytraceHandlerImpl: RaytraceHandler<RaytraceHandlerImpl.RaytraceConfig,
276277 val playerY = player.y
277278 val playerZ = player.z
278279
280+ val playerGridX = playerX.floorI() shr 8
281+ val playerGridZ = playerZ.floorI() shr 8
282+
279283 val shouldCull = userCullData.shouldCull
280284 val predicatedPlayerPos = if (shouldCull && config.predicatePlayerPositon) {
281285 val velocity = playerVelocityGetter.getPlayerMoveVelocity(player)
@@ -315,24 +319,23 @@ object RaytraceHandlerImpl: RaytraceHandler<RaytraceHandlerImpl.RaytraceConfig,
315319
316320 if (
317321 ! shouldCull
322+ || dist + (playerY - pos.y).square() <= forceVisibleDistanceSquared
318323 || entity.isCurrentlyGlowing
319324 || config.visibleEntityTypes.contains(entity.type)
320- || dist + (playerY - pos.y).square() <= forceVisibleDistanceSquared
321325 ) {
322326 userCullData.setCulled(entity.bukkitEntity, entity.id, false )
323327 continue
324328 }
325329
326- userCullData.setCulled(entity.bukkitEntity, entity.id, raytrace(player, predicatedPlayerPos, entity, level))
330+ userCullData.setCulled(entity.bukkitEntity, entity.id, raytrace(player, predicatedPlayerPos, entity.boundingBox , level))
327331 }
328332 }
329333 userCullData.shouldCull = tickedEntities >= config.cullThreshold
330334 userCullData.tick()
331335 }
332336
333- fun raytrace (player : ServerPlayer , predPlayer : Vec3 ? , entity : Entity , level : ServerLevel ): Boolean {
337+ fun raytrace (player : ServerPlayer , predPlayer : Vec3 ? , aabb : AABB , level : ServerLevel ): Boolean {
334338 val from = player.eyePosition
335- val aabb = entity.boundingBox
336339
337340 val isXMin = abs(from.x - aabb.minX) < abs(from.x - aabb.maxX)
338341 val isYMin = abs(from.y - aabb.minY) < abs(from.y - aabb.maxY)
0 commit comments