mirror of
https://github.com/GeyserMC/MCProtocolLib.git
synced 2024-12-04 21:01:02 -05:00
Update chunk reading/writing
This commit is contained in:
parent
75d4540f8f
commit
1520ef7deb
3 changed files with 12 additions and 10 deletions
|
@ -33,7 +33,7 @@ public class BlockStorage {
|
|||
this.bitsPerEntry = in.readUnsignedByte();
|
||||
|
||||
this.states = new ArrayList<BlockState>();
|
||||
int stateCount = in.readVarInt();
|
||||
int stateCount = this.bitsPerEntry > 8 ? 0 : in.readVarInt();
|
||||
for(int i = 0; i < stateCount; i++) {
|
||||
this.states.add(NetUtil.readBlockState(in));
|
||||
}
|
||||
|
@ -56,9 +56,11 @@ public class BlockStorage {
|
|||
public void write(NetOutput out) throws IOException {
|
||||
out.writeByte(this.bitsPerEntry);
|
||||
|
||||
out.writeVarInt(this.states.size());
|
||||
for(BlockState state : this.states) {
|
||||
NetUtil.writeBlockState(out, state);
|
||||
if (this.bitsPerEntry <= 8) {
|
||||
out.writeVarInt(this.states.size());
|
||||
for (BlockState state : this.states) {
|
||||
NetUtil.writeBlockState(out, state);
|
||||
}
|
||||
}
|
||||
|
||||
long[] data = this.storage.getData();
|
||||
|
|
|
@ -9,7 +9,7 @@ public class Column {
|
|||
private int x;
|
||||
private int z;
|
||||
private Chunk chunks[];
|
||||
private byte biomeData[];
|
||||
private int biomeData[];
|
||||
private CompoundTag tileEntities[];
|
||||
|
||||
private boolean skylight;
|
||||
|
@ -18,7 +18,7 @@ public class Column {
|
|||
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[], int biomeData[], CompoundTag[] tileEntities) {
|
||||
if(chunks.length != 16) {
|
||||
throw new IllegalArgumentException("Chunk array length must be 16.");
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ public class Column {
|
|||
return this.biomeData != null;
|
||||
}
|
||||
|
||||
public byte[] getBiomeData() {
|
||||
public int[] getBiomeData() {
|
||||
return this.biomeData;
|
||||
}
|
||||
|
||||
|
|
|
@ -329,9 +329,9 @@ public class NetUtil {
|
|||
}
|
||||
}
|
||||
|
||||
byte biomeData[] = null;
|
||||
int biomeData[] = null;
|
||||
if(fullChunk) {
|
||||
biomeData = in.readBytes(256);
|
||||
biomeData = in.readInts(256);
|
||||
}
|
||||
|
||||
column = new Column(x, z, chunks, biomeData, tileEntities);
|
||||
|
@ -365,7 +365,7 @@ public class NetUtil {
|
|||
}
|
||||
|
||||
if(fullChunk) {
|
||||
out.writeBytes(column.getBiomeData());
|
||||
out.writeInts(column.getBiomeData());
|
||||
}
|
||||
|
||||
return mask;
|
||||
|
|
Loading…
Reference in a new issue