3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-28 09:00:09 +01:00

Merge pull request #1705 from KennyTV/1.16

Minor chunk type cleanup
Dieser Commit ist enthalten in:
Myles 2020-04-05 21:52:20 +01:00 committet von GitHub
Commit 19f7800173
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
12 geänderte Dateien mit 73 neuen und 98 gelöschten Zeilen

Datei anzeigen

@ -1,31 +1,34 @@
package us.myles.ViaVersion.api.minecraft.chunks; package us.myles.ViaVersion.api.minecraft.chunks;
import com.github.steveice10.opennbt.tag.builtin.CompoundTag; import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import lombok.AllArgsConstructor;
import java.util.List; import java.util.List;
@AllArgsConstructor
public class BaseChunk implements Chunk { public class BaseChunk implements Chunk {
protected final int x; protected final int x;
protected final int z; protected final int z;
protected final boolean groundUp; protected final boolean fullChunk;
protected final int bitmask; protected final int bitmask;
protected final ChunkSection[] sections; protected final ChunkSection[] sections;
protected int[] biomeData; protected int[] biomeData;
protected CompoundTag heightMap; protected CompoundTag heightMap;
protected final List<CompoundTag> blockEntities; protected final List<CompoundTag> blockEntities;
public BaseChunk(int x, int z, boolean groundUp, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) { public BaseChunk(int x, int z, boolean fullChunk, int bitmask, ChunkSection[] sections, int[] biomeData, CompoundTag heightMap, List<CompoundTag> blockEntities) {
this.x = x; this.x = x;
this.z = z; this.z = z;
this.groundUp = groundUp; this.fullChunk = fullChunk;
this.bitmask = bitmask; this.bitmask = bitmask;
this.sections = sections; this.sections = sections;
this.biomeData = biomeData; this.biomeData = biomeData;
this.heightMap = heightMap;
this.blockEntities = blockEntities; this.blockEntities = blockEntities;
} }
public BaseChunk(int x, int z, boolean fullChunk, int bitmask, ChunkSection[] sections, int[] biomeData, List<CompoundTag> blockEntities) {
this(x, z, fullChunk, bitmask, sections, biomeData, null, blockEntities);
}
@Override @Override
public boolean isBiomeData() { public boolean isBiomeData() {
return biomeData != null; return biomeData != null;
@ -42,8 +45,8 @@ public class BaseChunk implements Chunk {
} }
@Override @Override
public boolean isGroundUp() { public boolean isFullChunk() {
return groundUp; return fullChunk;
} }
@Override @Override

Datei anzeigen

@ -5,12 +5,20 @@ import com.github.steveice10.opennbt.tag.builtin.CompoundTag;
import java.util.List; import java.util.List;
public interface Chunk { public interface Chunk {
int getX(); int getX();
int getZ(); int getZ();
boolean isBiomeData(); boolean isBiomeData();
boolean isFullChunk();
@Deprecated
default boolean isGroundUp() {
return isFullChunk();
}
int getBitmask(); int getBitmask();
ChunkSection[] getSections(); ChunkSection[] getSections();
@ -24,6 +32,4 @@ public interface Chunk {
void setHeightMap(CompoundTag heightMap); void setHeightMap(CompoundTag heightMap);
List<CompoundTag> getBlockEntities(); List<CompoundTag> getBlockEntities();
boolean isGroundUp();
} }

Datei anzeigen

@ -29,12 +29,7 @@ public class Chunk1_8 extends BaseChunk {
* @return True if the chunks has biome data * @return True if the chunks has biome data
*/ */
public boolean hasBiomeData() { public boolean hasBiomeData() {
return biomeData != null && groundUp; return biomeData != null && fullChunk;
}
@Override
public boolean isBiomeData() {
return biomeData != null;
} }
public boolean isUnloadPacket() { public boolean isUnloadPacket() {

Datei anzeigen

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
public class ChunkSection { public class ChunkSection {
/** /**
* Size (dimensions) of blocks in a chunks section. * Size (dimensions) of blocks in a chunks section.
*/ */

Datei anzeigen

@ -15,7 +15,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet;
import java.util.List; import java.util.List;
import java.util.logging.Level; import java.util.logging.Level;
@ -29,22 +28,15 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
boolean groundUp = input.readBoolean(); boolean fullChunk = input.readBoolean();
int primaryBitmask = Type.VAR_INT.read(input); int primaryBitmask = Type.VAR_INT.read(input);
ByteBuf data = input.readSlice(Type.VAR_INT.read(input)); ByteBuf data = input.readSlice(Type.VAR_INT.read(input));
BitSet usedSections = new BitSet(16);
ChunkSection[] sections = new ChunkSection[16];
// Calculate section count from bitmask
for (int i = 0; i < 16; i++) {
if ((primaryBitmask & (1 << i)) != 0) {
usedSections.set(i);
}
}
// Read sections // Read sections
ChunkSection[] sections = new ChunkSection[16];
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
if (!usedSections.get(i)) continue; // Section not set if ((primaryBitmask & (1 << i)) == 0) continue; // Section not set
ChunkSection section = Types1_13.CHUNK_SECTION.read(data); ChunkSection section = Types1_13.CHUNK_SECTION.read(data);
sections[i] = section; sections[i] = section;
section.readBlockLight(data); section.readBlockLight(data);
@ -53,14 +45,14 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
} }
} }
int[] biomeData = groundUp ? new int[256] : null; int[] biomeData = fullChunk ? new int[256] : null;
if (groundUp) { if (fullChunk) {
if (data.readableBytes() >= 256 * 4) { if (data.readableBytes() >= 256 * 4) {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
biomeData[i] = data.readInt(); biomeData[i] = data.readInt();
} }
} else { } else {
Via.getPlatform().getLogger().log(Level.WARNING, "Chunk x="+ chunkX + " z=" + chunkZ + " doesn't have biome data!"); Via.getPlatform().getLogger().log(Level.WARNING, "Chunk x=" + chunkX + " z=" + chunkZ + " doesn't have biome data!");
} }
} }
@ -74,7 +66,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
} }
} }
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData); return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, nbtData);
} }
@Override @Override
@ -82,7 +74,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
output.writeBoolean(chunk.isGroundUp()); output.writeBoolean(chunk.isFullChunk());
Type.VAR_INT.write(output, chunk.getBitmask()); Type.VAR_INT.write(output, chunk.getBitmask());
ByteBuf buf = output.alloc().buffer(); ByteBuf buf = output.alloc().buffer();
@ -98,7 +90,7 @@ public class Chunk1_13Type extends PartialType<Chunk, ClientWorld> {
} }
buf.readerIndex(0); buf.readerIndex(0);
Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 * 4 : 0)); Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 1024 : 0));
output.writeBytes(buf); output.writeBytes(buf);
} finally { } finally {
buf.release(); // release buffer buf.release(); // release buffer

Datei anzeigen

@ -199,12 +199,12 @@ public class WorldPackets {
lightPacket.write(Type.VAR_INT, chunk.getX()); lightPacket.write(Type.VAR_INT, chunk.getX());
lightPacket.write(Type.VAR_INT, chunk.getZ()); lightPacket.write(Type.VAR_INT, chunk.getZ());
int skyLightMask = chunk.isGroundUp() ? 0x3ffff : 0; // all 18 bits set if ground up int skyLightMask = chunk.isFullChunk() ? 0x3ffff : 0; // all 18 bits set if ground up
int blockLightMask = 0; int blockLightMask = 0;
for (int i = 0; i < chunk.getSections().length; i++) { for (int i = 0; i < chunk.getSections().length; i++) {
ChunkSection sec = chunk.getSections()[i]; ChunkSection sec = chunk.getSections()[i];
if (sec == null) continue; if (sec == null) continue;
if (!chunk.isGroundUp() && sec.hasSkyLight()) { if (!chunk.isFullChunk() && sec.hasSkyLight()) {
skyLightMask |= (1 << (i + 1)); skyLightMask |= (1 << (i + 1));
} }
blockLightMask |= (1 << (i + 1)); blockLightMask |= (1 << (i + 1));
@ -217,18 +217,18 @@ public class WorldPackets {
// not sending skylight/setting empty skylight causes client lag due to some weird calculations // not sending skylight/setting empty skylight causes client lag due to some weird calculations
// only do this on the initial chunk send (not when chunk.isGroundUp() is false) // only do this on the initial chunk send (not when chunk.isGroundUp() is false)
if (chunk.isGroundUp()) if (chunk.isFullChunk())
lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk below 0 lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk below 0
for (ChunkSection section : chunk.getSections()) { for (ChunkSection section : chunk.getSections()) {
if (section == null || !section.hasSkyLight()) { if (section == null || !section.hasSkyLight()) {
if (chunk.isGroundUp()) { if (chunk.isFullChunk()) {
lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT);
} }
continue; continue;
} }
lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, section.getSkyLight()); lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, section.getSkyLight());
} }
if (chunk.isGroundUp()) if (chunk.isFullChunk())
lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk above 255 lightPacket.write(Type.BYTE_ARRAY_PRIMITIVE, FULL_LIGHT); // chunk above 255
for (ChunkSection section : chunk.getSections()) { for (ChunkSection section : chunk.getSections()) {

Datei anzeigen

@ -14,7 +14,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet;
import java.util.List; import java.util.List;
public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> { public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
@ -28,31 +27,25 @@ public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
boolean groundUp = input.readBoolean(); boolean fullChunk = 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);
Type.VAR_INT.read(input); Type.VAR_INT.read(input);
BitSet usedSections = new BitSet(16);
ChunkSection[] sections = new ChunkSection[16];
// Calculate section count from bitmask
for (int i = 0; i < 16; i++) {
if ((primaryBitmask & (1 << i)) != 0) {
usedSections.set(i);
}
}
// Read sections // Read sections
ChunkSection[] sections = new ChunkSection[16];
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
if (!usedSections.get(i)) continue; // Section not set if ((primaryBitmask & (1 << i)) == 0) continue; // Section not set
short nonAirBlocksCount = input.readShort(); short nonAirBlocksCount = input.readShort();
ChunkSection section = Types1_13.CHUNK_SECTION.read(input); ChunkSection section = Types1_13.CHUNK_SECTION.read(input);
section.setNonAirBlocksCount(nonAirBlocksCount); section.setNonAirBlocksCount(nonAirBlocksCount);
sections[i] = section; sections[i] = section;
} }
int[] biomeData = groundUp ? new int[256] : null; int[] biomeData = fullChunk ? new int[256] : null;
if (groundUp) { if (fullChunk) {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
biomeData[i] = input.readInt(); biomeData[i] = input.readInt();
} }
@ -68,7 +61,7 @@ public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
} }
} }
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, heightMap, nbtData); return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, heightMap, nbtData);
} }
@Override @Override
@ -76,7 +69,7 @@ public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
output.writeBoolean(chunk.isGroundUp()); output.writeBoolean(chunk.isFullChunk());
Type.VAR_INT.write(output, chunk.getBitmask()); Type.VAR_INT.write(output, chunk.getBitmask());
Type.NBT.write(output, chunk.getHeightMap()); Type.NBT.write(output, chunk.getHeightMap());
@ -85,11 +78,12 @@ public class Chunk1_14Type extends PartialType<Chunk, ClientWorld> {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
ChunkSection section = chunk.getSections()[i]; ChunkSection section = chunk.getSections()[i];
if (section == null) continue; // Section not set if (section == null) continue; // Section not set
buf.writeShort(section.getNonAirBlocksCount()); buf.writeShort(section.getNonAirBlocksCount());
Types1_13.CHUNK_SECTION.write(buf, section); Types1_13.CHUNK_SECTION.write(buf, section);
} }
buf.readerIndex(0); buf.readerIndex(0);
Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 * 4 : 0)); Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 1024 : 0)); // 256 * 4
output.writeBytes(buf); output.writeBytes(buf);
} finally { } finally {
buf.release(); // release buffer buf.release(); // release buffer

Datei anzeigen

@ -42,7 +42,7 @@ 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()) { if (chunk.isFullChunk()) {
int[] biomeData = chunk.getBiomeData(); int[] biomeData = chunk.getBiomeData();
int[] newBiomeData = new int[1024]; int[] newBiomeData = new int[1024];
if (biomeData != null) { if (biomeData != null) {

Datei anzeigen

@ -14,10 +14,10 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet;
import java.util.List; import java.util.List;
public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> { public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
private static final CompoundTag[] A = new CompoundTag[0];
public Chunk1_15Type(ClientWorld param) { public Chunk1_15Type(ClientWorld param) {
super(param, Chunk.class); super(param, Chunk.class);
@ -28,31 +28,24 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
boolean groundUp = input.readBoolean(); boolean fullChunk = 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; int[] biomeData = fullChunk ? new int[1024] : null;
if (groundUp) { if (fullChunk) {
for (int i = 0; i < 1024; i++) { for (int i = 0; i < 1024; i++) {
biomeData[i] = input.readInt(); biomeData[i] = input.readInt();
} }
} }
Type.VAR_INT.read(input); Type.VAR_INT.read(input); // data size in bytes
BitSet usedSections = new BitSet(16);
ChunkSection[] sections = new ChunkSection[16];
// Calculate section count from bitmask
for (int i = 0; i < 16; i++) {
if ((primaryBitmask & (1 << i)) != 0) {
usedSections.set(i);
}
}
// Read sections // Read sections
ChunkSection[] sections = new ChunkSection[16];
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
if (!usedSections.get(i)) continue; // Section not set if ((primaryBitmask & (1 << i)) == 0) continue; // Section not set
short nonAirBlocksCount = input.readShort(); short nonAirBlocksCount = input.readShort();
ChunkSection section = Types1_13.CHUNK_SECTION.read(input); ChunkSection section = Types1_13.CHUNK_SECTION.read(input);
section.setNonAirBlocksCount(nonAirBlocksCount); section.setNonAirBlocksCount(nonAirBlocksCount);
@ -69,7 +62,7 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
} }
} }
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, heightMap, nbtData); return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, heightMap, nbtData);
} }
@Override @Override
@ -77,7 +70,7 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
output.writeBoolean(chunk.isGroundUp()); output.writeBoolean(chunk.isFullChunk());
Type.VAR_INT.write(output, chunk.getBitmask()); Type.VAR_INT.write(output, chunk.getBitmask());
Type.NBT.write(output, chunk.getHeightMap()); Type.NBT.write(output, chunk.getHeightMap());
@ -93,6 +86,7 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
ChunkSection section = chunk.getSections()[i]; ChunkSection section = chunk.getSections()[i];
if (section == null) continue; // Section not set if (section == null) continue; // Section not set
buf.writeShort(section.getNonAirBlocksCount()); buf.writeShort(section.getNonAirBlocksCount());
Types1_13.CHUNK_SECTION.write(buf, section); Types1_13.CHUNK_SECTION.write(buf, section);
} }
@ -104,7 +98,7 @@ public class Chunk1_15Type extends PartialType<Chunk, ClientWorld> {
} }
// Write Block Entities // Write Block Entities
Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(new CompoundTag[0])); Type.NBT_ARRAY.write(output, chunk.getBlockEntities().toArray(A));
} }
@Override @Override

