Start prep for shadow lighting rework

This commit is contained in:
Mike Primm 2022-01-30 14:23:00 -06:00
parent fd420f739f
commit e22ad9b8bf
6 changed files with 96 additions and 3 deletions

View File

@ -128,6 +128,26 @@ public abstract class GenericMapChunkCache extends MapChunkCache {
return (emit << 8) + sky;
}
@Override
/**
* Get block sky and emitted light, relative to current coordinate
* @return (emitted light * 256) + sky light
*/
public final int getBlockLight(int xoff, int yoff, int zoff) {
int emit = 0, sky = 15;
int nx = x + xoff;
int ny = y + yoff;
int nz = z + zoff;
GenericChunkSection sect;
int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim);
if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) {
sect = snaparray[nchunkindex].getSection(ny);
emit = sect.emitted.getLight(nx, ny, nz);
sky = sect.sky.getLight(nx, ny, nz);
}
return (emit << 8) + sky;
}
@Override
public final BiomeMap getBiome() {
try {
return snap.getBiome(bx, y, bz);

View File

@ -31,6 +31,14 @@ public interface MapIterator extends MapDataContext {
* @return (emitted light * 256) + sky light
*/
int getBlockLight(BlockStep step);
/**
* Get block sky and emitted light, relative to current coordinate
* @param xoff - x offset from current position
* @param yoff - y offset from current position
* @param zoff - z offset from current position
* @return (emitted light * 256) + sky light
*/
int getBlockLight(int xoff, int yoff, int zoff);
/**
* Get biome at coordinates
* @return biome

View File

@ -14,9 +14,6 @@ import org.dynmap.DynmapChunk;
import org.dynmap.DynmapCore;
import org.dynmap.DynmapWorld;
import org.dynmap.Log;
import org.dynmap.bukkit.helper.BukkitVersionHelper;
import org.dynmap.bukkit.helper.BukkitWorld;
import org.dynmap.bukkit.helper.SnapshotCache;
import org.dynmap.bukkit.helper.SnapshotCache.SnapshotRec;
import org.dynmap.common.BiomeMap;
import org.dynmap.hdmap.HDBlockModels;
@ -181,6 +178,23 @@ public abstract class AbstractMapChunkCache extends MapChunkCache {
}
return (emit << 8) + sky;
}
@Override
/**
* Get block sky and emitted light, relative to current coordinate
* @return (emitted light * 256) + sky light
*/
public final int getBlockLight(int xoff, int yoff, int zoff) {
int emit = 0, sky = 15;
int nx = x + xoff;
int ny = y + yoff;
int nz = z + zoff;
int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim);
if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) {
emit = snaparray[nchunkindex].getBlockEmittedLight(nx, ny, nz);
sky = snaparray[nchunkindex].getBlockSkyLight(nx, ny, nz);
}
return (emit << 8) + sky;
}
private void biomePrep() {
if(sameneighborbiomecnt != null)

View File

@ -201,6 +201,23 @@ public class ForgeMapChunkCache extends MapChunkCache
}
return (emit << 8) + sky;
}
@Override
/**
* Get block sky and emitted light, relative to current coordinate
* @return (emitted light * 256) + sky light
*/
public final int getBlockLight(int xoff, int yoff, int zoff) {
int emit = 0, sky = 15;
int nx = x + xoff;
int ny = y + yoff;
int nz = z + zoff;
int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim);
if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) {
emit = snaparray[nchunkindex].getBlockEmittedLight(nx, ny, nz);
sky = snaparray[nchunkindex].getBlockSkyLight(nx, ny, nz);
}
return (emit << 8) + sky;
}
private void biomePrep()
{

View File

@ -197,6 +197,23 @@ public class ForgeMapChunkCache extends MapChunkCache
}
return (emit << 8) + sky;
}
@Override
/**
* Get block sky and emitted light, relative to current coordinate
* @return (emitted light * 256) + sky light
*/
public final int getBlockLight(int xoff, int yoff, int zoff) {
int emit = 0, sky = 15;
int nx = x + xoff;
int ny = y + yoff;
int nz = z + zoff;
int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim);
if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) {
emit = snaparray[nchunkindex].getBlockEmittedLight(nx, ny, nz);
sky = snaparray[nchunkindex].getBlockSkyLight(nx, ny, nz);
}
return (emit << 8) + sky;
}
private void biomePrep()
{

View File

@ -197,6 +197,23 @@ public class ForgeMapChunkCache extends MapChunkCache
}
return (emit << 8) + sky;
}
@Override
/**
* Get block sky and emitted light, relative to current coordinate
* @return (emitted light * 256) + sky light
*/
public final int getBlockLight(int xoff, int yoff, int zoff) {
int emit = 0, sky = 15;
int nx = x + xoff;
int ny = y + yoff;
int nz = z + zoff;
int nchunkindex = ((nx >> 4) - x_min) + (((nz >> 4) - z_min) * x_dim);
if ((nchunkindex < snapcnt) && (nchunkindex >= 0)) {
emit = snaparray[nchunkindex].getBlockEmittedLight(nx, ny, nz);
sky = snaparray[nchunkindex].getBlockSkyLight(nx, ny, nz);
}
return (emit << 8) + sky;
}
private void biomePrep()
{