diff --git a/src/main/java/pl/asie/foamfix/coremod/ChunkRenderDispatcherPatch.java b/src/main/java/pl/asie/foamfix/coremod/ChunkRenderDispatcherPatch.java index 1a7d8c2..ed8734a 100644 --- a/src/main/java/pl/asie/foamfix/coremod/ChunkRenderDispatcherPatch.java +++ b/src/main/java/pl/asie/foamfix/coremod/ChunkRenderDispatcherPatch.java @@ -17,9 +17,25 @@ public boolean updateChunkLater(RenderChunk chunkRenderer) { } public boolean updateChunkNow(RenderChunk chunkRenderer) { - // TODO: Make the latter a config option again if we use this method for sth else -// if (FoamFixShared.config.delayChunkUpdates) { + if (!chunkRenderer.isNeedsUpdateCustom()) { return updateChunkLater(chunkRenderer); -// } + } + + chunkRenderer.getLockCompileTask().lock(); + boolean flag; + + try { + ChunkCompileTaskGenerator chunkcompiletaskgenerator = chunkRenderer.makeCompileTaskChunk(); + + try { + this.renderWorker.processTask(chunkcompiletaskgenerator); + } catch (InterruptedException var7) { } + + flag = true; + } finally { + chunkRenderer.getLockCompileTask().unlock(); + } + + return flag; } } diff --git a/src/main/java/pl/asie/foamfix/shared/FoamFixConfig.java b/src/main/java/pl/asie/foamfix/shared/FoamFixConfig.java index 303635f..7a93077 100644 --- a/src/main/java/pl/asie/foamfix/shared/FoamFixConfig.java +++ b/src/main/java/pl/asie/foamfix/shared/FoamFixConfig.java @@ -25,7 +25,13 @@ */ package pl.asie.foamfix.shared; +import net.minecraftforge.common.ForgeModContainer; +import net.minecraftforge.common.ForgeVersion; import net.minecraftforge.common.config.Configuration; +import net.minecraftforge.fml.common.ModContainer; +import net.minecraftforge.fml.common.versioning.DefaultArtifactVersion; +import net.minecraftforge.fml.common.versioning.VersionParser; +import net.minecraftforge.fml.common.versioning.VersionRange; import java.io.File; @@ -41,24 +47,39 @@ public class FoamFixConfig { private Configuration config; public boolean geSmallLightingOptimize = false; + private boolean getBoolean(String name, String category, boolean defaultValue, String description) { + return config.getBoolean(name, category, defaultValue, description); + } + + private boolean getBoolean(String name, String category, boolean defaultValue, String description, String forgeVersionRange) { + VersionRange range = VersionParser.parseRange(forgeVersionRange); + DefaultArtifactVersion requiredVersion = new DefaultArtifactVersion("Forge", range); + + if (requiredVersion.containsVersion(new DefaultArtifactVersion("Forge", ForgeVersion.getVersion()))) { + return getBoolean(name, category, defaultValue, description); + } else { + return false; + } + } + public void init(File file, boolean isCoremod) { if (config == null) { config = new Configuration(file); - lwDummyPackageManifestMap = config.getBoolean("dummyPackageManifestMap", "launchwrapper", true, "Dummy out LaunchWrapper's unused package manifest map. This will only break things if some other mod reflects into the LaunchClassLoader to get the private map, which as far as I know is not the case."); - lwWeakenResourceCache = config.getBoolean("weakenResourceCache", "launchwrapper", true, "Weaken LaunchWrapper's byte[] resource cache to make it cleanuppable by the GC. Safe."); - clDeduplicate = config.getBoolean("deduplicateModels", "client", true, "Enable deduplication of redundant objects in memory."); + lwDummyPackageManifestMap = getBoolean("dummyPackageManifestMap", "launchwrapper", true, "Dummy out LaunchWrapper's unused package manifest map. This will only break things if some other mod reflects into the LaunchClassLoader to get the private map, which as far as I know is not the case."); + lwWeakenResourceCache = getBoolean("weakenResourceCache", "launchwrapper", true, "Weaken LaunchWrapper's byte[] resource cache to make it cleanuppable by the GC. Safe."); + clDeduplicate = getBoolean("deduplicateModels", "client", true, "Enable deduplication of redundant objects in memory."); clDeduplicateRecursionLevel = config.getInt("deduplicateModelsMaxRecursion", "client", 6, 1, Integer.MAX_VALUE, "The maximum amount of levels of recursion for the deduplication process. Smaller values will deduplicate less data, but make the process run faster."); - clCleanRedundantModelRegistry = config.getBoolean("clearDuplicateModelRegistry", "client", true, "Clears the baked models generated in the first pass *before* entering the second pass, instead of *after*. While this doesn't reduce memory usage in-game, it does reduce it noticeably during loading."); - geDynamicRegistrySizeScaling = config.getBoolean("dynamicRegistrySizeScaling", "general", true, "Makes large FML registries scale their availability BitSets dynamically, saving ~48MB of RAM."); + clCleanRedundantModelRegistry = getBoolean("clearDuplicateModelRegistry", "client", true, "Clears the baked models generated in the first pass *before* entering the second pass, instead of *after*. While this doesn't reduce memory usage in-game, it does reduce it noticeably during loading."); + geDynamicRegistrySizeScaling = getBoolean("dynamicRegistrySizeScaling", "general", true, "Makes large FML registries scale their availability BitSets dynamically, saving ~48MB of RAM.", "(,13.19.1.2190)"); if (isCoremod) { - // clTextureDoubleBuffering = config.getBoolean("textureDoubleBuffering", "experimental", true, "Makes texture animations double-buffered, letting the GPU process them independently of scene rendering."); - geSmallPropertyStorage = config.getBoolean("smallPropertyStorage", "experimental", true, "Replaces the default BlockState/ExtendedBlockState implementations with a far more memory-efficient variant."); - geBlockPosPatch = config.getBoolean("optimizedBlockPos", "coremod", true, "Optimizes BlockPos mutable/immutable getters to run on the same variables, letting them be inlined and thus theoretically increasing performance."); - clBlockInfoPatch = config.getBoolean("optimizedBlockInfo", "coremod", true, "Prevents BlockInfo from generating as many BlockPos objects; also, fixes a lighting bug."); - geSmallLightingOptimize = config.getBoolean("smallLightingOptimize", "experimental", true, "Currently minor lighting calculation code optimization."); - delayChunkUpdates = config.getBoolean("delayChunkRenderUpdates", "experimental", true, "Delays chunk render updates to prevent stutter at the cost of minor chunk render update lag."); + // clTextureDoubleBuffering = getBoolean("textureDoubleBuffering", "experimental", true, "Makes texture animations double-buffered, letting the GPU process them independently of scene rendering."); + geSmallPropertyStorage = getBoolean("smallPropertyStorage", "experimental", true, "Replaces the default BlockState/ExtendedBlockState implementations with a far more memory-efficient variant."); + geBlockPosPatch = getBoolean("optimizedBlockPos", "coremod", true, "Optimizes BlockPos mutable/immutable getters to run on the same variables, letting them be inlined and thus theoretically increasing performance."); + clBlockInfoPatch = getBoolean("optimizedBlockInfo", "coremod", true, "Prevents BlockInfo from generating as many BlockPos objects; also, fixes a lighting bug."); + // geSmallLightingOptimize = getBoolean("smallLightingOptimize", "experimental", true, "Currently minor lighting calculation code optimization."); + delayChunkUpdates = getBoolean("delayChunkRenderUpdates", "experimental", true, "Delays chunk render updates to prevent stutter at the cost of minor chunk render update lag.", "(,13.20.0.2220)"); } config.save();