Merge pull request #1107 from creeper123123321/master

Change Chunk#getBiomeData() to int[]
This commit is contained in:
Myles 2018-12-05 19:01:25 +00:00 committed by GitHub
commit fba0a59324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 30 additions and 19 deletions

View File

@ -14,7 +14,7 @@ public class BaseChunk implements Chunk {
protected boolean groundUp;
protected int bitmask;
protected ChunkSection[] sections;
protected byte[] biomeData;
protected int[] biomeData;
protected List<CompoundTag> blockEntities;
@Override

View File

@ -15,7 +15,7 @@ public interface Chunk {
ChunkSection[] getSections();
byte[] getBiomeData();
int[] getBiomeData();
List<CompoundTag> getBlockEntities();

View File

@ -10,7 +10,7 @@ public class Chunk1_8 extends BaseChunk {
@Getter
private boolean unloadPacket = false;
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, byte[] biomeData, List<CompoundTag> blockEntities) {
public Chunk1_8(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
super(x, z, groundUp, bitmask, sections, biomeData, blockEntities);
}

View File

@ -334,7 +334,7 @@ public class WorldPackets {
if (chunk.isBiomeData()) {
int latestBiomeWarn = Integer.MIN_VALUE;
for (int i = 0; i < 256; i++) {
int biome = chunk.getBiomeData()[i] & 0xFF;
int biome = chunk.getBiomeData()[i];
if (!validBiomes.contains(biome)) {
if (biome != 255 // is it generated naturally? *shrug*
&& latestBiomeWarn != biome) {

View File

@ -52,11 +52,10 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
}
}
byte[] biomeData = groundUp ? new byte[256] : null;
int[] biomeData = groundUp ? new int[256] : null;
if (groundUp) {
for (int i = 0; i < 256; i++) {
// todo use int in Chunk?
biomeData[i] = (byte) input.readInt();;
biomeData[i] = input.readInt();
}
}
@ -99,8 +98,8 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
// Write biome data
if (chunk.isBiomeData()) {
for (byte value : chunk.getBiomeData()) {
output.writeInt(value & 0xFF); // This is a temporary workaround, we'll look into fixing this soon :)
for (int value : chunk.getBiomeData()) {
output.writeInt(value);
}
}

View File

@ -53,9 +53,11 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
}
}
byte[] biomeData = groundUp ? new byte[256] : null;
int[] biomeData = groundUp ? new int[256] : null;
if (groundUp) {
input.readBytes(biomeData);
for (int i = 0; i < 256; i++) {
biomeData[i] = input.readByte() & 0xFF;
}
}
List<CompoundTag> nbtData = new ArrayList<>(Arrays.asList(Type.NBT_ARRAY.read(input)));
@ -97,7 +99,9 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
// Write biome data
if (chunk.isBiomeData()) {
output.writeBytes(chunk.getBiomeData());
for (int biome : chunk.getBiomeData()) {
buf.writeByte((byte) biome);
}
}
// Write Block Entities

View File

@ -59,9 +59,11 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
}
}
byte[] biomeData = groundUp ? new byte[256] : null;
int[] biomeData = groundUp ? new int[256] : null;
if (groundUp) {
input.readBytes(biomeData);
for (int i = 0; i < 256; i++) {
biomeData[i] = input.readByte() & 0xFF;
}
}
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, new ArrayList<CompoundTag>());
@ -93,7 +95,9 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
// Write biome data
if (chunk.isBiomeData()) {
output.writeBytes(chunk.getBiomeData());
for (int biome : chunk.getBiomeData()) {
output.writeByte((byte) biome);
}
}
}

View File

@ -61,7 +61,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
// Data to be read
BitSet usedSections = new BitSet(16);
ChunkSection[] sections = new ChunkSection[16];
byte[] biomeData = null;
int[] biomeData = null;
// Calculate section count from bitmask
for (int i = 0; i < 16; i++) {
@ -112,8 +112,10 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
// Read biome data
if (bytesLeft >= BIOME_DATA_LENGTH) {
biomeData = new byte[BIOME_DATA_LENGTH];
input.readBytes(biomeData);
biomeData = new int[BIOME_DATA_LENGTH];
for (int i = 0; i < BIOME_DATA_LENGTH; i++){
biomeData[i] = input.readByte() & 0xFF;
}
bytesLeft -= BIOME_DATA_LENGTH;
}
@ -156,7 +158,9 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
// Write biome data
if (chunk.hasBiomeData()) {
output.writeBytes(chunk.getBiomeData());
for (int biome : chunk.getBiomeData()) {
buf.writeByte((byte) biome);
}
}
}
}