mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-26 12:05:41 +01:00
Merge pull request #1548 from KennyTV/dev
Convert biome data to 1.15 format
This commit is contained in:
commit
4bb4b96a10
@ -17,6 +17,8 @@ public interface Chunk {
|
||||
|
||||
int[] getBiomeData();
|
||||
|
||||
void setBiomeData(int[] biomeData);
|
||||
|
||||
CompoundTag getHeightMap();
|
||||
|
||||
void setHeightMap(CompoundTag heightMap);
|
||||
|
@ -83,6 +83,26 @@ public class WorldPackets {
|
||||
Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld));
|
||||
wrapper.write(new Chunk1_15Type(clientWorld), chunk);
|
||||
|
||||
if (chunk.isGroundUp()) {
|
||||
int[] biomeData = chunk.getBiomeData();
|
||||
int[] newBiomeData = new int[1024];
|
||||
// Now in 4x4x4 areas - take the biome of each "middle"
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
int x = (j << 2) + 2;
|
||||
int z = (i << 2) + 2;
|
||||
int oldIndex = (z << 4 | x);
|
||||
newBiomeData[i << 2 | j] = biomeData[oldIndex];
|
||||
}
|
||||
}
|
||||
// ... and copy it to the new y layers
|
||||
for (int i = 1; i < 64; ++i) {
|
||||
System.arraycopy(newBiomeData, 0, newBiomeData, i * 16, 16);
|
||||
}
|
||||
|
||||
chunk.setBiomeData(newBiomeData);
|
||||
}
|
||||
|
||||
for (int s = 0; s < 16; s++) {
|
||||
ChunkSection section = chunk.getSections()[s];
|
||||
if (section == null) continue;
|
||||
|
@ -31,6 +31,14 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
|
||||
boolean groundUp = input.readBoolean();
|
||||
int primaryBitmask = Type.VAR_INT.read(input);
|
||||
CompoundTag heightMap = Type.NBT.read(input);
|
||||
|
||||
int[] biomeData = groundUp ? new int[1024] : null;
|
||||
if (groundUp) {
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
biomeData[i] = input.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
Type.VAR_INT.read(input);
|
||||
|
||||
BitSet usedSections = new BitSet(16);
|
||||
@ -42,15 +50,6 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
|
||||
}
|
||||
}
|
||||
|
||||
int[] biomeData = groundUp ? new int[256] : null;
|
||||
if (groundUp) {
|
||||
//TODO Why 1024 ints?
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
//biomeData[i] = input.readInt();
|
||||
input.readInt();
|
||||
}
|
||||
}
|
||||
|
||||
// Read sections
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if (!usedSections.get(i)) continue; // Section not set
|
||||
@ -84,13 +83,9 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
|
||||
|
||||
// Write biome data
|
||||
if (chunk.isBiomeData()) {
|
||||
//TODO Why 1024 ints?
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
output.writeInt(0);
|
||||
for (int value : chunk.getBiomeData()) {
|
||||
output.writeInt(value);
|
||||
}
|
||||
/*for (int value : chunk.getBiomeData()) {
|
||||
output.writeInt(value & 0xFF); // This is a temporary workaround, we'll look into fixing this soon :)
|
||||
}*/
|
||||
}
|
||||
|
||||
ByteBuf buf = output.alloc().buffer();
|
||||
|
Loading…
Reference in New Issue
Block a user