Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-28 09:00:09 +01:00
Cache 1.17.1 light by default, add config option
Dieser Commit ist enthalten in:
Ursprung
bc11bd4caf
Commit
6a00bf099e
@ -453,4 +453,6 @@ public interface ViaVersionConfig {
|
|||||||
* @return the global map from vanilla dimensions to world name
|
* @return the global map from vanilla dimensions to world name
|
||||||
*/
|
*/
|
||||||
WorldIdentifiers get1_16WorldNamesMap();
|
WorldIdentifiers get1_16WorldNamesMap();
|
||||||
|
|
||||||
|
boolean cache1_17Light();
|
||||||
}
|
}
|
||||||
|
@ -88,6 +88,7 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
private boolean forcedUse1_17ResourcePack;
|
private boolean forcedUse1_17ResourcePack;
|
||||||
private JsonElement resourcePack1_17PromptMessage;
|
private JsonElement resourcePack1_17PromptMessage;
|
||||||
private WorldIdentifiers map1_16WorldNames;
|
private WorldIdentifiers map1_16WorldNames;
|
||||||
|
private boolean cache1_17Light;
|
||||||
|
|
||||||
protected AbstractViaConfig(File configFile) {
|
protected AbstractViaConfig(File configFile) {
|
||||||
super(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),
|
map1_16WorldNames = new WorldIdentifiers(worlds.getOrDefault("overworld", WorldIdentifiers.OVERWORLD_DEFAULT),
|
||||||
worlds.getOrDefault("nether", WorldIdentifiers.NETHER_DEFAULT),
|
worlds.getOrDefault("nether", WorldIdentifiers.NETHER_DEFAULT),
|
||||||
worlds.getOrDefault("end", WorldIdentifiers.END_DEFAULT));
|
worlds.getOrDefault("end", WorldIdentifiers.END_DEFAULT));
|
||||||
|
cache1_17Light = getBoolean("cache-1_17-light", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private BlockedProtocolVersions loadBlockedProtocolVersions() {
|
private BlockedProtocolVersions loadBlockedProtocolVersions() {
|
||||||
@ -516,4 +518,9 @@ public abstract class AbstractViaConfig extends Config implements ViaVersionConf
|
|||||||
public WorldIdentifiers get1_16WorldNamesMap() {
|
public WorldIdentifiers get1_16WorldNamesMap() {
|
||||||
return map1_16WorldNames;
|
return map1_16WorldNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean cache1_17Light() {
|
||||||
|
return cache1_17Light;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public final class WorldPackets {
|
|||||||
handler(wrapper -> {
|
handler(wrapper -> {
|
||||||
final int chunkX = wrapper.passthrough(Type.VAR_INT);
|
final int chunkX = wrapper.passthrough(Type.VAR_INT);
|
||||||
final int chunkZ = 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
|
// Light packets updating already sent chunks are the same as before
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -162,9 +162,9 @@ public final class WorldPackets {
|
|||||||
final ChunkLightStorage lightStorage = wrapper.user().get(ChunkLightStorage.class);
|
final ChunkLightStorage lightStorage = wrapper.user().get(ChunkLightStorage.class);
|
||||||
final boolean alreadyLoaded = !lightStorage.addLoadedChunk(chunk.getX(), chunk.getZ());
|
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
|
// 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) {
|
if (light == null) {
|
||||||
Via.getPlatform().getLogger().warning("No light data found for chunk at " + chunk.getX() + ", " + chunk.getZ() + ". Chunk was already loaded: " + alreadyLoaded);
|
Via.getPlatform().getLogger().warning("No light data found for chunk at " + chunk.getX() + ", " + chunk.getZ() + ". Chunk was already loaded: " + alreadyLoaded);
|
||||||
|
|
||||||
|
@ -38,6 +38,10 @@ public final class ChunkLightStorage implements StorableObject {
|
|||||||
return lightPackets.remove(getChunkSectionIndex(x, z));
|
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) {
|
public boolean addLoadedChunk(final int x, final int z) {
|
||||||
return loadedChunks.add(getChunkSectionIndex(x, z));
|
return loadedChunks.add(getChunkSectionIndex(x, z));
|
||||||
}
|
}
|
||||||
|
@ -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.
|
# The message to be displayed at the prompt when the 1.17+ client receives the server resource pack.
|
||||||
resource-pack-1_17-prompt: ''
|
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 #
|
# 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren