diff options
author | makamys <makamys@outlook.com> | 2021-05-19 11:50:07 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-19 11:51:49 +0200 |
commit | 4bef4d56ae9332ba2226ecb3dab31813bbd594b9 (patch) | |
tree | dfc1d3a4e26059929943390ef4b388eb9a3f83ee /src/main/java/makamys/lodmod | |
parent | 61cb22ab61abdd1bfd216d10084dcd19b80ba536 (diff) | |
download | Neodymium-4bef4d56ae9332ba2226ecb3dab31813bbd594b9.tar.gz Neodymium-4bef4d56ae9332ba2226ecb3dab31813bbd594b9.tar.bz2 Neodymium-4bef4d56ae9332ba2226ecb3dab31813bbd594b9.zip |
Make amount of chunk loads per tick configurable
Diffstat (limited to 'src/main/java/makamys/lodmod')
-rw-r--r-- | src/main/java/makamys/lodmod/LODMod.java | 26 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODRenderer.java | 2 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java index dd25e6b..2c9c160 100644 --- a/src/main/java/makamys/lodmod/LODMod.java +++ b/src/main/java/makamys/lodmod/LODMod.java @@ -9,8 +9,11 @@ import net.minecraftforge.client.event.EntityViewRenderEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.common.MinecraftForge; +import net.minecraftforge.common.config.Configuration; import net.minecraftforge.event.world.WorldEvent; +import java.io.File; + import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.lwjgl.opengl.GL11; @@ -19,6 +22,7 @@ import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.Mod; import cpw.mods.fml.common.Mod.EventHandler; import cpw.mods.fml.common.event.FMLInitializationEvent; +import cpw.mods.fml.common.event.FMLPreInitializationEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.Side; @@ -36,6 +40,27 @@ public class LODMod public static LODRenderer renderer; + public static int chunkLoadsPerTick; + + private File configFile; + + @EventHandler + public void preInit(FMLPreInitializationEvent event) + { + configFile = event.getSuggestedConfigurationFile(); + reloadConfig(); + } + + private void reloadConfig() { + Configuration config = new Configuration(configFile); + + config.load(); + chunkLoadsPerTick = config.get("Options", "chunkLoadsPerTick", 64).getInt(); + if(config.hasChanged()) { + config.save(); + } + } + @EventHandler public void init(FMLInitializationEvent event) { @@ -52,6 +77,7 @@ public class LODMod LOGGER.warn("Renderer didn't get destroyed last time"); renderer.destroy(); } + reloadConfig(); renderer = new LODRenderer(); } diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 3c8303d..4691a2c 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -478,7 +478,7 @@ public class LODRenderer { } public synchronized void serverTick() { - int chunkLoadsRemaining = 64; + int chunkLoadsRemaining = LODMod.chunkLoadsPerTick; while(!serverChunkLoadQueue.isEmpty() && chunkLoadsRemaining-- > 0) { ChunkCoordIntPair coords = serverChunkLoadQueue.remove(0); ChunkProviderServer chunkProviderServer = Minecraft.getMinecraft().getIntegratedServer().worldServers[0].theChunkProviderServer; |