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
|
|
@ -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++) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue