9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-19 15:09:18 +00:00

decrease wait times in mantle components

This commit is contained in:
Julian Krings
2025-08-27 16:08:49 +02:00
parent 7b9c2ae6ad
commit ca4c205a4a
2 changed files with 22 additions and 30 deletions

View File

@@ -172,7 +172,7 @@ public interface EngineMantle {
@ChunkCoordinates @ChunkCoordinates
default void generateMatter(int x, int z, boolean multicore, ChunkContext context) { default void generateMatter(int x, int z, boolean multicore, ChunkContext context) {
if (!getEngine().getDimension().isUseMantle()) { if (!getEngine().getDimension().isUseMantle() || getMantle().hasFlag(x, z, MantleFlag.PLANNED)) {
return; return;
} }
@@ -191,20 +191,15 @@ public interface EngineMantle {
Position2 pos = p.getB(); Position2 pos = p.getB();
int xx = pos.getX(); int xx = pos.getX();
int zz = pos.getZ(); int zz = pos.getZ();
MantleChunk mc = getMantle().getChunk(xx, zz).use();
try {
IrisContext.getOr(getEngine()).setChunkContext(context); IrisContext.getOr(getEngine()).setChunkContext(context);
generateMantleComponent(writer, xx, zz, c, mc, context); generateMantleComponent(writer, xx, zz, c, writer.acquireChunk(xx, zz), context);
} finally {
mc.release();
}
}, },
multicore ? burst() : null multicore ? burst() : null
); );
if (!last) continue; if (!last) continue;
forEach(streamRadius(x, z, radius), forEach(streamRadius(x, z, radius),
p -> getMantle().flag(p.getX(), p.getZ(), MantleFlag.PLANNED, true), p -> writer.acquireChunk(x, z).flag(MantleFlag.PLANNED, true),
multicore ? burst() : null multicore ? burst() : null
); );
} }

View File

@@ -31,6 +31,7 @@ import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet; import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.data.B; import com.volmit.iris.util.data.B;
import com.volmit.iris.util.data.IrisCustomData; import com.volmit.iris.util.data.IrisCustomData;
import com.volmit.iris.util.documentation.ChunkCoordinates;
import com.volmit.iris.util.function.Function3; import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.mantle.Mantle; import com.volmit.iris.util.mantle.Mantle;
import com.volmit.iris.util.mantle.MantleChunk; import com.volmit.iris.util.mantle.MantleChunk;
@@ -149,20 +150,11 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
return; return;
} }
if (cx >= this.x - radius && cx <= this.x + radius MantleChunk chunk = acquireChunk(cx, cz);
&& cz >= this.z - radius && cz <= this.z + radius) { if (chunk == null) return;
MantleChunk chunk = cachedChunks.computeIfAbsent(Cache.key(cx, cz), k -> mantle.getChunk(cx, cz).use());
if (chunk == null) {
Iris.error("Mantle Writer Accessed " + cx + "," + cz + " and came up null (and yet within bounds!)");
return;
}
Matter matter = chunk.getOrCreate(y >> 4); Matter matter = chunk.getOrCreate(y >> 4);
matter.slice(matter.getClass(t)).set(x & 15, y & 15, z & 15, t); matter.slice(matter.getClass(t)).set(x & 15, y & 15, z & 15, t);
} else {
Iris.error("Mantle Writer Accessed chunk out of bounds" + cx + "," + cz);
}
} }
public <T> T getData(int x, int y, int z, Class<T> type) { public <T> T getData(int x, int y, int z, Class<T> type) {
@@ -173,15 +165,8 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
return null; return null;
} }
if (cx < this.x - radius || cx > this.x + radius MantleChunk chunk = acquireChunk(cx, cz);
|| cz < this.z - radius || cz > this.z + radius) {
Iris.error("Mantle Writer Accessed chunk out of bounds" + cx + "," + cz);
return null;
}
MantleChunk chunk = cachedChunks.computeIfAbsent(Cache.key(cx, cz), k -> mantle.getChunk(cx, cz).use());
if (chunk == null) { if (chunk == null) {
Iris.error("Mantle Writer Accessed " + cx + "," + cz + " and came up null (and yet within bounds!)");
return null; return null;
} }
@@ -190,6 +175,18 @@ public class MantleWriter implements IObjectPlacer, AutoCloseable {
.get(x & 15, y & 15, z & 15); .get(x & 15, y & 15, z & 15);
} }
@ChunkCoordinates
public MantleChunk acquireChunk(int cx, int cz) {
if (cx < this.x - radius || cx > this.x + radius
|| cz < this.z - radius || cz > this.z + radius) {
Iris.error("Mantle Writer Accessed chunk out of bounds" + cx + "," + cz);
return null;
}
MantleChunk chunk = cachedChunks.computeIfAbsent(Cache.key(cx, cz), k -> mantle.getChunk(cx, cz).use());
if (chunk == null) Iris.error("Mantle Writer Accessed " + cx + "," + cz + " and came up null (and yet within bounds!)");
return chunk;
}
@Override @Override
public int getHighest(int x, int z, IrisData data) { public int getHighest(int x, int z, IrisData data) {
return engineMantle.getHighest(x, z, data); return engineMantle.getHighest(x, z, data);