3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-09-08 22:02:50 +02:00

Change Chunk#getBiomeData() to int[]

Dieser Commit ist enthalten in:
creeper123123321 2018-12-05 16:52:53 -02:00
Ursprung 83ba55dda5
Commit c5c7d36bd1
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0AC57D54786721D1
8 geänderte Dateien mit 30 neuen und 19 gelöschten Zeilen

Datei anzeigen

@ -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

Datei anzeigen

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

Datei anzeigen

@ -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);
}

Datei anzeigen

@ -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) {

Datei anzeigen

@ -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);
}
}

Datei anzeigen

@ -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

Datei anzeigen

@ -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);
}
}
}

Datei anzeigen

@ -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);
}
}
}
}