Implement basic sky lighting for chunks with broken lighting
(forge,fabric)
This commit is contained in:
parent
05819b1b74
commit
3a3a970883
12 changed files with 197 additions and 219 deletions
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue