Skip to content

Commit 9ec6c46

Browse files
committed
[EntityCulling] Fix occlude detect on some shaped blocks
1 parent f139c9c commit 9ec6c46

File tree

1 file changed

+4
-3
lines changed
  • bukkit/version/v1_18/src/main/kotlin/io/github/rothes/esu/bukkit/module/networkthrottle/entityculling/v1_18

1 file changed

+4
-3
lines changed

bukkit/version/v1_18/src/main/kotlin/io/github/rothes/esu/bukkit/module/networkthrottle/entityculling/v1_18/RaytraceHandlerImpl.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import io.github.rothes.esu.core.module.Feature
2222
import io.github.rothes.esu.core.module.configuration.EmptyConfiguration
2323
import io.github.rothes.esu.core.user.User
2424
import io.github.rothes.esu.core.util.UnsafeUtils.usBooleanAccessor
25+
import io.github.rothes.esu.core.util.UnsafeUtils.usNullableObjAccessor
2526
import io.github.rothes.esu.core.util.extension.math.floorI
2627
import io.github.rothes.esu.core.util.extension.math.frac
2728
import io.github.rothes.esu.core.util.extension.math.square
@@ -76,8 +77,8 @@ object RaytraceHandlerImpl: RaytraceHandler<RaytraceHandlerImpl.RaytraceConfig,
7677
private val playerVelocityGetter by Versioned(PlayerVelocityGetter::class.java)
7778
private val entityHandleGetter by Versioned(EntityHandleGetter::class.java)
7879

79-
private val shapedOcclusion = BlockBehaviour.BlockStateBase::class.java.getDeclaredField("useShapeForLightOcclusion").usBooleanAccessor
8080
private val canOcclude = BlockBehaviour.BlockStateBase::class.java.getDeclaredField("canOcclude").usBooleanAccessor
81+
private val bsCache = BlockBehaviour.BlockStateBase::class.java.getDeclaredField("cache").usNullableObjAccessor
8182

8283
private var raytracer: RayTracer = StepRayTracer
8384
private var forceVisibleDistanceSquared = 0.0
@@ -430,7 +431,7 @@ object RaytraceHandlerImpl: RaytraceHandler<RaytraceHandlerImpl.RaytraceConfig,
430431

431432
if (section != null) { // It can never be null, but we don't want the kotlin npe check!
432433
val blockState = section.get((currX and 15) or ((currZ and 15) shl 4) or ((currY and 15) shl (4 + 4)))
433-
if (!shapedOcclusion[blockState] && canOcclude[blockState])
434+
if (canOcclude[blockState] && bsCache[blockState] != null && blockState.isCollisionShapeFullBlock(null, null))
434435
return true
435436
}
436437
}
@@ -511,7 +512,7 @@ object RaytraceHandlerImpl: RaytraceHandler<RaytraceHandlerImpl.RaytraceConfig,
511512

512513
if (section != null) {
513514
val blockState = section.get((currX and 15) or ((currZ and 15) shl 4) or ((currY and 15) shl (4 + 4)))
514-
if (!shapedOcclusion[blockState] && canOcclude[blockState])
515+
if (canOcclude[blockState] && bsCache[blockState] != null && blockState.isCollisionShapeFullBlock(null, null))
515516
return true
516517
}
517518

0 commit comments

Comments
 (0)