Add option to construct ChunkSectionLightImpl without block light

This commit is contained in:
RaphiMC 2024-10-23 16:42:21 +02:00 committed by Nassim Jahnke
parent 84d928ebe7
commit c556420870
No known key found for this signature in database
GPG Key ID: EF6771C01F6EF02F
3 changed files with 15 additions and 7 deletions

View File

@ -37,14 +37,14 @@ public class ChunkSectionImpl implements ChunkSection {
public ChunkSectionImpl(final boolean holdsLight) { public ChunkSectionImpl(final boolean holdsLight) {
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE)); addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE));
if (holdsLight) { if (holdsLight) {
this.light = new ChunkSectionLightImpl(); this.light = ChunkSectionLightImpl.createWithBlockLight();
} }
} }
public ChunkSectionImpl(final boolean holdsLight, final int expectedPaletteLength) { public ChunkSectionImpl(final boolean holdsLight, final int expectedPaletteLength) {
addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE, expectedPaletteLength)); addPalette(PaletteType.BLOCKS, new DataPaletteImpl(ChunkSection.SIZE, expectedPaletteLength));
if (holdsLight) { if (holdsLight) {
this.light = new ChunkSectionLightImpl(); this.light = ChunkSectionLightImpl.createWithBlockLight();
} }
} }

View File

@ -43,7 +43,7 @@ public interface ChunkSectionLight {
* Returns whether the section has block light. * Returns whether the section has block light.
* This returns true unless specifically set to null. * This returns true unless specifically set to null.
* *
* @return true if skylight is present * @return true if block light is present
*/ */
boolean hasBlockLight(); boolean hasBlockLight();

View File

@ -30,9 +30,17 @@ public class ChunkSectionLightImpl implements ChunkSectionLight {
private NibbleArray blockLight; private NibbleArray blockLight;
private NibbleArray skyLight; private NibbleArray skyLight;
public ChunkSectionLightImpl() { protected ChunkSectionLightImpl() {
// Block light is always written }
this.blockLight = new NibbleArray(ChunkSection.SIZE);
public static ChunkSectionLight createWithBlockLight() {
final ChunkSectionLightImpl light = new ChunkSectionLightImpl();
light.blockLight = new NibbleArray(ChunkSection.SIZE);
return light;
}
public static ChunkSectionLight createEmpty() {
return new ChunkSectionLightImpl();
} }
@Override @Override