aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authormakamys <makamys@outlook.com>2021-06-16 18:07:47 +0200
committermakamys <makamys@outlook.com>2021-06-16 18:07:47 +0200
commitd64ee82b4dc59c21cbe86e364fd51785f38ec8ba (patch)
tree12cce7ecd8fac9bad04b768270b8f9e874314ed9 /src/main
parent2d8a1c193494b1563282426be707fb7cac75f43f (diff)
downloadNeodymium-d64ee82b4dc59c21cbe86e364fd51785f38ec8ba.tar.gz
Neodymium-d64ee82b4dc59c21cbe86e364fd51785f38ec8ba.tar.bz2
Neodymium-d64ee82b4dc59c21cbe86e364fd51785f38ec8ba.zip
Fix LOD chunks loading from wrong coordinate when entering new dimension
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/makamys/lodmod/LODMod.java2
-rw-r--r--src/main/java/makamys/lodmod/renderer/LODRenderer.java66
-rw-r--r--src/main/resources/META-INF/LODMod_at.cfg5
3 files changed, 39 insertions, 34 deletions
diff --git a/src/main/java/makamys/lodmod/LODMod.java b/src/main/java/makamys/lodmod/LODMod.java
index 3852cdc..ceed97d 100644
--- a/src/main/java/makamys/lodmod/LODMod.java
+++ b/src/main/java/makamys/lodmod/LODMod.java
@@ -112,7 +112,7 @@ public class LODMod
renderer.destroy();
renderer = null;
}
- if(enabled) {
+ if(enabled && newWorld != null) {
renderer = new LODRenderer(newWorld);
}
}
diff --git a/src/main/java/makamys/lodmod/renderer/LODRenderer.java b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
index c3ae345..2f958d0 100644
--- a/src/main/java/makamys/lodmod/renderer/LODRenderer.java
+++ b/src/main/java/makamys/lodmod/renderer/LODRenderer.java
@@ -165,43 +165,45 @@ public class LODRenderer {
sendChunkToGPU(lodChunk);
}
- Entity player = Minecraft.getMinecraft().renderViewEntity;
-
- List<ChunkCoordIntPair> newServerChunkLoadQueue = new ArrayList<>();
-
- if(Double.isNaN(lastSortX) || getLastSortDistanceSq(player) > 16 * 16) {
- int centerX = (int)Math.floor(player.posX / 16.0);
- int centerZ = (int)Math.floor(player.posZ / 16.0);
+ if(Minecraft.getMinecraft().playerController.netClientHandler.doneLoadingTerrain) {
+ Entity player = Minecraft.getMinecraft().renderViewEntity;
- for(int x = -renderRange; x <= renderRange; x++) {
- for(int z = -renderRange; z <= renderRange; z++) {
- if(x * x + z * z < renderRange * renderRange) {
- int chunkX = centerX + x;
- int chunkZ = centerZ + z;
-
- if(getLODChunk(chunkX, chunkZ).needsChunk) {
- newServerChunkLoadQueue.add(new ChunkCoordIntPair(chunkX, chunkZ));
- getLODChunk(chunkX, chunkZ).needsChunk = false;
+ List<ChunkCoordIntPair> newServerChunkLoadQueue = new ArrayList<>();
+
+ if(Double.isNaN(lastSortX) || getLastSortDistanceSq(player) > 16 * 16) {
+ int centerX = (int)Math.floor(player.posX / 16.0);
+ int centerZ = (int)Math.floor(player.posZ / 16.0);
+
+ for(int x = -renderRange; x <= renderRange; x++) {
+ for(int z = -renderRange; z <= renderRange; z++) {
+ if(x * x + z * z < renderRange * renderRange) {
+ int chunkX = centerX + x;
+ int chunkZ = centerZ + z;
+
+ if(getLODChunk(chunkX, chunkZ).needsChunk) {
+ newServerChunkLoadQueue.add(new ChunkCoordIntPair(chunkX, chunkZ));
+ getLODChunk(chunkX, chunkZ).needsChunk = false;
+ }
}
}
}
- }
- Collections.sort(newServerChunkLoadQueue, new ChunkCoordDistanceComparator(player.posX, player.posY, player.posZ));
- addToServerChunkLoadQueue(newServerChunkLoadQueue);
-
- lastSortX = player.posX;
- lastSortY = player.posY;
- lastSortZ = player.posZ;
- for(Iterator<ChunkCoordIntPair> it = loadedRegionsMap.keySet().iterator(); it.hasNext();) {
- ChunkCoordIntPair k = it.next();
- LODRegion v = loadedRegionsMap.get(k);
+ Collections.sort(newServerChunkLoadQueue, new ChunkCoordDistanceComparator(player.posX, player.posY, player.posZ));
+ addToServerChunkLoadQueue(newServerChunkLoadQueue);
- if(v.distanceTaxicab(player) > renderRange * 16 + 16 * 16) {
- System.out.println("unloading " + v);
- v.destroy(getSaveDir());
- it.remove();
- } else {
- v.tick(player);
+ lastSortX = player.posX;
+ lastSortY = player.posY;
+ lastSortZ = player.posZ;
+ for(Iterator<ChunkCoordIntPair> it = loadedRegionsMap.keySet().iterator(); it.hasNext();) {
+ ChunkCoordIntPair k = it.next();
+ LODRegion v = loadedRegionsMap.get(k);
+
+ if(v.distanceTaxicab(player) > renderRange * 16 + 16 * 16) {
+ System.out.println("unloading " + v);
+ v.destroy(getSaveDir());
+ it.remove();
+ } else {
+ v.tick(player);
+ }
}
}
}
diff --git a/src/main/resources/META-INF/LODMod_at.cfg b/src/main/resources/META-INF/LODMod_at.cfg
index e28c810..766965a 100644
--- a/src/main/resources/META-INF/LODMod_at.cfg
+++ b/src/main/resources/META-INF/LODMod_at.cfg
@@ -1,3 +1,6 @@
public net.minecraft.client.renderer.texture.TextureMap field_94252_e #mapUploadedSprites
public net.minecraft.client.renderer.Tessellator func_78379_d()V #reset
-public net.minecraft.world.biome.BiomeGenBase field_150605_ac #temperatureNoise \ No newline at end of file
+public net.minecraft.world.biome.BiomeGenBase field_150605_ac #temperatureNoise
+
+public net.minecraft.client.multiplayer.PlayerControllerMP field_78774_b #netClientHandler
+public net.minecraft.client.network.NetHandlerPlayClient field_147309_h #doneLoadingTerrain \ No newline at end of file