camera fluid check never loads the chunk at the eye (an eye in an unloaded chunk loaded it synchronously in prepare: 204 ms, now 13 ms)
This commit is contained in:
1 parent
c75c7a4b60
commit
a082271f28
1 file changed
+10
-1
@@ -39,7 +39,9 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.stream.IntStream;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
@@ -167,8 +169,15 @@ public class DefaultScreenRenderer {
|
||||
return SnapshotBuilder.chunkArea(eyeLocation, FrustumBounds.of(eyeLocation, rayMap, MAX_DISTANCE), 2);
|
||||
}
|
||||
|
||||
/** The fluid at the eye; an unloaded chunk counts as air (never loads one, see {@link SnapshotBuilder}). */
|
||||
private static int cameraFluid(Location eye) {
|
||||
return FluidRenderer.cameraFluid(eye.getWorld()::getBlockData, eye.getX(), eye.getY(), eye.getZ());
|
||||
World world = eye.getWorld();
|
||||
BlockData air = Material.AIR.createBlockData();
|
||||
return FluidRenderer.cameraFluid(
|
||||
(x, y, z) -> world.isChunkLoaded(x >> 4, z >> 4) ? world.getBlockData(x, y, z) : air,
|
||||
eye.getX(),
|
||||
eye.getY(),
|
||||
eye.getZ());
|
||||
}
|
||||
|
||||
private static RayMap rayMap(Location eye, int width, int height, int cameraFluid) {
|
||||
|
||||
Reference in new issue
Block a user