Fixed some minor bugs

This commit is contained in:
OLEGSHA 2021-01-03 23:19:23 +03:00
parent e7433c90e2
commit 6f82d1d8b8
2 changed files with 21 additions and 10 deletions

View File

@ -20,6 +20,7 @@ package ru.windcorp.progressia.client.world;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.WeakHashMap;
@ -142,12 +143,14 @@ implements GenericWorld<
int[] updates = new int[] { 0 };
VectorUtil.iterateCuboidAround(entity.getChunkCoords(null), 3, chunkPos -> {
if (chunksToUpdate.contains(chunkPos)) {
getChunk(chunkPos).update();
chunksToUpdate.remove(chunkPos);
if (!chunksToUpdate.contains(chunkPos)) return;
updates[0]++;
}
ChunkRender chunk = getChunk(chunkPos);
if (chunk == null) return;
chunk.update();
chunksToUpdate.remove(chunkPos);
updates[0]++;
});
return updates[0];
@ -163,10 +166,14 @@ implements GenericWorld<
Vec3 v = Vectors.grab3();
for (Vec3i chunkPos : chunksToUpdate) {
for (Iterator<Vec3i> it = chunksToUpdate.iterator(); it.hasNext();) {
Vec3i chunkPos = it.next();
ChunkRender chunk = getChunk(chunkPos);
if (chunk == null) continue;
if (chunk == null) {
it.remove();
continue;
}
v.set(chunk.getMinX(), chunk.getMinY(), chunk.getMinZ()).sub(playerPos);
float distSq = v.x * v.x + v.y * v.y + v.z * v.z;

View File

@ -164,7 +164,11 @@ public class LayerTestGUI extends GUILayer {
if (client == null) return "Pos: n/a";
Vec3 pos = client.getCamera().getLastAnchorPosition();
return String.format(Locale.US, "Pos: %+7.1f %+7.1f %+7.1f", pos.x, pos.y, pos.z);
if (Float.isNaN(pos.x)) {
return "Pos: entity n/a";
} else {
return String.format(Locale.US, "Pos: %+7.1f %+7.1f %+7.1f", pos.x, pos.y, pos.z);
}
}
// private static class DebugComponent extends Component {