mirror of
https://github.com/webbukkit/dynmap.git
synced 2025-02-25 00:02:03 +01:00
Implement basic sky lighting for chunks with broken lighting
(forge,fabric)
This commit is contained in:
parent
05819b1b74
commit
3a3a970883
@ -119,23 +119,31 @@ public class GenericChunk {
|
||||
int sky[] = new int[256]; // ZX array
|
||||
Arrays.fill(sky, 15); // Start fully lit at top
|
||||
GenericChunkSection.Builder bld = new GenericChunkSection.Builder();
|
||||
boolean allzero = false;
|
||||
// Make light array for each section, start from top
|
||||
for (int i = (sections.length - 1); i >= 0; i--) {
|
||||
if (sections[i] == null) continue;
|
||||
byte[] ssky = new byte[2048];
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int idx = (z << 4) + x;
|
||||
for (int y = 15; y >= 0; y--) {
|
||||
DynmapBlockState bs = sections[i].blocks.getBlock(x, y, z); // Get block
|
||||
int atten = bs.lightAttenuation;
|
||||
sky[idx] = (sky[idx] > atten) ? (sky[idx] - atten) : 0;
|
||||
ssky[(y << 7) | (z << 3) | (x >> 1)] |= (sky[idx] << (4 * (x & 1)));
|
||||
byte[] ssky = new byte[2048];
|
||||
if (!allzero) {
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
int idx = (z << 4) + x;
|
||||
for (int y = 15; y >= 0; y--) {
|
||||
DynmapBlockState bs = sections[i].blocks.getBlock(x, y, z); // Get block
|
||||
int atten = bs.getLightAttenuation();
|
||||
sky[idx] = (sky[idx] >= atten) ? (sky[idx] - atten) : 0;
|
||||
ssky[(y << 7) | (z << 3) | (x >> 1)] |= (sky[idx] << (4 * (x & 1)));
|
||||
}
|
||||
}
|
||||
}
|
||||
// Check if we're all dark
|
||||
allzero = true;
|
||||
for (int v = 0; v < 256; v++) {
|
||||
if (sky[v] > 0) { allzero = false; break; }
|
||||
}
|
||||
}
|
||||
// Replace section with new one with new lighting
|
||||
sections[i] = bld.buildFrom(sections[i], ssky);
|
||||
// Replace section with new one with new lighting
|
||||
sections[i] = bld.buildFrom(sections[i], ssky);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class DynmapBlockState {
|
||||
// Legacy block ID (if defined - otherwise -1)
|
||||
public final int legacyBlockID;
|
||||
// Light attenuation level (levels dropped when light tries to pass through block)
|
||||
public final int lightAttenuation;
|
||||
public int lightAttenuation;
|
||||
// List of block states (only defined on base block), indexed by stateIndex (null if single state base block)
|
||||
private DynmapBlockState[] states;
|
||||
private int stateLastIdx = 0;
|
||||
@ -106,24 +106,24 @@ public class DynmapBlockState {
|
||||
private static DynmapBlockState still_water = null;
|
||||
|
||||
public static class Builder {
|
||||
DynmapBlockState base;
|
||||
int stateidx;
|
||||
String blkname;
|
||||
String statename;
|
||||
String material;
|
||||
int legacyblkid;
|
||||
int matchflags;
|
||||
int lightblocked;
|
||||
private DynmapBlockState base;
|
||||
private int stateidx;
|
||||
private String blkname;
|
||||
private String statename;
|
||||
private String material;
|
||||
private int legacyblkid;
|
||||
private int matchflags;
|
||||
private int lightblocked;
|
||||
public Builder() {
|
||||
reset();
|
||||
}
|
||||
public void reset() { base = null; blkname = null; statename = null; material = null; legacyblkid = -1; matchflags = 0; lightblocked = 0; }
|
||||
public Builder setBaseState(DynmapBlockState base) { this.base = base; return this; }
|
||||
public Builder setStateIndex(int stateidx) { this.stateidx = stateidx; return this; }
|
||||
public Builder setBaseState(DynmapBlockState blkbase) { this.base = blkbase; return this; }
|
||||
public Builder setStateIndex(int sidx) { this.stateidx = sidx; return this; }
|
||||
public Builder setBlockName(String blkname) { this.blkname = blkname; return this; }
|
||||
public Builder setStateName(String statename) { this.statename = statename; return this; }
|
||||
public Builder setMaterial(String material) { this.material = material; return this; }
|
||||
public Builder setLegacyBlockID(int legacyblkid) { this.legacyblkid = legacyblkid; return this; }
|
||||
public Builder setStateName(String stname) { this.statename = stname; return this; }
|
||||
public Builder setMaterial(String mat) { this.material = mat; return this; }
|
||||
public Builder setLegacyBlockID(int legacybid) { this.legacyblkid = legacybid; return this; }
|
||||
public Builder setAir() { this.matchflags |= MATCH_AIR; return this; }
|
||||
public Builder setLog() { this.matchflags |= MATCH_LOG; return this; }
|
||||
public Builder setCustomWater() { this.matchflags |= MATCH_WATER; return this; }
|
||||
@ -133,13 +133,14 @@ public class DynmapBlockState {
|
||||
public Builder setBlocksLight() { this.lightblocked = 15; return this; }
|
||||
public Builder setAttenuatesLight(int levels) { this.lightblocked = levels; return this; }
|
||||
public DynmapBlockState build() {
|
||||
DynmapBlockState bs = new DynmapBlockState(base, stateidx, blkname, statename, material, legacyblkid);
|
||||
DynmapBlockState bs = new DynmapBlockState(base, stateidx, blkname, statename, material, legacyblkid, lightblocked);
|
||||
if ((matchflags & MATCH_AIR) != 0) bs.setAir();
|
||||
if ((matchflags & MATCH_LOG) != 0) bs.setLog();
|
||||
if ((matchflags & MATCH_WATERLOGGED) != 0) bs.setWaterlogged();
|
||||
if ((matchflags & MATCH_LEAVES) != 0) bs.setLeaves();
|
||||
if ((matchflags & MATCH_SOLID) != 0) bs.setSolid();
|
||||
if ((matchflags & MATCH_WATER) != 0) bs.addWaterBlock(blkname);
|
||||
reset(); // Reset after build complete
|
||||
return bs;
|
||||
}
|
||||
}
|
||||
@ -228,14 +229,7 @@ public class DynmapBlockState {
|
||||
if (this.blockName.equals(WATER_BLOCK) && (this == this.baseState)) {
|
||||
still_water = this;
|
||||
}
|
||||
if (lightAtten < 0) { // Not set
|
||||
if (isWater() || isWaterlogged()) lightAttenuation = 1;
|
||||
else if (isLeaves()) lightAttenuation = 2;
|
||||
else lightAttenuation = 0;
|
||||
}
|
||||
else {
|
||||
lightAttenuation = lightAtten;
|
||||
}
|
||||
lightAttenuation = lightAtten;
|
||||
}
|
||||
/**
|
||||
* Generate static lookup arrays once all BlockStates initialized
|
||||
@ -528,6 +522,15 @@ public class DynmapBlockState {
|
||||
public void setSolid() {
|
||||
matchflags |= MATCH_SOLID;
|
||||
}
|
||||
/**
|
||||
* Get light attenuation
|
||||
*/
|
||||
public final int getLightAttenuation() {
|
||||
if (lightAttenuation < 0) {
|
||||
lightAttenuation = (isWater() || isWaterlogged() || isLeaves()) ? 1 : 0;
|
||||
}
|
||||
return lightAttenuation;
|
||||
}
|
||||
/**
|
||||
* To printable string
|
||||
*/
|
||||
|
@ -29,6 +29,7 @@ import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.CollisionView;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
//import net.minecraft.world.WorldAccess;
|
||||
@ -174,6 +175,7 @@ public class DynmapPlugin {
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getId(bs);
|
||||
@ -205,27 +207,20 @@ public class DynmapPlugin {
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isFullOpaque(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) {
|
||||
basebs = dbs;
|
||||
}
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -28,6 +28,7 @@ import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
//import net.minecraft.world.WorldAccess;
|
||||
@ -174,6 +175,7 @@ public class DynmapPlugin {
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getId(bs);
|
||||
@ -205,27 +207,20 @@ public class DynmapPlugin {
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isFullOpaque(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) {
|
||||
basebs = dbs;
|
||||
}
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -27,6 +27,7 @@ import net.minecraft.util.collection.IdList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@ -173,6 +174,7 @@ public class DynmapPlugin {
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getRawId(bs);
|
||||
@ -204,27 +206,20 @@ public class DynmapPlugin {
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) {
|
||||
basebs = dbs;
|
||||
}
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -27,6 +27,7 @@ import net.minecraft.util.collection.IdList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@ -174,6 +175,7 @@ public class DynmapPlugin {
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getRawId(bs);
|
||||
@ -205,27 +207,20 @@ public class DynmapPlugin {
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) {
|
||||
basebs = dbs;
|
||||
}
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -24,6 +24,7 @@ import net.minecraft.util.collection.IdList;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.world.EmptyBlockView;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldAccess;
|
||||
import net.minecraft.world.biome.Biome;
|
||||
@ -31,6 +32,7 @@ import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraft.world.chunk.ChunkSection;
|
||||
import net.minecraft.world.chunk.ChunkStatus;
|
||||
import net.minecraft.world.chunk.WorldChunk;
|
||||
|
||||
import org.dynmap.*;
|
||||
import org.dynmap.common.BiomeMap;
|
||||
import org.dynmap.common.DynmapCommandSender;
|
||||
@ -135,6 +137,7 @@ public class DynmapPlugin {
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getRawId(bs);
|
||||
@ -166,27 +169,20 @@ public class DynmapPlugin {
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isOpaqueFullCube(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 15 : (bs.isTranslucent(EmptyBlockView.INSTANCE, BlockPos.ORIGIN) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) {
|
||||
basebs = dbs;
|
||||
}
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
}
|
||||
}
|
||||
// for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -56,6 +56,7 @@ import net.minecraft.util.math.ChunkPos;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.EmptyBlockReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
@ -222,6 +223,7 @@ public class DynmapPlugin
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.get(bs);
|
||||
@ -253,25 +255,20 @@ public class DynmapPlugin
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FlowingFluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FlowingFluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -57,6 +57,7 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.EmptyBlockReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IWorld;
|
||||
import net.minecraft.world.World;
|
||||
@ -223,6 +224,7 @@ public class DynmapPlugin
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.get(bs);
|
||||
@ -254,25 +256,20 @@ public class DynmapPlugin
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FlowingFluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FlowingFluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -59,6 +59,7 @@ import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.text.ChatType;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraft.util.text.StringTextComponent;
|
||||
import net.minecraft.world.EmptyBlockReader;
|
||||
import net.minecraft.world.IBlockReader;
|
||||
import net.minecraft.world.IServerWorld;
|
||||
import net.minecraft.world.IWorld;
|
||||
@ -224,6 +225,9 @@ public class DynmapPlugin
|
||||
/**
|
||||
* Initialize block states (org.dynmap.blockstate.DynmapBlockState)
|
||||
*/
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public void initializeBlockStates() {
|
||||
stateByID = new DynmapBlockState[512*32]; // Simple map - scale as needed
|
||||
Arrays.fill(stateByID, DynmapBlockState.AIR); // Default to air
|
||||
@ -235,6 +239,7 @@ public class DynmapPlugin
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getId(bs);
|
||||
@ -266,25 +271,21 @@ public class DynmapPlugin
|
||||
}
|
||||
statename += p.getName() + "=" + bs.get(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isOpaqueCube(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockReader.INSTANCE, BlockPos.ZERO) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FlowingFluidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof FlowingFluidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -51,6 +51,7 @@ import net.minecraft.server.players.GameProfileCache;
|
||||
import net.minecraft.server.players.UserBanList;
|
||||
import net.minecraft.world.entity.Pose;
|
||||
import net.minecraft.world.level.ChunkPos;
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
import net.minecraft.world.level.LevelAccessor;
|
||||
import net.minecraft.world.level.biome.Biome;
|
||||
import net.minecraft.world.level.block.Block;
|
||||
@ -214,6 +215,7 @@ public class DynmapPlugin
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getId(bs);
|
||||
@ -245,25 +247,21 @@ public class DynmapPlugin
|
||||
}
|
||||
statename += p.getName() + "=" + bs.getValue(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof LiquidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof LiquidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
@ -123,6 +123,8 @@ import it.unimi.dsi.fastutil.longs.LongOpenHashSet;
|
||||
import net.minecraftforge.eventbus.api.EventPriority;
|
||||
import net.minecraftforge.eventbus.api.SubscribeEvent;
|
||||
|
||||
import net.minecraft.world.level.EmptyBlockGetter;
|
||||
|
||||
public class DynmapPlugin
|
||||
{
|
||||
private DynmapCore core;
|
||||
@ -213,6 +215,7 @@ public class DynmapPlugin
|
||||
int baseidx = 0;
|
||||
|
||||
Iterator<BlockState> iter = bsids.iterator();
|
||||
DynmapBlockState.Builder bld = new DynmapBlockState.Builder();
|
||||
while (iter.hasNext()) {
|
||||
BlockState bs = iter.next();
|
||||
int idx = bsids.getId(bs);
|
||||
@ -244,25 +247,20 @@ public class DynmapPlugin
|
||||
}
|
||||
statename += p.getName() + "=" + bs.getValue(p).toString();
|
||||
}
|
||||
//Log.info("bn=" + bn + ", statenme=" + statename + ",idx=" + idx + ",baseidx=" + baseidx);
|
||||
DynmapBlockState dbs = new DynmapBlockState(basebs, idx - baseidx, bn, statename, mat.toString(), idx);
|
||||
int lightAtten = bs.isSolidRender(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 15 : (bs.propagatesSkylightDown(EmptyBlockGetter.INSTANCE, BlockPos.ZERO) ? 0 : 1);
|
||||
//Log.info("statename=" + bn + "[" + statename + "], lightAtten=" + lightAtten);
|
||||
// Fill in base attributes
|
||||
bld.setBaseState(basebs).setStateIndex(idx - baseidx).setBlockName(bn).setStateName(statename).setMaterial(mat.toString()).setLegacyBlockID(idx).setAttenuatesLight(lightAtten);
|
||||
if (mat.isSolid()) { bld.setSolid(); }
|
||||
if (mat == Material.AIR) { bld.setAir(); }
|
||||
if (mat == Material.WOOD) { bld.setLog(); }
|
||||
if (mat == Material.LEAVES) { bld.setLeaves(); }
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof LiquidBlock)) {
|
||||
bld.setWaterlogged();
|
||||
}
|
||||
DynmapBlockState dbs = bld.build(); // Build state
|
||||
stateByID[idx] = dbs;
|
||||
if (basebs == null) { basebs = dbs; }
|
||||
if (mat.isSolid()) {
|
||||
dbs.setSolid();
|
||||
}
|
||||
if (mat == Material.AIR) {
|
||||
dbs.setAir();
|
||||
}
|
||||
if (mat == Material.WOOD) {
|
||||
dbs.setLog();
|
||||
}
|
||||
if (mat == Material.LEAVES) {
|
||||
dbs.setLeaves();
|
||||
}
|
||||
if ((!bs.getFluidState().isEmpty()) && !(bs.getBlock() instanceof LiquidBlock)) {
|
||||
dbs.setWaterlogged();
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int gidx = 0; gidx < DynmapBlockState.getGlobalIndexMax(); gidx++) {
|
||||
|
Loading…
Reference in New Issue
Block a user