Datei anzeigen

@ -15,7 +15,6 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.BitSet;
import java.util.List; import java.util.List;
public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> { public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
@ -29,22 +28,15 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
boolean groundUp = input.readBoolean(); boolean fullChunk = input.readBoolean();
int primaryBitmask = Type.VAR_INT.read(input); int primaryBitmask = Type.VAR_INT.read(input);
Type.VAR_INT.read(input); Type.VAR_INT.read(input);
BitSet usedSections = new BitSet(16);
ChunkSection[] sections = new ChunkSection[16];
// Calculate section count from bitmask
for (int i = 0; i < 16; i++) {
if ((primaryBitmask & (1 << i)) != 0) {
usedSections.set(i);
}
}
// Read sections // Read sections
ChunkSection[] sections = new ChunkSection[16];
for (int i = 0; i < 16; i++) { for (int i = 0; i < 16; i++) {
if (!usedSections.get(i)) continue; // Section not set if ((primaryBitmask & (1 << i)) == 0) continue; // Section not set
ChunkSection section = Types1_9.CHUNK_SECTION.read(input); ChunkSection section = Types1_9.CHUNK_SECTION.read(input);
sections[i] = section; sections[i] = section;
section.readBlockLight(input); section.readBlockLight(input);
@ -53,8 +45,8 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
} }
} }
int[] biomeData = groundUp ? new int[256] : null; int[] biomeData = fullChunk ? new int[256] : null;
if (groundUp) { if (fullChunk) {
for (int i = 0; i < 256; i++) { for (int i = 0; i < 256; i++) {
biomeData[i] = input.readByte() & 0xFF; biomeData[i] = input.readByte() & 0xFF;
} }
@ -70,7 +62,7 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
} }
} }
return new BaseChunk(chunkX, chunkZ, groundUp, primaryBitmask, sections, biomeData, nbtData); return new BaseChunk(chunkX, chunkZ, fullChunk, primaryBitmask, sections, biomeData, nbtData);
} }
@Override @Override
@ -78,7 +70,7 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
output.writeBoolean(chunk.isGroundUp()); output.writeBoolean(chunk.isFullChunk());
Type.VAR_INT.write(output, chunk.getBitmask()); Type.VAR_INT.write(output, chunk.getBitmask());
ByteBuf buf = output.alloc().buffer(); ByteBuf buf = output.alloc().buffer();
@ -91,7 +83,6 @@ public class Chunk1_9_3_4Type extends PartialType<Chunk, ClientWorld> {
if (!section.hasSkyLight()) continue; // No sky light, we're done here. if (!section.hasSkyLight()) continue; // No sky light, we're done here.
section.writeSkyLight(buf); section.writeSkyLight(buf);
} }
buf.readerIndex(0); buf.readerIndex(0);
Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 : 0)); Type.VAR_INT.write(output, buf.readableBytes() + (chunk.isBiomeData() ? 256 : 0));

