1
0
Fork 0

remove skylight

This commit is contained in:
Sen 2025-08-27 21:11:45 +02:00
parent 375a67d10f
commit 259bcab1fd
Signed by: sen
GPG key ID: 3AC50A6F47D1B722
12 changed files with 38 additions and 325 deletions

View file

@ -3616,7 +3616,6 @@ public class Client implements IThreadListener {
int j = chunkcoordintpair.x * 16; int j = chunkcoordintpair.x * 16;
int k = chunkcoordintpair.z * 16; int k = chunkcoordintpair.z * 16;
ChunkClient chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z); ChunkClient chunk = this.getChunk(chunkcoordintpair.x, chunkcoordintpair.z);
chunk.enqueueRelight();
this.previousActive.add(chunkcoordintpair); this.previousActive.add(chunkcoordintpair);
++i; ++i;

View file

@ -743,11 +743,6 @@ public class ClientPlayer implements IClientPlayer
ChunkClient chunk = this.gm.getChunk(packetIn.getChunkX(), packetIn.getChunkZ()); ChunkClient chunk = this.gm.getChunk(packetIn.getChunkX(), packetIn.getChunkZ());
chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedExtend(), packetIn.hasBiomes()); chunk.setData(packetIn.getExtractedDataBytes(), packetIn.getExtractedExtend(), packetIn.hasBiomes());
this.gm.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15); this.gm.markBlockRangeForRenderUpdate(packetIn.getChunkX() << 4, -World.MAX_SIZE_Y, packetIn.getChunkZ() << 4, (packetIn.getChunkX() << 4) + 15, World.MAX_SIZE_Y, (packetIn.getChunkZ() << 4) + 15);
if (!packetIn.hasBiomes() || !this.world.dimension.hasSkyLight()) // TODO: check
{
chunk.resetRelight();
}
} }
/** /**
@ -1342,11 +1337,6 @@ public class ClientPlayer implements IClientPlayer
ChunkClient chunk = this.gm.getChunk(j, k); ChunkClient chunk = this.gm.getChunk(j, k);
chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkExtend(i), true); chunk.setData(packetIn.getChunkBytes(i), packetIn.getChunkExtend(i), true);
this.gm.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15); this.gm.markBlockRangeForRenderUpdate(j << 4, -World.MAX_SIZE_Y, k << 4, (j << 4) + 15, World.MAX_SIZE_Y, (k << 4) + 15);
if (!this.world.dimension.hasSkyLight()) // TODO: check
{
chunk.resetRelight();
}
} }
} }

View file

@ -66,7 +66,6 @@ public class ChunkClient extends Chunk {
public void setData(byte[] data, int[] extend, boolean biomes) { public void setData(byte[] data, int[] extend, boolean biomes) {
int pos = 0; int pos = 0;
boolean sky = this.world.dimension.hasSkyLight();
if(biomes) { if(biomes) {
this.clearArrays(); this.clearArrays();
@ -74,7 +73,7 @@ public class ChunkClient extends Chunk {
for(int cy : extend) { for(int cy : extend) {
BlockArray arr = this.getArray(cy); BlockArray arr = this.getArray(cy);
if(arr == null) { if(arr == null) {
arr = new BlockArray(cy << 4, sky, null); arr = new BlockArray(cy << 4, null);
this.setArray(arr); this.setArray(arr);
} }
@ -95,17 +94,6 @@ public class ChunkClient extends Chunk {
} }
} }
if(sky) {
for(int cy : extend) {
BlockArray arr = this.getArray(cy);
if(arr != null) {
NibbleArray slight = arr.getSkylight();
System.arraycopy(data, pos, slight.getData(), 0, slight.getData().length);
pos += slight.getData().length;
}
}
}
if(biomes) { if(biomes) {
for(int k = 0; k < this.temperatures.length; ++k) { for(int k = 0; k < this.temperatures.length; ++k) {
this.temperatures[k] = Float.intBitsToFloat((int)((data[pos + 3] & 255) << 24 | (data[pos + 2] & 255) << 16 | (data[pos + 1] & 255) << 8 | data[pos] & 255)); this.temperatures[k] = Float.intBitsToFloat((int)((data[pos + 3] & 255) << 24 | (data[pos + 2] & 255) << 16 | (data[pos + 1] & 255) << 8 | data[pos] & 255));

View file

@ -68,13 +68,12 @@ public class SPacketChunkData implements Packet<IClientPlayer>
return this.extractedData.data; return this.extractedData.data;
} }
public static int getSize(int segments, boolean overworld, boolean biomes) public static int getSize(int segments, boolean biomes)
{ {
int i = segments * 2 * 16 * 16 * 16; int i = segments * 2 * 16 * 16 * 16;
int j = segments * 16 * 16 * 16 / 2; int j = segments * 16 * 16 * 16 / 2;
int k = overworld ? segments * 16 * 16 * 16 / 2 : 0;
int l = biomes ? 256 * 8 : 0; int l = biomes ? 256 * 8 : 0;
return i + j + k + l; return i + j + l;
} }
public int getChunkX() public int getChunkX()

View file

@ -10,18 +10,16 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
private int[] xPositions; private int[] xPositions;
private int[] zPositions; private int[] zPositions;
private SPacketChunkData.Extracted[] chunksData; private SPacketChunkData.Extracted[] chunksData;
private boolean sky;
public SPacketMapChunkBulk() public SPacketMapChunkBulk()
{ {
} }
public SPacketMapChunkBulk(int[] x, int[] z, SPacketChunkData.Extracted[] chunks, boolean sky) public SPacketMapChunkBulk(int[] x, int[] z, SPacketChunkData.Extracted[] chunks)
{ {
this.xPositions = x; this.xPositions = x;
this.zPositions = z; this.zPositions = z;
this.chunksData = chunks; this.chunksData = chunks;
this.sky = sky;
} }
/** /**
@ -29,7 +27,6 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
*/ */
public void readPacketData(PacketBuffer buf) throws IOException public void readPacketData(PacketBuffer buf) throws IOException
{ {
this.sky = buf.readBoolean();
int i = buf.readVarInt(); int i = buf.readVarInt();
this.xPositions = new int[i]; this.xPositions = new int[i];
this.zPositions = new int[i]; this.zPositions = new int[i];
@ -44,7 +41,7 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
for(int z = 0; z < this.chunksData[j].extend.length; z++) { for(int z = 0; z < this.chunksData[j].extend.length; z++) {
this.chunksData[j].extend[z] = buf.readVarInt(); this.chunksData[j].extend[z] = buf.readVarInt();
} }
this.chunksData[j].data = new byte[SPacketChunkData.getSize(this.chunksData[j].extend.length, this.sky, true)]; this.chunksData[j].data = new byte[SPacketChunkData.getSize(this.chunksData[j].extend.length, true)];
} }
for (int k = 0; k < i; ++k) for (int k = 0; k < i; ++k)
@ -58,7 +55,6 @@ public class SPacketMapChunkBulk implements Packet<IClientPlayer>
*/ */
public void writePacketData(PacketBuffer buf) throws IOException public void writePacketData(PacketBuffer buf) throws IOException
{ {
buf.writeBoolean(this.sky);
buf.writeVarInt(this.chunksData.length); buf.writeVarInt(this.chunksData.length);
for (int i = 0; i < this.xPositions.length; ++i) for (int i = 0; i < this.xPositions.length; ++i)

View file

@ -16,15 +16,12 @@ public class BlockArray {
private int filled; private int filled;
private char[] data; private char[] data;
private NibbleArray blocklight; private NibbleArray blocklight;
private NibbleArray skylight;
public BlockArray(int y, boolean sky, State filler) { public BlockArray(int y, State filler) {
this.yBase = y; this.yBase = y;
this.filler = filler; this.filler = filler;
this.data = new char[4096]; this.data = new char[4096];
this.blocklight = new NibbleArray(); this.blocklight = new NibbleArray();
if(sky)
this.skylight = new NibbleArray();
if(filler != null && filler.getBlock() != Blocks.air) { if(filler != null && filler.getBlock() != Blocks.air) {
Arrays.fill(this.data, (char)BlockRegistry.getId(filler)); Arrays.fill(this.data, (char)BlockRegistry.getId(filler));
this.blocks = this.data.length; this.blocks = this.data.length;
@ -78,14 +75,6 @@ public class BlockArray {
return this.yBase; return this.yBase;
} }
public void setSky(int x, int y, int z, int value) {
this.skylight.set(x, y, z, value);
}
public int getSky(int x, int y, int z) {
return this.skylight.get(x, y, z);
}
public void setLight(int x, int y, int z, int value) { public void setLight(int x, int y, int z, int value) {
this.blocklight.set(x, y, z, value); this.blocklight.set(x, y, z, value);
} }
@ -123,10 +112,6 @@ public class BlockArray {
return this.blocklight; return this.blocklight;
} }
public NibbleArray getSkylight() {
return this.skylight;
}
public void setData(char[] data) { public void setData(char[] data) {
this.data = data; this.data = data;
} }
@ -134,10 +119,6 @@ public class BlockArray {
public void setBlocklight(NibbleArray data) { public void setBlocklight(NibbleArray data) {
this.blocklight = data; this.blocklight = data;
} }
public void setSkylight(NibbleArray data) {
this.skylight = data;
}
public int hashCode() { public int hashCode() {
return this.yBase >> 4; return this.yBase >> 4;

View file

@ -32,21 +32,18 @@ public abstract class Chunk {
protected final IntHashMap<BlockArray> blocks = new IntHashMap(); protected final IntHashMap<BlockArray> blocks = new IntHashMap();
protected final Set<BlockArray> blockList = Sets.newHashSet(); protected final Set<BlockArray> blockList = Sets.newHashSet();
protected final int[] precHeight = new int[256]; protected final int[] precHeight = new int[256];
protected final boolean[] updateSky = new boolean[256];
protected final int[] height = new int[256]; protected final int[] height = new int[256];
protected final Map<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap(); protected final Map<BlockPos, TileEntity> tiles = Maps.<BlockPos, TileEntity>newHashMap();
protected final InheritanceMultiMap<Entity>[] entities = new InheritanceMultiMap[32]; protected final InheritanceMultiMap<Entity>[] entities = new InheritanceMultiMap[32];
protected final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>(); protected final ConcurrentLinkedQueue<BlockPos> tileQueue = new ConcurrentLinkedQueue<BlockPos>();
protected boolean loaded; protected boolean loaded;
protected boolean gapUpdate;
protected boolean populated; protected boolean populated;
protected boolean lightInit; protected boolean lightInit;
protected boolean updated; protected boolean updated;
protected boolean modified; protected boolean modified;
protected boolean hasEntity; protected boolean hasEntity;
protected int minHeight; protected int minHeight;
protected int lightChecks = Integer.MAX_VALUE;
protected int bottom = Integer.MAX_VALUE; protected int bottom = Integer.MAX_VALUE;
protected int top = Integer.MIN_VALUE; protected int top = Integer.MIN_VALUE;
@ -80,7 +77,7 @@ public abstract class Chunk {
this.top = y > this.top ? y : this.top; this.top = y > this.top ? y : this.top;
} }
public void genSkyLight() { public void genSky() {
int top = this.top; int top = this.top;
int bottom = this.bottom < -64 ? -64 : this.bottom; int bottom = this.bottom < -64 ? -64 : this.bottom;
this.minHeight = Integer.MAX_VALUE; this.minHeight = Integer.MAX_VALUE;
@ -100,101 +97,12 @@ public abstract class Chunk {
break; break;
} }
} }
if(this.world.dimension.hasSkyLight() && top != Integer.MIN_VALUE) {
int l = 15;
int y = top + 16 - 1;
while(true) {
int b = this.getOpacity(x, y, z);
if(b == 0 && l != 15) {
b = 1;
}
l -= b;
if(l > 0) {
BlockArray stor = this.getArray(y >> 4);
if(stor != null) {
stor.setSky(x, y & 15, z, l);
this.world.clientNotifyLight(new BlockPos((this.xPos << 4) + x, y, (this.zPos << 4) + z));
}
}
--y;
if(y <= bottom || l <= 0) {
break;
}
}
}
} }
} }
this.modified = true; this.modified = true;
} }
private void propagateOcclusion(int x, int z) {
this.updateSky[x + z * 16] = true;
this.gapUpdate = true;
}
private void recheckGaps(boolean single) {
if(this.world.isAreaLoaded(new BlockPos(this.xPos * 16 + 8, 0, this.zPos * 16 + 8), 16)) {
for(int x = 0; x < 16; ++x) {
for(int z = 0; z < 16; ++z) {
if(this.updateSky[x + z * 16]) {
this.updateSky[x + z * 16] = false;
int h = this.getHeight(x, z);
int cx = this.xPos * 16 + x;
int cz = this.zPos * 16 + z;
int max = Integer.MAX_VALUE;
for(Facing face : Facing.Plane.HORIZONTAL) {
max = Math.min(max, this.world.getChunksLowestHorizon(cx + face.getFrontOffsetX(),
cz + face.getFrontOffsetZ()));
}
this.checkNeighbor(cx, cz, max);
for(Facing face : Facing.Plane.HORIZONTAL) {
this.checkNeighbor(cx + face.getFrontOffsetX(), cz + face.getFrontOffsetZ(), h);
}
if(single) {
return;
}
}
}
}
this.gapUpdate = false;
}
}
private void checkNeighbor(int x, int z, int max) {
int h = this.world.getHeight(new BlockPos(x, 0, z)).getY();
if(h > max) {
this.updateNeighbor(x, z, max, h + 1);
}
else if(h < max) {
this.updateNeighbor(x, z, h, max + 1);
}
}
private void updateNeighbor(int x, int z, int bottom, int top) {
if(top > bottom && this.world.isAreaLoaded(new BlockPos(x, 0, z), 16)) {
for(int y = bottom; y < top; ++y) {
this.world.checkLightFor(LightType.SKY, new BlockPos(x, y, z));
}
this.modified = true;
}
}
private void relightBlock(int x, int y, int z) { private void relightBlock(int x, int y, int z) {
int h = this.height[z << 4 | x]; int h = this.height[z << 4 | x];
int min = this.bottom < -64 ? -64 : this.bottom; int min = this.bottom < -64 ? -64 : this.bottom;
@ -214,52 +122,6 @@ public abstract class Chunk {
int cx = this.xPos * 16 + x; int cx = this.xPos * 16 + x;
int cz = this.zPos * 16 + z; int cz = this.zPos * 16 + z;
if(this.world.dimension.hasSkyLight()) {
if(cy < h) {
for(int n = cy; n < h; ++n) {
BlockArray stor = this.getArray(n >> 4);
if(stor != null) {
stor.setSky(x, n & 15, z, 15);
this.world.clientNotifyLight(new BlockPos((this.xPos << 4) + x, n, (this.zPos << 4) + z));
}
}
}
else {
for(int n = h; n < cy; ++n) {
BlockArray stor = this.getArray(n >> 4);
if(stor != null) {
stor.setSky(x, n & 15, z, 0);
this.world.clientNotifyLight(new BlockPos((this.xPos << 4) + x, n, (this.zPos << 4) + z));
}
}
}
int l = 15;
while(cy > min && l > 0) {
--cy;
int b = this.getOpacity(x, cy, z);
if(b == 0) {
b = 1;
}
l -= b;
if(l < 0) {
l = 0;
}
BlockArray stor = this.getArray(cy >> 4);
if(stor != null) {
stor.setSky(x, cy & 15, z, l);
}
}
}
int sh = this.height[z << 4 | x]; int sh = this.height[z << 4 | x];
int sy = h; int sy = h;
int ey = sh; int ey = sh;
@ -273,14 +135,6 @@ public abstract class Chunk {
this.minHeight = sh; this.minHeight = sh;
} }
if(this.world.dimension.hasSkyLight()) {
for(Facing face : Facing.Plane.HORIZONTAL) {
this.updateNeighbor(cx + face.getFrontOffsetX(), cz + face.getFrontOffsetZ(), sy, ey);
}
this.updateNeighbor(cx, cz, sy, ey);
}
this.modified = true; this.modified = true;
} }
} }
@ -334,7 +188,7 @@ public abstract class Chunk {
return null; return null;
} }
stor = new BlockArray(y >> 4 << 4, this.world.dimension.hasSkyLight(), y < 0 ? this.filler : null); stor = new BlockArray(y >> 4 << 4, y < 0 ? this.filler : null);
this.setArray(stor); this.setArray(stor);
up = y >= h; up = y >= h;
} }
@ -356,7 +210,7 @@ public abstract class Chunk {
else { else {
if(updateLight) { if(updateLight) {
if(up) { if(up) {
this.genSkyLight(); this.genSky();
} }
else { else {
int b = block.getLightOpacity(); int b = block.getLightOpacity();
@ -370,10 +224,6 @@ public abstract class Chunk {
else if(y == h - 1) { else if(y == h - 1) {
this.relightBlock(x, y, z); this.relightBlock(x, y, z);
} }
if(b != ob && (b < ob || this.getLight(LightType.SKY, pos) > 0 || this.getLight(LightType.BLOCK, pos) > 0)) {
this.propagateOcclusion(x, z);
}
} }
} }
@ -414,9 +264,9 @@ public abstract class Chunk {
int z = pos.getZ() & 15; int z = pos.getZ() & 15;
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.getArray(y >> 4);
if(type == LightType.SKY) { if(type == LightType.SKY) {
int l = stor == null ? (this.canSeeSky(pos) ? type.defValue : 0) : (this.world.dimension.hasSkyLight() ? stor.getSky(x, y & 15, z) : 0); int l = stor == null ? (this.canSeeSky(pos) ? type.defValue : 0) : (this.world.dimension.hasSkyLight() ? 15 : 0);
if(y < 0) { if(y < 64) {
int max = y < -64 ? 0 : (y + 64) / 4; int max = y < 0 ? 0 : y / 4;
l = l > max ? max : l; l = l > max ? max : l;
} }
return l; return l;
@ -433,19 +283,14 @@ public abstract class Chunk {
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.getArray(y >> 4);
if(stor == null) { if(stor == null) {
stor = new BlockArray(y >> 4 << 4, this.world.dimension.hasSkyLight(), y < 0 ? this.filler : null); stor = new BlockArray(y >> 4 << 4, y < 0 ? this.filler : null);
this.setArray(stor); this.setArray(stor);
this.genSkyLight(); this.genSky();
} }
this.modified = true; this.modified = true;
if(type == LightType.SKY) { if(type == LightType.BLOCK) {
if(this.world.dimension.hasSkyLight()) {
stor.setSky(x, y & 15, z, value);
}
}
else if(type == LightType.BLOCK) {
stor.setLight(x, y & 15, z, value); stor.setLight(x, y & 15, z, value);
} }
} }
@ -455,9 +300,9 @@ public abstract class Chunk {
int y = pos.getY(); int y = pos.getY();
int z = pos.getZ() & 15; int z = pos.getZ() & 15;
BlockArray stor = this.getArray(y >> 4); BlockArray stor = this.getArray(y >> 4);
int l = stor == null ? LightType.SKY.defValue : (this.world.dimension.hasSkyLight() ? stor.getSky(x, y & 15, z) : 0); int l = stor == null ? LightType.SKY.defValue : (this.world.dimension.hasSkyLight() ? 15 : 0);
if(y < 0) { if(y < 64) {
int max = y < -64 ? 0 : (y + 64) / 4; int max = y < 0 ? 0 : y / 4;
l = l > max ? max : l; l = l > max ? max : l;
} }
if(stor == null) if(stor == null)
@ -644,10 +489,6 @@ public abstract class Chunk {
} }
public void update(boolean noGaps) { public void update(boolean noGaps) {
if(this.gapUpdate && this.world.dimension.hasSkyLight() && !noGaps) {
this.recheckGaps(this.world.client);
}
this.updated = true; this.updated = true;
if(!this.lightInit && this.populated) { if(!this.lightInit && this.populated) {
@ -669,53 +510,6 @@ public abstract class Chunk {
return this.updated && this.populated && this.lightInit; return this.updated && this.populated && this.lightInit;
} }
public void resetRelight() {
this.lightChecks = 0;
}
/**
* Called once-per-chunk-per-tick, and advances the round-robin relight check
* index by up to 8 blocks at a time. In a worst-case scenario, can potentially
* take up to 51.2 seconds, calculated via (8192/8)/20, to re-check all blocks
* in a chunk, which may explain lagging light updates on initial world
* generation.
*/
public void enqueueRelight() {
BlockPos pos = new BlockPos(this.xPos << 4, 0, this.zPos << 4);
for(int n = 0; n < 8; ++n) {
if(this.top == Integer.MIN_VALUE)
return;
int h = 1 + (this.top >> 4) - (this.bottom >> 4);
if(this.lightChecks >= 256 * h)
return;
int s = (this.lightChecks % h) + (this.bottom >> 4);
int x = this.lightChecks / h % 16;
int z = this.lightChecks / 512;
++this.lightChecks;
for(int y = 0; y < 16; ++y) {
BlockPos block = pos.add(x, (s << 4) + y, z);
boolean edge = y == 0 || y == 15 || x == 0 || x == 15 || z == 0 || z == 15;
BlockArray arr = this.getArray(s);
if(arr == null && edge || arr != null
&& arr.getBlock(x, y, z) == Blocks.air) {
for(Facing face : Facing.values()) {
BlockPos side = block.offset(face);
if(this.world.getState(side).getBlock().getLight() > 0) {
this.world.checkLight(side);
}
}
this.world.checkLight(block);
}
}
}
}
public void checkLight() { public void checkLight() {
this.populated = true; this.populated = true;
this.lightInit = true; this.lightInit = true;
@ -739,8 +533,6 @@ public abstract class Chunk {
int d = face.getAxisDirection() == Facing.AxisDirection.POSITIVE ? 16 : 1; int d = face.getAxisDirection() == Facing.AxisDirection.POSITIVE ? 16 : 1;
this.world.getChunk(pos.offset(face, d)).updateColumns(face.getOpposite()); this.world.getChunk(pos.offset(face, d)).updateColumns(face.getOpposite());
} }
this.setSkyDirty();
} }
} }
else { else {
@ -749,14 +541,6 @@ public abstract class Chunk {
} }
} }
private void setSkyDirty() {
for(int n = 0; n < this.updateSky.length; ++n) {
this.updateSky[n] = true;
}
this.recheckGaps(false);
}
private void updateColumns(Facing facing) { private void updateColumns(Facing facing) {
if(this.populated) { if(this.populated) {
if(facing == Facing.EAST) { if(facing == Facing.EAST) {

View file

@ -1495,7 +1495,7 @@ public abstract class World implements IWorldAccess {
private int getRawLight(BlockPos pos, LightType lightType) { private int getRawLight(BlockPos pos, LightType lightType) {
if(lightType == LightType.SKY && this.canSeeSky(pos)) { if(lightType == LightType.SKY && this.canSeeSky(pos)) {
return pos.getY() < 0 ? (pos.getY() < -64 ? 0 : (pos.getY() + 64) / 4) : 15; return pos.getY() < 64 ? (pos.getY() < 0 ? 0 : pos.getY() / 4) : 15;
} }
else { else {
Block block = this.getState(pos).getBlock(); Block block = this.getState(pos).getBlock();

View file

@ -859,7 +859,7 @@ public class Player extends User implements Executor, IPlayer
public static SPacketChunkData.Extracted getExtractedData(WorldServer world, ChunkServer chunk, boolean biomes, boolean overworld, int[] extend) public static SPacketChunkData.Extracted getExtractedData(WorldServer world, ChunkServer chunk, boolean biomes, int[] extend)
{ {
Set<BlockArray> aextendedblockstorage = chunk.getStorage(); Set<BlockArray> aextendedblockstorage = chunk.getStorage();
SPacketChunkData.Extracted dataset = new SPacketChunkData.Extracted(); SPacketChunkData.Extracted dataset = new SPacketChunkData.Extracted();
@ -884,7 +884,7 @@ public class Player extends User implements Executor, IPlayer
} }
dataset.extend = extend; dataset.extend = extend;
dataset.data = new byte[SPacketChunkData.getSize(extend.length, overworld, biomes)]; dataset.data = new byte[SPacketChunkData.getSize(extend.length, biomes)];
int j = 0; int j = 0;
for (BlockArray extendedblockstorage1 : list) for (BlockArray extendedblockstorage1 : list)
@ -903,14 +903,6 @@ public class Player extends User implements Executor, IPlayer
j = copyTo(extendedblockstorage2.getBlocklight().getData(), dataset.data, j); j = copyTo(extendedblockstorage2.getBlocklight().getData(), dataset.data, j);
} }
if (overworld)
{
for (BlockArray extendedblockstorage3 : list)
{
j = copyTo(extendedblockstorage3.getSkylight().getData(), dataset.data, j);
}
}
if (biomes) if (biomes)
{ {
BiomeGenerator gen = world.getBiomeGenerator(); BiomeGenerator gen = world.getBiomeGenerator();
@ -940,12 +932,12 @@ public class Player extends User implements Executor, IPlayer
return offset + src.length; return offset + src.length;
} }
public static SPacketChunkData getPacket(WorldServer world, ChunkServer chunkIn, boolean biomes, int[] extend, boolean sky) public static SPacketChunkData getPacket(WorldServer world, ChunkServer chunkIn, boolean biomes, int[] extend)
{ {
return new SPacketChunkData(chunkIn.xPos, chunkIn.zPos, biomes, getExtractedData(world, chunkIn, biomes, sky, extend)); return new SPacketChunkData(chunkIn.xPos, chunkIn.zPos, biomes, getExtractedData(world, chunkIn, biomes, extend));
} }
private static SPacketMapChunkBulk getPacket(WorldServer world, List<ChunkServer> chunks, boolean sky) private static SPacketMapChunkBulk getPacket(WorldServer world, List<ChunkServer> chunks)
{ {
int i = chunks.size(); int i = chunks.size();
int[] xPositions = new int[i]; int[] xPositions = new int[i];
@ -955,13 +947,13 @@ public class Player extends User implements Executor, IPlayer
for (int j = 0; j < i; ++j) for (int j = 0; j < i; ++j)
{ {
ChunkServer chunk = chunks.get(j); ChunkServer chunk = chunks.get(j);
SPacketChunkData.Extracted s21packetchunkdata$extracted = getExtractedData(world, chunk, true, sky, null); SPacketChunkData.Extracted s21packetchunkdata$extracted = getExtractedData(world, chunk, true, null);
xPositions[j] = chunk.xPos; xPositions[j] = chunk.xPos;
zPositions[j] = chunk.zPos; zPositions[j] = chunk.zPos;
chunksData[j] = s21packetchunkdata$extracted; chunksData[j] = s21packetchunkdata$extracted;
} }
return new SPacketMapChunkBulk(xPositions, zPositions, chunksData, sky); return new SPacketMapChunkBulk(xPositions, zPositions, chunksData);
} }
@ -1052,11 +1044,11 @@ public class Player extends User implements Executor, IPlayer
{ {
if (list.size() == 1) if (list.size() == 1)
{ {
this.sendPacket(getPacket(world, list.get(0), true, null, this.entity.worldObj.dimension.hasSkyLight())); this.sendPacket(getPacket(world, list.get(0), true, null));
} }
else else
{ {
this.sendPacket(getPacket(world, list, this.entity.worldObj.dimension.hasSkyLight())); this.sendPacket(getPacket(world, list));
} }
for (TileEntity tileentity : list1) for (TileEntity tileentity : list1)

View file

@ -24,7 +24,6 @@ public class ChunkServer extends Chunk {
public ChunkServer(WorldServer world, char[] data, int height, boolean base, boolean ceil, Random rand, int x, int z) { public ChunkServer(WorldServer world, char[] data, int height, boolean base, boolean ceil, Random rand, int x, int z) {
this(world, x, z); this(world, x, z);
boolean sky = world.dimension.hasSkyLight();
for(int bx = 0; bx < 16; ++bx) { for(int bx = 0; bx < 16; ++bx) {
for(int bz = 0; bz < 16; ++bz) { for(int bz = 0; bz < 16; ++bz) {
for(int by = 0; by < height; ++by) { for(int by = 0; by < height; ++by) {
@ -33,7 +32,7 @@ public class ChunkServer extends Chunk {
int y = by >> 4; int y = by >> 4;
BlockArray arr = this.getArray(y); BlockArray arr = this.getArray(y);
if(arr == null) { if(arr == null) {
arr = new BlockArray(y << 4, sky, null); arr = new BlockArray(y << 4, null);
this.setArray(arr); this.setArray(arr);
} }
arr.set(bx, by & 15, bz, state); arr.set(bx, by & 15, bz, state);
@ -44,7 +43,7 @@ public class ChunkServer extends Chunk {
if(base) { if(base) {
BlockArray arr = this.getArray(0); BlockArray arr = this.getArray(0);
if(arr == null) { if(arr == null) {
arr = new BlockArray(0, sky, null); arr = new BlockArray(0, null);
this.setArray(arr); this.setArray(arr);
} }
for(int bx = 0; bx < 16; ++bx) { for(int bx = 0; bx < 16; ++bx) {
@ -63,13 +62,13 @@ public class ChunkServer extends Chunk {
int y = (height - 1) >> 4; int y = (height - 1) >> 4;
BlockArray arr = this.getArray(y); BlockArray arr = this.getArray(y);
if(arr == null) { if(arr == null) {
arr = new BlockArray(y << 4, sky, null); arr = new BlockArray(y << 4, null);
this.setArray(arr); this.setArray(arr);
} }
y = (height - 5) >> 4; y = (height - 5) >> 4;
arr = this.getArray(y); arr = this.getArray(y);
if(arr == null) { if(arr == null) {
arr = new BlockArray(y << 4, sky, null); arr = new BlockArray(y << 4, null);
this.setArray(arr); this.setArray(arr);
} }
for(int bx = 0; bx < 16; ++bx) { for(int bx = 0; bx < 16; ++bx) {
@ -81,10 +80,8 @@ public class ChunkServer extends Chunk {
} }
} }
} }
if(ceil) if(!ceil)
this.resetRelight(); this.genSky();
else
this.genSkyLight();
} }
public int getTopSegment() { public int getTopSegment() {

View file

@ -490,12 +490,11 @@ public class Region {
chunk.setInhabited(tag.getLong("I")); chunk.setInhabited(tag.getLong("I"));
List<TagObject> sects = tag.getList("S"); List<TagObject> sects = tag.getList("S");
BlockArray[] sections = new BlockArray[sects.size()]; BlockArray[] sections = new BlockArray[sects.size()];
boolean light = world.dimension.hasSkyLight();
for(int n = 0; n < sects.size(); ++n) { for(int n = 0; n < sects.size(); ++n) {
TagObject sect = sects.get(n); TagObject sect = sects.get(n);
int y = sect.getInt("Y"); int y = sect.getInt("Y");
BlockArray storage = new BlockArray(y << 4, light, y < 0 ? world.dimension.getFiller() : null); BlockArray storage = new BlockArray(y << 4, y < 0 ? world.dimension.getFiller() : null);
byte[] blocks = sect.getByteArray("D"); byte[] blocks = sect.getByteArray("D");
char[] seg = new char[blocks.length >> 1]; char[] seg = new char[blocks.length >> 1];
@ -506,10 +505,6 @@ public class Region {
storage.setData(seg); storage.setData(seg);
storage.setBlocklight(new NibbleArray(sect.getByteArray("B"))); storage.setBlocklight(new NibbleArray(sect.getByteArray("B")));
if(light) {
storage.setSkylight(new NibbleArray(sect.getByteArray("S")));
}
storage.update(); storage.update();
sections[n] = storage; sections[n] = storage;
} }
@ -614,13 +609,6 @@ public class Region {
sect.setByteArray("B", storage.getBlocklight().getData()); sect.setByteArray("B", storage.getBlocklight().getData());
if(light) {
sect.setByteArray("S", storage.getSkylight().getData());
}
else {
sect.setByteArray("S", new byte[storage.getBlocklight().getData().length]);
}
sects.add(sect); sects.add(sect);
} }
} }

View file

@ -465,7 +465,6 @@ public final class WorldServer extends AWorldServer {
// this.profiler.next("moodSound"); // this.profiler.next("moodSound");
// this.playMoodSound(k, l, chunk); // this.playMoodSound(k, l, chunk);
// this.profiler.next("checkLight"); // this.profiler.next("checkLight");
chunk.enqueueRelight();
// this.profiler.next("tickChunk"); // this.profiler.next("tickChunk");
chunk.update(false); chunk.update(false);
// this.profiler.next("thunder"); // this.profiler.next("thunder");
@ -1476,7 +1475,7 @@ public final class WorldServer extends AWorldServer {
private ChunkServer generate(int x, int z) { private ChunkServer generate(int x, int z) {
if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) { if(x < -this.size || z < -this.size || x >= this.size || z >= this.size) {
ChunkServer chunk = new ChunkServer(this, x, z); ChunkServer chunk = new ChunkServer(this, x, z);
chunk.genSkyLight(); chunk.genSky();
return chunk; return chunk;
} }
this.grng.setSeed((long)x * 341873128712L + (long)z * 132897987541L); this.grng.setSeed((long)x * 341873128712L + (long)z * 132897987541L);
@ -2899,7 +2898,7 @@ public final class WorldServer extends AWorldServer {
ChunkServer chunk = WorldServer.this.getChunk(this.position.x, this.position.z); ChunkServer chunk = WorldServer.this.getChunk(this.position.x, this.position.z);
if(chunk.isPopulated()) { if(chunk.isPopulated()) {
player.connection.sendPacket(Player.getPacket(WorldServer.this, chunk, true, new int[0], WorldServer.this.dimension.hasSkyLight())); player.connection.sendPacket(Player.getPacket(WorldServer.this, chunk, true, new int[0]));
} }
this.watching.remove(player); this.watching.remove(player);
@ -2991,7 +2990,7 @@ public final class WorldServer extends AWorldServer {
} }
} }
this.sendToAllPlayersWatchingChunk(Player.getPacket(WorldServer.this, WorldServer.this.getChunk(this.position.x, this.position.z), this.sendToAllPlayersWatchingChunk(Player.getPacket(WorldServer.this, WorldServer.this.getChunk(this.position.x, this.position.z),
this.biomes, extend, WorldServer.this.dimension.hasSkyLight())); this.biomes, extend));
if(this.biomes) { if(this.biomes) {
List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, Integer.MIN_VALUE, z, x + 16, Integer.MAX_VALUE, z + 16); List<TileEntity> list = WorldServer.this.getTileEntitiesIn(x, Integer.MIN_VALUE, z, x + 16, Integer.MAX_VALUE, z + 16);