mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-19 15:09:18 +00:00
fix more structures not being placed properly
This commit is contained in:
@@ -206,7 +206,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
var pair = iterator.next();
|
||||
int radius = pair.getB();
|
||||
boolean last = !iterator.hasNext();
|
||||
BurstExecutor burst = burst().burst(radius * 2 + 1);
|
||||
BurstExecutor burst = burst().burst((radius * 2 + 1) * pair.getA().size());
|
||||
burst.setMulticore(multicore);
|
||||
|
||||
for (int i = -radius; i <= radius; i++) {
|
||||
@@ -214,26 +214,30 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
int xx = x + i;
|
||||
int zz = z + j;
|
||||
MantleChunk mc = getMantle().getChunk(xx, zz).use();
|
||||
|
||||
burst.queue(() -> {
|
||||
try {
|
||||
IrisContext.touch(getEngine().getContext());
|
||||
pair.getA().forEach(k -> generateMantleComponent(writer, xx, zz, k, mc, context));
|
||||
if (last) mc.flag(MantleFlag.PLANNED, true);
|
||||
} finally {
|
||||
mc.release();
|
||||
}
|
||||
});
|
||||
for (MantleComponent c : pair.getA()) {
|
||||
burst.queue(() -> {
|
||||
IrisContext.getOr(getEngine()).setChunkContext(context);
|
||||
generateMantleComponent(writer, xx, zz, c, mc, context);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
|
||||
for (int i = -radius; i <= radius; i++) {
|
||||
for (int j = -radius; j <= radius; j++) {
|
||||
var chunk = getMantle().getChunk(x + i, z + j);
|
||||
if (last) chunk.flag(MantleFlag.PLANNED, true);
|
||||
chunk.release();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc, ChunkContext context) {
|
||||
mc.raiseFlag(c.getFlag(), () -> {
|
||||
mc.raiseFlag(MantleFlag.PLANNED, c.getFlag(), () -> {
|
||||
if (c.isEnabled()) c.generateLayer(writer, x, z, context);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -514,9 +514,9 @@ public class IrisObject extends IrisRegistrant {
|
||||
max.setZ(Math.max(max.getZ(), i.getZ()));
|
||||
}
|
||||
|
||||
w = max.getBlockX() - min.getBlockX() + (min.getBlockX() <= 0 && max.getBlockX() >= 0 && min.getBlockX() != max.getBlockX() ? 1 : 0);
|
||||
h = max.getBlockY() - min.getBlockY() + (min.getBlockY() <= 0 && max.getBlockY() >= 0 && min.getBlockY() != max.getBlockY() ? 1 : 0);
|
||||
d = max.getBlockZ() - min.getBlockZ() + (min.getBlockZ() <= 0 && max.getBlockZ() >= 0 && min.getBlockZ() != max.getBlockZ() ? 1 : 0);
|
||||
w = max.getBlockX() - min.getBlockX() + 1;
|
||||
h = max.getBlockY() - min.getBlockY() + 1;
|
||||
d = max.getBlockZ() - min.getBlockZ() + 1;
|
||||
center = new BlockVector(w / 2, h / 2, d / 2);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,6 +49,7 @@ public class MantleChunk {
|
||||
@Getter
|
||||
private final int z;
|
||||
private final AtomicIntegerArray flags;
|
||||
private final Object[] flagLocks;
|
||||
private final AtomicReferenceArray<Matter> sections;
|
||||
private final Semaphore ref = new Semaphore(Integer.MAX_VALUE, true);
|
||||
private final AtomicBoolean closed = new AtomicBoolean(false);
|
||||
@@ -62,11 +63,13 @@ public class MantleChunk {
|
||||
public MantleChunk(int sectionHeight, int x, int z) {
|
||||
sections = new AtomicReferenceArray<>(sectionHeight);
|
||||
flags = new AtomicIntegerArray(MantleFlag.values().length);
|
||||
flagLocks = new Object[MantleFlag.values().length];
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
|
||||
for (int i = 0; i < flags.length(); i++) {
|
||||
flags.set(i, 0);
|
||||
flagLocks[i] = new Object();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -148,9 +151,16 @@ public class MantleChunk {
|
||||
}
|
||||
|
||||
public void raiseFlag(MantleFlag flag, Runnable r) {
|
||||
raiseFlag(null, flag, r);
|
||||
}
|
||||
|
||||
public void raiseFlag(@Nullable MantleFlag guard, MantleFlag flag, Runnable r) {
|
||||
if (closed.get()) throw new IllegalStateException("Chunk is closed!");
|
||||
if (flags.getAndSet(flag.ordinal(), 1) == 0) {
|
||||
r.run();
|
||||
if (guard != null && isFlagged(guard)) return;
|
||||
synchronized (flagLocks[flag.ordinal()]) {
|
||||
if (flags.getAndSet(flag.ordinal(), 1) == 0) {
|
||||
r.run();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user