mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Component writers merged
This commit is contained in:
parent
d0fb3dde66
commit
fca189ee4c
@ -21,38 +21,32 @@ package com.volmit.iris.engine.mantle;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.project.loader.IrisData;
|
||||
import com.volmit.iris.engine.IrisComplex;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineTarget;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.common.IObjectPlacer;
|
||||
import com.volmit.iris.engine.object.dimensional.IrisDimension;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
|
||||
import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
|
||||
import com.volmit.iris.engine.object.regional.IrisRegion;
|
||||
import com.volmit.iris.engine.object.tile.TileData;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.mantle.TectonicPlate;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.parallel.MultiBurst;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.block.TileState;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
// TODO: MOVE PLACER OUT OF MATTER INTO ITS OWN THING
|
||||
@ -164,7 +158,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
|
||||
default void saveAllNow()
|
||||
{
|
||||
|
||||
getMantle().saveAll();
|
||||
}
|
||||
|
||||
default void save()
|
||||
@ -184,7 +178,6 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
|
||||
default int getRealRadius()
|
||||
{
|
||||
getMantle().set(0, 34, 292393, Bukkit.getPlayer("cyberpwn"));
|
||||
try {
|
||||
return (int) Math.ceil(getRadius().get() / 2D);
|
||||
} catch (InterruptedException e) {
|
||||
@ -204,15 +197,29 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
List<Runnable> post = Collections.synchronizedList(new KList<>());
|
||||
Consumer<Runnable> c = post::add;
|
||||
getComponents().forEach((i) -> generateMantleComponent(x, z, i, c));
|
||||
int s = getRealRadius();
|
||||
BurstExecutor burst = burst().burst();
|
||||
|
||||
for (int i = -s; i <= s; i++) {
|
||||
int xx = i + x;
|
||||
for (int j = -s; j <= s; j++) {
|
||||
int zz = j + z;
|
||||
burst.queue(() -> {
|
||||
getComponents().forEach((f) -> generateMantleComponent(xx, zz, f, c));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
burst().burst(post);
|
||||
}
|
||||
|
||||
default void generateMantleComponent(int x, int z, MantleComponent i, Consumer<Runnable> post)
|
||||
default void generateMantleComponent(int x, int z, MantleComponent c, Consumer<Runnable> post)
|
||||
{
|
||||
getMantle().raiseFlag(x, z, i.getFlag(), () -> i.generateLayer(x, z, post));
|
||||
getMantle().raiseFlag(x, z, c.getFlag(), () -> c.generateLayer(x, z, post));
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
|
@ -40,25 +40,12 @@ public class MantleFeatureComponent extends IrisMantleComponent {
|
||||
|
||||
@Override
|
||||
public void generateLayer(int x, int z, Consumer<Runnable> post) {
|
||||
int s = getRadius();
|
||||
BurstExecutor burst = burst();
|
||||
|
||||
for (int i = -s; i <= s; i++) {
|
||||
int xx = i + x;
|
||||
int xxx = 8 + (xx << 4);
|
||||
for (int j = -s; j <= s; j++) {
|
||||
int zz = j + z;
|
||||
int zzz = 8 + (zz << 4);
|
||||
burst.queue(() -> {
|
||||
RNG rng = new RNG(Cache.key(xx, zz) + seed());
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz);
|
||||
generateFeatures(rng, xx, zz, region, biome);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||
int xxx = 8 + (x << 4);
|
||||
int zzz = 8 + (z << 4);
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz);
|
||||
generateFeatures(rng, x, z, region, biome);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
|
@ -46,25 +46,12 @@ public class MantleJigsawComponent extends IrisMantleComponent
|
||||
|
||||
@Override
|
||||
public void generateLayer(int x, int z, Consumer<Runnable> post) {
|
||||
int s = getRadius();
|
||||
BurstExecutor burst = burst();
|
||||
|
||||
for (int i = -s; i <= s; i++) {
|
||||
int xx = i+x;
|
||||
int xxx = 8 + (xx << 4);
|
||||
for (int j = -s; j <= s; j++) {
|
||||
int zz = j + z;
|
||||
int zzz = 8 + (zz << 4);
|
||||
burst.queue(() -> {
|
||||
RNG rng = new RNG(Cache.key(xx, zz) + seed());
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz);
|
||||
generateJigsaw(rng, xx, zz, biome, region, post);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||
int xxx = 8 + (x << 4);
|
||||
int zzz = 8 + (z << 4);
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz);
|
||||
generateJigsaw(rng, x, z, biome, region, post);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
|
@ -31,38 +31,27 @@ import com.volmit.iris.engine.object.objects.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.object.regional.IrisRegion;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.documentation.ChunkCoordinates;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.mantle.MantleFlag;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
||||
public class MantleObjectComponent extends IrisMantleComponent {
|
||||
public MantleObjectComponent(EngineMantle engineMantle) {
|
||||
super(engineMantle, MantleFlag.FEATURE);
|
||||
super(engineMantle, MantleFlag.OBJECT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateLayer(int x, int z, Consumer<Runnable> post) {
|
||||
int s = getRadius();
|
||||
BurstExecutor burst = burst();
|
||||
|
||||
for (int i = -s; i <= s; i++) {
|
||||
int xx = i + x;
|
||||
int xxx = 8 + (xx << 4);
|
||||
for (int j = -s; j <= s; j++) {
|
||||
int zz = j + z;
|
||||
int zzz = 8 + (zz << 4);
|
||||
burst.queue(() -> {
|
||||
RNG rng = new RNG(Cache.key(xx, zz) + seed());
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz);
|
||||
placeObjects(rng, xx, zz, biome, region, post);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
burst.complete();
|
||||
RNG rng = new RNG(Cache.key(x, z) + seed());
|
||||
int xxx = 8 + (x << 4);
|
||||
int zzz = 8 + (z << 4);
|
||||
IrisRegion region = getComplex().getRegionStream().get(xxx, zzz);
|
||||
IrisBiome biome = getComplex().getTrueBiomeStreamNoFeatures().get(xxx, zzz);
|
||||
placeObjects(rng, x, z, biome, region, post);
|
||||
}
|
||||
|
||||
@ChunkCoordinates
|
||||
|
Loading…
x
Reference in New Issue
Block a user