3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Convert biome data to 1.15 format

Dieser Commit ist enthalten in:
KennyTV 2019-12-02 11:20:48 +01:00
Ursprung ff7cb4bbbe
Commit decb20d2d1
3 geänderte Dateien mit 32 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -17,6 +17,8 @@ public interface Chunk {
int[] getBiomeData(); int[] getBiomeData();
void setBiomeData(int[] biomeData);
CompoundTag getHeightMap(); CompoundTag getHeightMap();
void setHeightMap(CompoundTag heightMap); void setHeightMap(CompoundTag heightMap);

Datei anzeigen

@ -83,6 +83,26 @@ public class WorldPackets {
Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld)); Chunk chunk = wrapper.read(new Chunk1_14Type(clientWorld));
wrapper.write(new Chunk1_15Type(clientWorld), chunk); wrapper.write(new Chunk1_15Type(clientWorld), chunk);
if (chunk.isGroundUp()) {
int[] biomeData = chunk.getBiomeData();
int[] newBiomeData = new int[1024];
// Now in 4x4x4 areas (x, then z, then y)
// Set the x/z data
int i = 0;
for (int z = 1; z <= 16; z += 4) {
for (int x = 1; x <= 16; x += 4) {
int biome = biomeData[(x * z) - 1];
// Extend it on the y axis
for (int y = 0; y < 1024; y += 16) {
newBiomeData[i + y] = biome;
}
i++;
}
}
chunk.setBiomeData(newBiomeData);
}
for (int s = 0; s < 16; s++) { for (int s = 0; s < 16; s++) {
ChunkSection section = chunk.getSections()[s]; ChunkSection section = chunk.getSections()[s];
if (section == null) continue; if (section == null) continue;

Datei anzeigen

@ -31,6 +31,14 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
boolean groundUp = input.readBoolean(); boolean groundUp = input.readBoolean();
int primaryBitmask = Type.VAR_INT.read(input); int primaryBitmask = Type.VAR_INT.read(input);
CompoundTag heightMap = Type.NBT.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); Type.VAR_INT.read(input);
BitSet usedSections = new BitSet(16); 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 // Read sections
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
if (!usedSections.get(i)) continue; // Section not set if (!usedSections.get(i)) continue; // Section not set
@ -84,13 +83,9 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
// Write biome data // Write biome data
if (chunk.isBiomeData()) { if (chunk.isBiomeData()) {
//TODO Why 1024 ints? for (int value : chunk.getBiomeData()) {
for (int i = 0; i < 1024; i++) { output.writeInt(value);
output.writeInt(0);
} }
/*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(); ByteBuf buf = output.alloc().buffer();