3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-08 17:20:24 +01:00

Merge remote-tracking branch 'origin/master' into dev

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-10-11 21:04:29 +02:00
Commit 03f929163c
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
4 geänderte Dateien mit 16 neuen und 53 gelöschten Zeilen

Datei anzeigen

@ -8,5 +8,5 @@ repositories {
dependencies { dependencies {
// version must be manually kept in sync with the one in root project settings.gradle.kts // version must be manually kept in sync with the one in root project settings.gradle.kts
implementation("gradle.plugin.com.github.jengelman.gradle.plugins", "shadow", "7.0.0") implementation("gradle.plugin.com.github.johnrengelman", "shadow", "7.1.0")
} }

Datei anzeigen

@ -141,6 +141,8 @@ public class WorldPackets {
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class); ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
Chunk chunk = wrapper.read(new Chunk1_8Type(clientWorld)); 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 // Check if the chunk should be handled as an unload packet
if (chunk.isFullChunk() && chunk.getBitmask() == 0) { if (chunk.isFullChunk() && chunk.getBitmask() == 0) {
wrapper.setPacketType(ClientboundPackets1_9.UNLOAD_CHUNK); wrapper.setPacketType(ClientboundPackets1_9.UNLOAD_CHUNK);
@ -151,7 +153,7 @@ public class WorldPackets {
CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class); CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
provider.unloadChunk(wrapper.user(), chunk.getX(), chunk.getZ()); 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 // Unload the empty chunks
if (Via.getConfig().isChunkBorderFix()) { if (Via.getConfig().isChunkBorderFix()) {
@ -167,9 +169,10 @@ public class WorldPackets {
} }
} }
} else { } 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 // Send empty chunks surrounding the loaded chunk to force 1.9+ clients to render the new chunk
if (Via.getConfig().isChunkBorderFix()) { if (Via.getConfig().isChunkBorderFix()) {
@ -179,7 +182,7 @@ public class WorldPackets {
if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) { if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) {
PacketWrapper emptyChunk = wrapper.create(ClientboundPackets1_9.CHUNK_DATA); 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<>()); 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); emptyChunk.send(Protocol1_9To1_8.class);
} }
} }
@ -199,10 +202,11 @@ public class WorldPackets {
ClientChunks clientChunks = wrapper.user().get(ClientChunks.class); ClientChunks clientChunks = wrapper.user().get(ClientChunks.class);
Chunk[] chunks = wrapper.read(new ChunkBulk1_8Type(clientWorld)); Chunk[] chunks = wrapper.read(new ChunkBulk1_8Type(clientWorld));
Type<Chunk> chunkType = new Chunk1_9_1_2Type(clientWorld);
// Split into multiple chunk packets // Split into multiple chunk packets
for (Chunk chunk : chunks) { for (Chunk chunk : chunks) {
PacketWrapper chunkData = wrapper.create(ClientboundPackets1_9.CHUNK_DATA); 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); chunkData.send(Protocol1_9To1_8.class);
clientChunks.getLoadedChunks().add(ClientChunks.toLong(chunk.getX(), chunk.getZ())); clientChunks.getLoadedChunks().add(ClientChunks.toLong(chunk.getX(), chunk.getZ()));
@ -215,7 +219,7 @@ public class WorldPackets {
if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) { if (!clientChunks.getLoadedChunks().contains(ClientChunks.toLong(chunkX, chunkZ))) {
PacketWrapper emptyChunk = wrapper.create(ClientboundPackets1_9.CHUNK_DATA); 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<>()); 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); 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;
}
}
} }

Datei anzeigen

@ -65,12 +65,11 @@ public class ChunkBulk1_8Type extends PartialType<Chunk[], ClientWorld> {
@Override @Override
public void write(ByteBuf output, ClientWorld world, Chunk[] chunks) throws Exception { public void write(ByteBuf output, ClientWorld world, Chunk[] chunks) throws Exception {
boolean skyLight = false; boolean skyLight = false;
for (Chunk c : chunks) { loop1: for (Chunk c : chunks) {
for (ChunkSection section : c.getSections()) { for (ChunkSection section : c.getSections()) {
if (section != null) { if (section != null && section.getLight().hasSkyLight()) {
if (section.getLight().hasSkyLight()) { skyLight = true;
skyLight = true; break loop1;
}
} }
} }
} }

Datei anzeigen

@ -20,7 +20,7 @@ pluginManagement {
// default plugin versions // default plugin versions
plugins { plugins {
id("net.kyori.blossom") version "1.2.0" id("net.kyori.blossom") version "1.2.0"
id("com.github.johnrengelman.shadow") version "7.0.0" id("com.github.johnrengelman.shadow") version "7.1.0"
} }
} }