diff options
author | makamys <makamys@outlook.com> | 2021-05-20 02:12:05 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2021-05-20 02:12:05 +0200 |
commit | 341971e670a8d7a4da1142bc78cb2f24aaf6e835 (patch) | |
tree | c2997767897c96bebf5ad15e6406bbfcd45279ce /src/main/java/makamys | |
parent | 4bef4d56ae9332ba2226ecb3dab31813bbd594b9 (diff) | |
download | Neodymium-341971e670a8d7a4da1142bc78cb2f24aaf6e835.tar.gz Neodymium-341971e670a8d7a4da1142bc78cb2f24aaf6e835.tar.bz2 Neodymium-341971e670a8d7a4da1142bc78cb2f24aaf6e835.zip |
When a chunk is loaded, update its model
Diffstat (limited to 'src/main/java/makamys')
-rw-r--r-- | src/main/java/makamys/lodmod/LODMod.java | 10 | ||||
-rw-r--r-- | src/main/java/makamys/lodmod/renderer/LODRenderer.java | 5 |
2 files changed, 15 insertions, 0 deletions
diff --git a/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java index 2c9c160..1ca08f5 100644 --- a/src/main/java/makamys/lodmod/LODMod.java +++ b/src/main/java/makamys/lodmod/LODMod.java @@ -10,6 +10,7 @@ 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.ChunkEvent; import net.minecraftforge.event.world.WorldEvent; import java.io.File; @@ -91,6 +92,15 @@ public class LODMod } } + @SubscribeEvent + public void onChunkLoad(ChunkEvent.Load event) { + if(!event.world.isRemote) return; + + if(isActive()) { + renderer.onChunkLoad(event); + } + } + public static boolean isActive() { return renderer != null && renderer.hasInited; } diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java index 4691a2c..534a508 100644 --- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java +++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java @@ -14,6 +14,7 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraft.world.chunk.Chunk; import net.minecraft.world.gen.ChunkProviderServer; +import net.minecraftforge.event.world.ChunkEvent; import java.nio.FloatBuffer; import java.nio.IntBuffer; @@ -635,6 +636,10 @@ public class LODRenderer { System.out.println("Finished saving LOD regions in " + ((System.currentTimeMillis() - t0) / 1000.0) + "s"); } + public void onChunkLoad(ChunkEvent.Load event) { + farChunks.add(event.getChunk()); + } + private Path getSaveDir(){ return Minecraft.getMinecraft().mcDataDir.toPath().resolve("lodmod").resolve(Minecraft.getMinecraft().getIntegratedServer().getFolderName()); } |