Mantle dont use post handler

This commit is contained in:
cyberpwn 2021-09-12 08:10:29 -04:00
parent 2fd3abbb14
commit ccbd5b17d3
7 changed files with 17 additions and 30 deletions

View File

@ -84,7 +84,7 @@ public class PlannedStructure {
} }
} }
public void place(IObjectPlacer placer, Mantle e, Consumer<Runnable> post) { public void place(IObjectPlacer placer, Mantle e) {
IrisObjectPlacement options = new IrisObjectPlacement(); IrisObjectPlacement options = new IrisObjectPlacement();
options.getRotation().setEnabled(false); options.getRotation().setEnabled(false);
int startHeight = pieces.get(0).getPosition().getY(); int startHeight = pieces.get(0).getPosition().getY();

View File

@ -200,12 +200,6 @@ public interface EngineMantle extends IObjectPlacer {
return; return;
} }
KList<Runnable> post = new KList<>();
Consumer<Runnable> c = (i) -> {
synchronized (post) {
post.add(i);
}
};
int s = getRealRadius(); int s = getRealRadius();
BurstExecutor burst = burst().burst(multicore); BurstExecutor burst = burst().burst(multicore);
MantleWriter writer = getMantle().write(this, x, z, s * 2); MantleWriter writer = getMantle().write(this, x, z, s * 2);
@ -217,25 +211,18 @@ public interface EngineMantle extends IObjectPlacer {
MantleChunk mc = getMantle().getChunk(xx, zz); MantleChunk mc = getMantle().getChunk(xx, zz);
for (MantleComponent k : getComponents()) { for (MantleComponent k : getComponents()) {
generateMantleComponent(writer, xx, zz, k, c, mc); generateMantleComponent(writer, xx, zz, k, mc);
} }
}); });
} }
} }
burst.complete(); burst.complete();
while (!post.isEmpty()) {
KList<Runnable> px = post.copy();
post.clear();
burst().burst(multicore, px);
}
getMantle().flag(x, z, MantleFlag.REAL, true); getMantle().flag(x, z, MantleFlag.REAL, true);
} }
default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, Consumer<Runnable> post, MantleChunk mc) { default void generateMantleComponent(MantleWriter writer, int x, int z, MantleComponent c, MantleChunk mc) {
mc.raiseFlag(c.getFlag(), () -> c.generateLayer(writer, x, z, post)); mc.raiseFlag(c.getFlag(), () -> c.generateLayer(writer, x, z));
} }
@ChunkCoordinates @ChunkCoordinates

View File

@ -62,5 +62,5 @@ public interface MantleComponent {
MantleFlag getFlag(); MantleFlag getFlag();
@ChunkCoordinates @ChunkCoordinates
void generateLayer(MantleWriter writer, int x, int z, Consumer<Runnable> post); void generateLayer(MantleWriter writer, int x, int z);
} }

View File

@ -37,7 +37,7 @@ public class MantleCarvingComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z, Consumer<Runnable> post) { public void generateLayer(MantleWriter writer, int x, int z) {
RNG rng = new RNG(Cache.key(x, z) + seed()); RNG rng = new RNG(Cache.key(x, z) + seed());
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);

View File

@ -39,7 +39,7 @@ public class MantleFeatureComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z, Consumer<Runnable> post) { public void generateLayer(MantleWriter writer, int x, int z) {
RNG rng = new RNG(Cache.key(x, z) + seed()); RNG rng = new RNG(Cache.key(x, z) + seed());
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);

View File

@ -37,7 +37,7 @@ public class MantleFluidBodyComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z, Consumer<Runnable> post) { public void generateLayer(MantleWriter writer, int x, int z) {
RNG rng = new RNG(Cache.key(x, z) + seed() + 405666); RNG rng = new RNG(Cache.key(x, z) + seed() + 405666);
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);

View File

@ -48,17 +48,17 @@ public class MantleJigsawComponent extends IrisMantleComponent {
} }
@Override @Override
public void generateLayer(MantleWriter writer, int x, int z, Consumer<Runnable> post) { public void generateLayer(MantleWriter writer, int x, int z) {
RNG rng = new RNG(cng.fit(-Integer.MAX_VALUE, Integer.MAX_VALUE, x, z)); RNG rng = new RNG(cng.fit(-Integer.MAX_VALUE, Integer.MAX_VALUE, x, z));
int xxx = 8 + (x << 4); int xxx = 8 + (x << 4);
int zzz = 8 + (z << 4); int zzz = 8 + (z << 4);
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz); IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz); IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz);
generateJigsaw(writer, rng, x, z, biome, region, post); generateJigsaw(writer, rng, x, z, biome, region);
} }
@ChunkCoordinates @ChunkCoordinates
private void generateJigsaw(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region, Consumer<Runnable> post) { private void generateJigsaw(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region) {
boolean placed = false; boolean placed = false;
if (getDimension().getStronghold() != null) { if (getDimension().getStronghold() != null) {
@ -68,7 +68,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
for (Position2 pos : poss) { for (Position2 pos : poss) {
if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) { if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) {
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold()); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold());
place(writer, pos.toIris(), structure, rng, post); place(writer, pos.toIris(), structure, rng);
placed = true; placed = true;
} }
} }
@ -80,7 +80,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
if (rng.nextInt(i.getRarity()) == 0) { if (rng.nextInt(i.getRarity()) == 0) {
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
place(writer, position, structure, rng, post); place(writer, position, structure, rng);
placed = true; placed = true;
} }
} }
@ -91,7 +91,7 @@ public class MantleJigsawComponent extends IrisMantleComponent {
if (rng.nextInt(i.getRarity()) == 0) { if (rng.nextInt(i.getRarity()) == 0) {
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
place(writer, position, structure, rng, post); place(writer, position, structure, rng);
placed = true; placed = true;
} }
} }
@ -102,14 +102,14 @@ public class MantleJigsawComponent extends IrisMantleComponent {
if (rng.nextInt(i.getRarity()) == 0) { if (rng.nextInt(i.getRarity()) == 0) {
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
place(writer, position, structure, rng, post); place(writer, position, structure, rng);
} }
} }
} }
} }
@BlockCoordinates @BlockCoordinates
private void place(MantleWriter writer, IrisPosition position, IrisJigsawStructure structure, RNG rng, Consumer<Runnable> post) { private void place(MantleWriter writer, IrisPosition position, IrisJigsawStructure structure, RNG rng) {
if (structure.getFeature() != null) { if (structure.getFeature() != null) {
if (structure.getFeature().getBlockRadius() == 32) { if (structure.getFeature().getBlockRadius() == 32) {
structure.getFeature().setBlockRadius((double) structure.getMaxDimension() / 3); structure.getFeature().setBlockRadius((double) structure.getMaxDimension() / 3);
@ -118,6 +118,6 @@ public class MantleJigsawComponent extends IrisMantleComponent {
new IrisFeaturePositional(position.getX(), position.getZ(), structure.getFeature())); new IrisFeaturePositional(position.getX(), position.getZ(), structure.getFeature()));
} }
new PlannedStructure(structure, position, rng).place(writer, getMantle(), post); new PlannedStructure(structure, position, rng).place(writer, getMantle());
} }
} }