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

Cache 1.17.1 light by default, add config option

Dieser Commit ist enthalten in:
Nassim Jahnke 2021-11-18 11:23:46 +01:00
Ursprung bc11bd4caf
Commit 6a00bf099e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B
5 geänderte Dateien mit 20 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -453,4 +453,6 @@ public interface ViaVersionConfig {
* @return the global map from vanilla dimensions to world name
*/
WorldIdentifiers get1_16WorldNamesMap();
boolean cache1_17Light();
}

Datei anzeigen

@ -88,6 +88,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
private boolean forcedUse1_17ResourcePack;
private JsonElement resourcePack1_17PromptMessage;
private WorldIdentifiers map1_16WorldNames;
private boolean cache1_17Light;
protected AbstractViaConfig(File configFile) {
super(configFile);
@ -155,6 +156,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
map1_16WorldNames = new WorldIdentifiers(worlds.getOrDefault("overworld", WorldIdentifiers.OVERWORLD_DEFAULT),
worlds.getOrDefault("nether", WorldIdentifiers.NETHER_DEFAULT),
worlds.getOrDefault("end", WorldIdentifiers.END_DEFAULT));
cache1_17Light = getBoolean("cache-1_17-light", true);
}
private BlockedProtocolVersions loadBlockedProtocolVersions() {
@ -516,4 +518,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
public WorldIdentifiers get1_16WorldNamesMap() {
return map1_16WorldNames;
}
@Override
public boolean cache1_17Light() {
return cache1_17Light;
}
}

Datei anzeigen

@ -67,7 +67,7 @@ public final class WorldPackets {
handler(wrapper -> {
final int chunkX = wrapper.passthrough(Type.VAR_INT);
final int chunkZ = wrapper.passthrough(Type.VAR_INT);
if (wrapper.user().get(ChunkLightStorage.class).isLoaded(chunkX, chunkZ)) {
if (!Via.getConfig().cache1_17Light() && wrapper.user().get(ChunkLightStorage.class).isLoaded(chunkX, chunkZ)) {
// Light packets updating already sent chunks are the same as before
return;
}
@ -162,9 +162,9 @@ public final class WorldPackets {
final ChunkLightStorage lightStorage = wrapper.user().get(ChunkLightStorage.class);
final boolean alreadyLoaded = !lightStorage.addLoadedChunk(chunk.getX(), chunk.getZ());
// Get and remove light stored, there's only full chunk packets //TODO Only get, not remove if we find out people re-send full chunk packets without re-sending light
// Append light data to chunk packet
final ChunkLightStorage.ChunkLight light = lightStorage.removeLight(chunk.getX(), chunk.getZ());
final ChunkLightStorage.ChunkLight light = Via.getConfig().cache1_17Light() ?
lightStorage.getLight(chunk.getX(), chunk.getZ()) : lightStorage.removeLight(chunk.getX(), chunk.getZ());
if (light == null) {
Via.getPlatform().getLogger().warning("No light data found for chunk at " + chunk.getX() + ", " + chunk.getZ() + ". Chunk was already loaded: " + alreadyLoaded);

Datei anzeigen

@ -38,6 +38,10 @@ public final class ChunkLightStorage implements StorableObject {
return lightPackets.remove(getChunkSectionIndex(x, z));
}
public @Nullable ChunkLight getLight(final int x, final int z) {
return lightPackets.get(getChunkSectionIndex(x, z));
}
public boolean addLoadedChunk(final int x, final int z) {
return loadedChunks.add(getChunkSectionIndex(x, z));
}

Datei anzeigen

@ -160,6 +160,10 @@ forced-use-1_17-resource-pack: false
# The message to be displayed at the prompt when the 1.17+ client receives the server resource pack.
resource-pack-1_17-prompt: ''
#
# Caches light until chunks are unloaded to allow subsequent chunk update packets as opposed to instantly uncaching when the first chunk data is sent.
# Only disable this if you know what you are doing.
cache-1_17-light: true
#
#----------------------------------------------------------#
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
#----------------------------------------------------------#