Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-03 14:50:30 +01:00
Minor improvements (#2709)
Dieser Commit ist enthalten in:
Ursprung
fd9346d4da
Commit
3f229c4cb9
@ -141,6 +141,8 @@ public class WorldPackets {
|
||||
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
|
||||
Chunk chunk = wrapper.read(new Chunk1_8Type(clientWorld));
|
||||
|
||||
long chunkHash = ClientChunks.toLong(chunk.getX(), chunk.getZ());
|
||||
|
||||
// Check if the chunk should be handled as an unload packet
|
||||
if (chunk.isFullChunk() && chunk.getBitmask() == 0) {
|
||||
wrapper.setPacketType(ClientboundPackets1_9.UNLOAD_CHUNK);
|
||||
@ -151,7 +153,7 @@ public class WorldPackets {
|
||||
CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
|
||||
provider.unloadChunk(wrapper.user(), chunk.getX(), chunk.getZ());
|
||||
|
||||
clientChunks.getLoadedChunks().remove(ClientChunks.toLong(chunk.getX(), chunk.getZ()));
|
||||
clientChunks.getLoadedChunks().remove(chunkHash);
|
||||
|
||||
// Unload the empty chunks
|
||||
if (Via.getConfig().isChunkBorderFix()) {
|
||||
@ -167,9 +169,10 @@ public class WorldPackets {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
wrapper.write(new Chunk1_9_1_2Type(clientWorld), chunk);
|
||||
Type<Chunk> chunkType = new Chunk1_9_1_2Type(clientWorld);
|
||||
wrapper.write(chunkType, chunk);
|
||||
|
||||
clientChunks.getLoadedChunks().add(ClientChunks.toLong(chunk.getX(), chunk.getZ()));
|
||||
clientChunks.getLoadedChunks().add(chunkHash);
|
||||
|
||||
// Send empty chunks surrounding the loaded chunk to force 1.9+ clients to render the new chunk
|
||||
if (Via.getConfig().isChunkBorderFix()) {
|
||||
@ -179,7 +182,7 @@ public class WorldPackets {
|
||||
if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) {
|
||||
PacketWrapper emptyChunk = wrapper.create(ClientboundPackets1_9.CHUNK_DATA);
|
||||
Chunk c = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], new int[256], new ArrayList<>());
|
||||
emptyChunk.write(new Chunk1_9_1_2Type(wrapper.user().get(ClientWorld.class)), c);
|
||||
emptyChunk.write(chunkType, c);
|
||||
emptyChunk.send(Protocol1_9To1_8.class);
|
||||
}
|
||||
}
|
||||
@ -199,10 +202,11 @@ public class WorldPackets {
|
||||
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
|
||||
Chunk[] chunks = wrapper.read(new ChunkBulk1_8Type(clientWorld));
|
||||
|
||||
Type<Chunk> chunkType = new Chunk1_9_1_2Type(clientWorld);
|
||||
// Split into multiple chunk packets
|
||||
for (Chunk chunk : chunks) {
|
||||
PacketWrapper chunkData = wrapper.create(ClientboundPackets1_9.CHUNK_DATA);
|
||||
chunkData.write(new Chunk1_9_1_2Type(clientWorld), chunk);
|
||||
chunkData.write(chunkType, chunk);
|
||||
chunkData.send(Protocol1_9To1_8.class);
|
||||
|
||||
clientChunks.getLoadedChunks().add(ClientChunks.toLong(chunk.getX(), chunk.getZ()));
|
||||
@ -215,7 +219,7 @@ public class WorldPackets {
|
||||
if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) {
|
||||
PacketWrapper emptyChunk = wrapper.create(ClientboundPackets1_9.CHUNK_DATA);
|
||||
Chunk c = new BaseChunk(chunkX, chunkZ, true, false, 0, new ChunkSection[16], new int[256], new ArrayList<>());
|
||||
emptyChunk.write(new Chunk1_9_1_2Type(wrapper.user().get(ClientWorld.class)), c);
|
||||
emptyChunk.write(chunkType, c);
|
||||
emptyChunk.send(Protocol1_9To1_8.class);
|
||||
}
|
||||
}
|
||||
@ -459,44 +463,4 @@ public class WorldPackets {
|
||||
});
|
||||
}
|
||||
|
||||
public static final class ChunkBulkSection {
|
||||
private final int x;
|
||||
private final int z;
|
||||
private final int bitMask;
|
||||
private final int length;
|
||||
private byte[] data;
|
||||
|
||||
public ChunkBulkSection(PacketWrapper wrapper, boolean skylight) throws Exception {
|
||||
x = wrapper.read(Type.INT);
|
||||
z = wrapper.read(Type.INT);
|
||||
bitMask = wrapper.read(Type.UNSIGNED_SHORT);
|
||||
|
||||
int bitCount = Integer.bitCount(bitMask);
|
||||
length = (bitCount * ((4096 * 2) + 2048)) + (skylight ? bitCount * 2048 : 0) + 256; // Thanks MCProtocolLib
|
||||
}
|
||||
|
||||
public int getX() {
|
||||
return x;
|
||||
}
|
||||
|
||||
public int getZ() {
|
||||
return z;
|
||||
}
|
||||
|
||||
public int getBitMask() {
|
||||
return bitMask;
|
||||
}
|
||||
|
||||
public int getLength() {
|
||||
return length;
|
||||
}
|
||||
|
||||
public byte @Nullable [] getData() {
|
||||
return data;
|
||||
}
|
||||
|
||||
public void setData(byte[] data) {
|
||||
this.data = data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -65,12 +65,11 @@ public class ChunkBulk1_8Type extends PartialType<Chunk[], ClientWorld> {
|
||||
@Override
|
||||
public void write(ByteBuf output, ClientWorld world, Chunk[] chunks) throws Exception {
|
||||
boolean skyLight = false;
|
||||
for (Chunk c : chunks) {
|
||||
loop1: for (Chunk c : chunks) {
|
||||
for (ChunkSection section : c.getSections()) {
|
||||
if (section != null) {
|
||||
if (section.getLight().hasSkyLight()) {
|
||||
if (section != null && section.getLight().hasSkyLight()) {
|
||||
skyLight = true;
|
||||
}
|
||||
break loop1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren