use of org.terasology.world.chunks.LitChunk in project Terasology by MovingBlocks.
the class WorldProviderCoreImpl method getSunlight.
@Override
public byte getSunlight(int x, int y, int z) {
Vector3i chunkPos = ChunkMath.calcChunkPos(x, y, z);
LitChunk chunk = chunkProvider.getChunk(chunkPos);
if (chunk != null) {
Vector3i blockPos = ChunkMath.calcBlockPos(x, y, z);
return chunk.getSunlight(blockPos);
}
return 0;
}
use of org.terasology.world.chunks.LitChunk in project Terasology by MovingBlocks.
the class WorldProviderCoreImpl method getLight.
@Override
public byte getLight(int x, int y, int z) {
Vector3i chunkPos = ChunkMath.calcChunkPos(x, y, z);
LitChunk chunk = chunkProvider.getChunk(chunkPos);
if (chunk != null) {
Vector3i blockPos = ChunkMath.calcBlockPos(x, y, z);
return chunk.getLight(blockPos);
}
return 0;
}
use of org.terasology.world.chunks.LitChunk in project Terasology by MovingBlocks.
the class WorldProviderCoreImpl method getTotalLight.
@Override
public byte getTotalLight(int x, int y, int z) {
Vector3i chunkPos = ChunkMath.calcChunkPos(x, y, z);
LitChunk chunk = chunkProvider.getChunk(chunkPos);
if (chunk != null) {
Vector3i blockPos = ChunkMath.calcBlockPos(x, y, z);
return (byte) Math.max(chunk.getSunlight(blockPos), chunk.getLight(blockPos));
}
return 0;
}
use of org.terasology.world.chunks.LitChunk in project Terasology by MovingBlocks.
the class LightMerger method merge.
private void merge(Chunk chunk) {
Chunk[] localChunks = assembleLocalChunks(chunk);
localChunks[CENTER_INDEX] = chunk;
List<BatchPropagator> propagators = Lists.newArrayList();
propagators.add(new StandardBatchPropagator(new LightPropagationRules(), new LocalChunkView(localChunks, lightRules)));
PropagatorWorldView regenWorldView = new LocalChunkView(localChunks, sunlightRegenRules);
PropagationRules sunlightRules = new SunlightPropagationRules(regenWorldView);
PropagatorWorldView sunlightWorldView = new LocalChunkView(localChunks, sunlightRules);
BatchPropagator sunlightPropagator = new StandardBatchPropagator(sunlightRules, sunlightWorldView);
propagators.add(new SunlightRegenBatchPropagator(sunlightRegenRules, regenWorldView, sunlightPropagator, sunlightWorldView));
propagators.add(sunlightPropagator);
for (BatchPropagator propagator : propagators) {
// Propagate Inwards
for (Side side : Side.values()) {
Vector3i adjChunkPos = side.getAdjacentPos(chunk.getPosition());
LitChunk adjChunk = chunkProvider.getChunkUnready(adjChunkPos);
if (adjChunk != null) {
propagator.propagateBetween(adjChunk, chunk, side.reverse(), false);
}
}
// Propagate Outwards
for (Side side : Side.values()) {
Vector3i adjChunkPos = side.getAdjacentPos(chunk.getPosition());
LitChunk adjChunk = chunkProvider.getChunk(adjChunkPos);
if (adjChunk != null) {
propagator.propagateBetween(chunk, adjChunk, side, true);
}
}
}
for (BatchPropagator propagator : propagators) {
propagator.process();
}
chunk.deflateSunlight();
}
Aggregations