Datei anzeigen

@ -75,7 +75,7 @@ public class Chunk1_9_1_2Type extends PartialType<Chunk, ClientWorld> {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
output.writeBoolean(chunk.isGroundUp()); output.writeBoolean(chunk.isFullChunk());
Type.VAR_INT.write(output, chunk.getBitmask()); Type.VAR_INT.write(output, chunk.getBitmask());
ByteBuf buf = output.alloc().buffer(); ByteBuf buf = output.alloc().buffer();

Datei anzeigen

@ -54,7 +54,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
int chunkX = input.readInt(); int chunkX = input.readInt();
int chunkZ = input.readInt(); int chunkZ = input.readInt();
long chunkHash = toLong(chunkX, chunkZ); long chunkHash = toLong(chunkX, chunkZ);
boolean groundUp = input.readByte() != 0; boolean fullChunk = input.readByte() != 0;
int bitmask = input.readUnsignedShort(); int bitmask = input.readUnsignedShort();
int dataLength = Type.VAR_INT.read(input); int dataLength = Type.VAR_INT.read(input);
@ -74,7 +74,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
// If the chunks is from a chunks bulk, it is never an unload packet // If the chunks is from a chunks bulk, it is never an unload packet
// Other wise, if it has no data, it is :) // Other wise, if it has no data, it is :)
boolean isBulkPacket = param.getBulkChunks().remove(chunkHash); boolean isBulkPacket = param.getBulkChunks().remove(chunkHash);
if (sectionCount == 0 && groundUp && !isBulkPacket && param.getLoadedChunks().contains(chunkHash)) { if (sectionCount == 0 && fullChunk && !isBulkPacket && param.getLoadedChunks().contains(chunkHash)) {
// This is a chunks unload packet // This is a chunks unload packet
param.getLoadedChunks().remove(chunkHash); param.getLoadedChunks().remove(chunkHash);
return new Chunk1_8(chunkX, chunkZ); return new Chunk1_8(chunkX, chunkZ);
@ -121,11 +121,11 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
// Check remaining bytes // Check remaining bytes
if (bytesLeft > 0) { if (bytesLeft > 0) {
Via.getPlatform().getLogger().log(Level.WARNING, bytesLeft + " Bytes left after reading chunks! (" + groundUp + ")"); Via.getPlatform().getLogger().log(Level.WARNING, bytesLeft + " Bytes left after reading chunks! (" + fullChunk + ")");
} }
// Return chunks // Return chunks
return new Chunk1_8(chunkX, chunkZ, groundUp, bitmask, sections, biomeData, new ArrayList<CompoundTag>()); return new Chunk1_8(chunkX, chunkZ, fullChunk, bitmask, sections, biomeData, new ArrayList<CompoundTag>());
} }
@Override @Override
@ -137,7 +137,7 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
output.writeInt(chunk.getX()); output.writeInt(chunk.getX());
output.writeInt(chunk.getZ()); output.writeInt(chunk.getZ());
if (chunk.isUnloadPacket()) return; if (chunk.isUnloadPacket()) return;
output.writeByte(chunk.isGroundUp() ? 0x01 : 0x00); output.writeByte(chunk.isFullChunk() ? 0x01 : 0x00);
Type.VAR_INT.write(output, chunk.getBitmask()); Type.VAR_INT.write(output, chunk.getBitmask());
ByteBuf buf = output.alloc().buffer(); ByteBuf buf = output.alloc().buffer();
@ -150,7 +150,6 @@ public class Chunk1_9to1_8Type extends PartialType<Chunk, ClientChunks> {
if (!section.hasSkyLight()) continue; // No sky light, we're done here. if (!section.hasSkyLight()) continue; // No sky light, we're done here.
section.writeSkyLight(buf); section.writeSkyLight(buf);
} }
buf.readerIndex(0); buf.readerIndex(0);
Type.VAR_INT.write(output, buf.readableBytes() + (chunk.hasBiomeData() ? 256 : 0)); Type.VAR_INT.write(output, buf.readableBytes() + (chunk.hasBiomeData() ? 256 : 0));