Minor cleanup.

This commit is contained in:
Steveice10 2016-12-15 16:13:24 -08:00
parent 9ec44e6d40
commit 5c4cebdcac
4 changed files with 13 additions and 17 deletions

View file

@ -11,11 +11,11 @@ public class Column {
private boolean skylight;
public Column(int x, int z, Chunk chunks[], CompoundTag tileEntities[]) {
public Column(int x, int z, Chunk chunks[], CompoundTag[] tileEntities) {
this(x, z, chunks, null, tileEntities);
}
public Column(int x, int z, Chunk chunks[], byte biomeData[], CompoundTag tileEntities[]) {
public Column(int x, int z, Chunk chunks[], byte biomeData[], CompoundTag[] tileEntities) {
if(chunks.length != 16) {
throw new IllegalArgumentException("Chunk array length must be 16.");
}
@ -26,9 +26,9 @@ public class Column {
this.skylight = false;
boolean noSkylight = false;
for (Chunk chunk : chunks) {
if (chunk != null) {
if (chunk.getSkyLight() == null) {
for(Chunk chunk : chunks) {
if(chunk != null) {
if(chunk.getSkyLight() == null) {
noSkylight = true;
} else {
this.skylight = true;
@ -44,7 +44,7 @@ public class Column {
this.z = z;
this.chunks = chunks;
this.biomeData = biomeData;
this.tileEntities = tileEntities;
this.tileEntities = tileEntities != null ? tileEntities : new CompoundTag[0];
}
public int getX() {

View file

@ -14,7 +14,7 @@ public class FlexibleStorage {
public FlexibleStorage(int bitsPerEntry, long[] data) {
if(bitsPerEntry < 1 || bitsPerEntry > 32) {
throw new IllegalArgumentException("BitsPerEntry cannot be outside of accepted range.");
throw new IllegalArgumentException("BitsPerEntry \"" + bitsPerEntry + "\" is outside of accepted range.");
}
this.bitsPerEntry = bitsPerEntry;

View file

@ -35,9 +35,10 @@ public class ServerChunkDataPacket implements Packet {
int chunkMask = in.readVarInt();
byte data[] = in.readBytes(in.readVarInt());
CompoundTag[] tileEntities = new CompoundTag[in.readVarInt()];
for (int i = 0; i < tileEntities.length; i++) {
for(int i = 0; i < tileEntities.length; i++) {
tileEntities[i] = NetUtil.readNBT(in);
}
this.column = NetUtil.readColumn(data, x, z, fullChunk, false, chunkMask, tileEntities);
}
@ -53,16 +54,10 @@ public class ServerChunkDataPacket implements Packet {
out.writeVarInt(mask);
out.writeVarInt(byteOut.size());
out.writeBytes(byteOut.toByteArray(), byteOut.size());
ByteArrayOutputStream tileEntitiesByteOut = new ByteArrayOutputStream();
NetOutput tileEntitiesNetOut = new StreamNetOutput(tileEntitiesByteOut);
for (CompoundTag compoundTag : column.getTileEntities()) {
NetUtil.writeNBT(tileEntitiesNetOut, compoundTag);
out.writeVarInt(this.column.getTileEntities().length);
for(CompoundTag tag : this.column.getTileEntities()) {
NetUtil.writeNBT(out, tag);
}
out.writeVarInt(column.getTileEntities().length);
out.writeBytes(tileEntitiesByteOut.toByteArray(), tileEntitiesByteOut.size());
}
@Override

View file

@ -255,6 +255,7 @@ public class NetUtil {
if(fullChunk) {
biomeData = in.readBytes(256);
}
column = new Column(x, z, chunks, biomeData, tileEntities);
} catch(Exception e) {
ex = e;