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();
|
var pair = iterator.next();
|
||||||
int radius = pair.getB();
|
int radius = pair.getB();
|
||||||
boolean last = !iterator.hasNext();
|
boolean last = !iterator.hasNext();
|
||||||
BurstExecutor burst = burst().burst(radius * 2 + 1);
|
BurstExecutor burst = burst().burst((radius * 2 + 1) * pair.getA().size());
|
||||||
burst.setMulticore(multicore);
|
burst.setMulticore(multicore);
|
||||||
|
|
||||||
for (int i = -radius; i <= radius; i++) {
|
for (int i = -radius; i <= radius; i++) {
|
||||||
@@ -214,26 +214,30 @@ public interface EngineMantle extends IObjectPlacer {
|
|||||||
int xx = x + i;
|
int xx = x + i;
|
||||||
int zz = z + j;
|
int zz = z + j;
|
||||||
MantleChunk mc = getMantle().getChunk(xx, zz).use();
|
MantleChunk mc = getMantle().getChunk(xx, zz).use();
|
||||||
|
for (MantleComponent c : pair.getA()) {
|
||||||
burst.queue(() -> {
|
burst.queue(() -> {
|
||||||
try {
|
IrisContext.getOr(getEngine()).setChunkContext(context);
|
||||||
IrisContext.touch(getEngine().getContext());
|
generateMantleComponent(writer, xx, zz, c, mc, context);
|
||||||
pair.getA().forEach(k -> generateMantleComponent(writer, xx, zz, k, mc, context));
|
|
||||||
if (last) mc.flag(MantleFlag.PLANNED, true);
|
|
||||||
} finally {
|
|
||||||
mc.release();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
burst.complete();
|
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) {
|
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);
|
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()));
|
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);
|
w = max.getBlockX() - min.getBlockX() + 1;
|
||||||
h = max.getBlockY() - min.getBlockY() + (min.getBlockY() <= 0 && max.getBlockY() >= 0 && min.getBlockY() != max.getBlockY() ? 1 : 0);
|
h = max.getBlockY() - min.getBlockY() + 1;
|
||||||
d = max.getBlockZ() - min.getBlockZ() + (min.getBlockZ() <= 0 && max.getBlockZ() >= 0 && min.getBlockZ() != max.getBlockZ() ? 1 : 0);
|
d = max.getBlockZ() - min.getBlockZ() + 1;
|
||||||
center = new BlockVector(w / 2, h / 2, d / 2);
|
center = new BlockVector(w / 2, h / 2, d / 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ public class MantleChunk {
|
|||||||
@Getter
|
@Getter
|
||||||
private final int z;
|
private final int z;
|
||||||
private final AtomicIntegerArray flags;
|
private final AtomicIntegerArray flags;
|
||||||
|
private final Object[] flagLocks;
|
||||||
private final AtomicReferenceArray<Matter> sections;
|
private final AtomicReferenceArray<Matter> sections;
|
||||||
private final Semaphore ref = new Semaphore(Integer.MAX_VALUE, true);
|
private final Semaphore ref = new Semaphore(Integer.MAX_VALUE, true);
|
||||||
private final AtomicBoolean closed = new AtomicBoolean(false);
|
private final AtomicBoolean closed = new AtomicBoolean(false);
|
||||||
@@ -62,11 +63,13 @@ public class MantleChunk {
|
|||||||
public MantleChunk(int sectionHeight, int x, int z) {
|
public MantleChunk(int sectionHeight, int x, int z) {
|
||||||
sections = new AtomicReferenceArray<>(sectionHeight);
|
sections = new AtomicReferenceArray<>(sectionHeight);
|
||||||
flags = new AtomicIntegerArray(MantleFlag.values().length);
|
flags = new AtomicIntegerArray(MantleFlag.values().length);
|
||||||
|
flagLocks = new Object[MantleFlag.values().length];
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
|
|
||||||
for (int i = 0; i < flags.length(); i++) {
|
for (int i = 0; i < flags.length(); i++) {
|
||||||
flags.set(i, 0);
|
flags.set(i, 0);
|
||||||
|
flagLocks[i] = new Object();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -148,11 +151,18 @@ public class MantleChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void raiseFlag(MantleFlag flag, Runnable r) {
|
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 (closed.get()) throw new IllegalStateException("Chunk is closed!");
|
||||||
|
if (guard != null && isFlagged(guard)) return;
|
||||||
|
synchronized (flagLocks[flag.ordinal()]) {
|
||||||
if (flags.getAndSet(flag.ordinal(), 1) == 0) {
|
if (flags.getAndSet(flag.ordinal(), 1) == 0) {
|
||||||
r.run();
|
r.run();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isFlagged(MantleFlag flag) {
|
public boolean isFlagged(MantleFlag flag) {
|
||||||
return flags.get(flag.ordinal()) == 1;
|
return flags.get(flag.ordinal()) == 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user