Don't send chunk packets with no chunks :)

This commit is contained in:
Myles 2016-03-08 21:13:15 +00:00
parent 126ee6e03f
commit fc4a617da7
2 changed files with 9 additions and 2 deletions

View File

@ -47,18 +47,21 @@ public class NetUtil {
// 2 = Get block light.
// 3 = Get sky light.
Chunk[] chunks = new Chunk[16];
int chunkCount = 0;
for (int pass = 0; pass < 4; pass++) {
if(pass == 1){
if(chunkCount == 0) return null;
}
for (int ind = 0; ind < 16; ind++) {
if ((bitmask & 1 << ind) != 0) {
if (pass == 0) {
chunkCount++;
// Block length + Blocklight length
expected += (4096 * 2) + 2048;
}
if (pass == 1) {
chunks[ind] = new Chunk(sky || hasSkyLight);
buf.position(pos / 2);
int buffPos = buf.position();
// convert short array to new one
@ -109,6 +112,7 @@ public class NetUtil {
}
Column column = new Column(x, z, chunks, biomeData);
System.out.println("Chunk " + x + " " + z + " count: " + chunkCount);
return column;
}
}

View File

@ -770,6 +770,9 @@ public class OutgoingTransformer {
}
}
Column read = NetUtil.readOldChunkData(chunkX, chunkZ, groundUp, bitMask, data, true, sk);
if (read == null) {
throw new CancelException();
}
// Write chunk section array :((
ByteBuf temp = output.alloc().buffer();
try {