mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-27 11:09:06 +00:00
Cleanup
This commit is contained in:
@@ -25,29 +25,23 @@ public class EnginePanic {
|
||||
private static final KMap<String, String> stuff = new KMap<>();
|
||||
private static KMap<String, String> last = new KMap<>();
|
||||
|
||||
public static void add(String key, String value)
|
||||
{
|
||||
public static void add(String key, String value) {
|
||||
stuff.put(key, value);
|
||||
}
|
||||
|
||||
public static void saveLast()
|
||||
{
|
||||
public static void saveLast() {
|
||||
last = stuff.copy();
|
||||
}
|
||||
|
||||
public static void lastPanic()
|
||||
{
|
||||
for(String i : last.keySet())
|
||||
{
|
||||
public static void lastPanic() {
|
||||
for(String i : last.keySet()) {
|
||||
Iris.error("Last Panic " + i + ": " + stuff.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
public static void panic()
|
||||
{
|
||||
public static void panic() {
|
||||
lastPanic();
|
||||
for(String i : stuff.keySet())
|
||||
{
|
||||
for(String i : stuff.keySet()) {
|
||||
Iris.error("Engine Panic " + i + ": " + stuff.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,70 +102,70 @@ public class IrisComplex implements DataProvider {
|
||||
focusRegion = engine.getFocusRegion();
|
||||
KMap<InferredType, ProceduralStream<IrisBiome>> inferredStreams = new KMap<>();
|
||||
|
||||
if (focusBiome != null) {
|
||||
if(focusBiome != null) {
|
||||
focusBiome.setInferredType(InferredType.LAND);
|
||||
focusRegion = findRegion(focusBiome, engine);
|
||||
}
|
||||
|
||||
//@builder
|
||||
engine.getDimension().getRegions().forEach((i) -> data.getRegionLoader().load(i)
|
||||
.getAllBiomes(this).forEach((b) -> b
|
||||
.getGenerators()
|
||||
.forEach((c) -> registerGenerator(c.getCachedGenerator(this)))));
|
||||
.getAllBiomes(this).forEach((b) -> b
|
||||
.getGenerators()
|
||||
.forEach((c) -> registerGenerator(c.getCachedGenerator(this)))));
|
||||
overlayStream = ProceduralStream.ofDouble((x, z) -> 0D);
|
||||
engine.getDimension().getOverlayNoise().forEach((i) -> overlayStream.add((x, z) -> i.get(rng, getData(), x, z)));
|
||||
rockStream = engine.getDimension().getRockPalette().getLayerGenerator(rng.nextParallelRNG(45), data).stream()
|
||||
.select(engine.getDimension().getRockPalette().getBlockData(data));
|
||||
.select(engine.getDimension().getRockPalette().getBlockData(data));
|
||||
fluidStream = engine.getDimension().getFluidPalette().getLayerGenerator(rng.nextParallelRNG(78), data).stream()
|
||||
.select(engine.getDimension().getFluidPalette().getBlockData(data));
|
||||
.select(engine.getDimension().getFluidPalette().getBlockData(data));
|
||||
regionStyleStream = engine.getDimension().getRegionStyle().create(rng.nextParallelRNG(883), getData()).stream()
|
||||
.zoom(engine.getDimension().getRegionZoom());
|
||||
.zoom(engine.getDimension().getRegionZoom());
|
||||
regionIdentityStream = regionStyleStream.fit(Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||
regionStream = focusRegion != null ?
|
||||
ProceduralStream.of((x, z) -> focusRegion,
|
||||
Interpolated.of(a -> 0D, a -> focusRegion))
|
||||
: regionStyleStream
|
||||
.selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions()))
|
||||
.cache2D("regionStream", engine, cacheSize);
|
||||
ProceduralStream.of((x, z) -> focusRegion,
|
||||
Interpolated.of(a -> 0D, a -> focusRegion))
|
||||
: regionStyleStream
|
||||
.selectRarity(data.getRegionLoader().loadAll(engine.getDimension().getRegions()))
|
||||
.cache2D("regionStream", engine, cacheSize);
|
||||
regionIDStream = regionIdentityStream.convertCached((i) -> new UUID(Double.doubleToLongBits(i), String.valueOf(i * 38445).hashCode() * 3245556666L));
|
||||
caveBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
|
||||
.zoom(r.getCaveBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes()))
|
||||
.onNull(emptyBiome)
|
||||
-> engine.getDimension().getCaveBiomeStyle().create(rng.nextParallelRNG(InferredType.CAVE.ordinal()), getData()).stream()
|
||||
.zoom(r.getCaveBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getCaveBiomes()))
|
||||
.onNull(emptyBiome)
|
||||
).convertAware2D(ProceduralStream::get).cache2D("caveBiomeStream", engine, cacheSize);
|
||||
inferredStreams.put(InferredType.CAVE, caveBiomeStream);
|
||||
landBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
|
||||
.zoom(r.getLandBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND)))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D("landBiomeStream", engine, cacheSize);
|
||||
-> engine.getDimension().getLandBiomeStyle().create(rng.nextParallelRNG(InferredType.LAND.ordinal()), getData()).stream()
|
||||
.zoom(r.getLandBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getLandBiomes(), (t) -> t.setInferredType(InferredType.LAND)))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D("landBiomeStream", engine, cacheSize);
|
||||
inferredStreams.put(InferredType.LAND, landBiomeStream);
|
||||
seaBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
|
||||
.zoom(r.getSeaBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA)))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D("seaBiomeStream", engine, cacheSize);
|
||||
-> engine.getDimension().getSeaBiomeStyle().create(rng.nextParallelRNG(InferredType.SEA.ordinal()), getData()).stream()
|
||||
.zoom(r.getSeaBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getSeaBiomes(), (t) -> t.setInferredType(InferredType.SEA)))
|
||||
).convertAware2D(ProceduralStream::get)
|
||||
.cache2D("seaBiomeStream", engine, cacheSize);
|
||||
inferredStreams.put(InferredType.SEA, seaBiomeStream);
|
||||
shoreBiomeStream = regionStream.convert((r)
|
||||
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
|
||||
.zoom(r.getShoreBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE)))
|
||||
-> engine.getDimension().getShoreBiomeStyle().create(rng.nextParallelRNG(InferredType.SHORE.ordinal()), getData()).stream()
|
||||
.zoom(r.getShoreBiomeZoom())
|
||||
.selectRarity(data.getBiomeLoader().loadAll(r.getShoreBiomes(), (t) -> t.setInferredType(InferredType.SHORE)))
|
||||
).convertAware2D(ProceduralStream::get).cache2D("shoreBiomeStream", engine, cacheSize);
|
||||
inferredStreams.put(InferredType.SHORE, shoreBiomeStream);
|
||||
bridgeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome.getInferredType(),
|
||||
Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) :
|
||||
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData())
|
||||
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND)
|
||||
.cache2D("bridgeStream", engine, cacheSize);
|
||||
Interpolated.of(a -> 0D, a -> focusBiome.getInferredType())) :
|
||||
engine.getDimension().getContinentalStyle().create(rng.nextParallelRNG(234234565), getData())
|
||||
.bake().scale(1D / engine.getDimension().getContinentZoom()).bake().stream()
|
||||
.convert((v) -> v >= engine.getDimension().getLandChance() ? InferredType.SEA : InferredType.LAND)
|
||||
.cache2D("bridgeStream", engine, cacheSize);
|
||||
baseBiomeStream = focusBiome != null ? ProceduralStream.of((x, z) -> focusBiome,
|
||||
Interpolated.of(a -> 0D, a -> focusBiome)) :
|
||||
bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z))
|
||||
.convertAware2D(this::implode)
|
||||
.cache2D("baseBiomeStream", engine, cacheSize);
|
||||
Interpolated.of(a -> 0D, a -> focusBiome)) :
|
||||
bridgeStream.convertAware2D((t, x, z) -> inferredStreams.get(t).get(x, z))
|
||||
.convertAware2D(this::implode)
|
||||
.cache2D("baseBiomeStream", engine, cacheSize);
|
||||
heightStream = ProceduralStream.of((x, z) -> {
|
||||
IrisBiome b = focusBiome != null ? focusBiome : baseBiomeStream.get(x, z);
|
||||
return getHeight(engine, b, x, z, engine.getSeedManager().getHeight());
|
||||
@@ -173,40 +173,40 @@ public class IrisComplex implements DataProvider {
|
||||
roundedHeighteightStream = heightStream.round();
|
||||
slopeStream = heightStream.slope(3).cache2D("slopeStream", engine, cacheSize);
|
||||
trueBiomeStream = focusBiome != null ? ProceduralStream.of((x, y) -> focusBiome, Interpolated.of(a -> 0D,
|
||||
b -> focusBiome))
|
||||
.cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream
|
||||
.convertAware2D((h, x, z) ->
|
||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||
regionStream.get(x, z), x, z, fluidHeight))
|
||||
.cache2D("trueBiomeStream", engine, cacheSize);
|
||||
b -> focusBiome))
|
||||
.cache2D("trueBiomeStream-focus", engine, cacheSize) : heightStream
|
||||
.convertAware2D((h, x, z) ->
|
||||
fixBiomeType(h, baseBiomeStream.get(x, z),
|
||||
regionStream.get(x, z), x, z, fluidHeight))
|
||||
.cache2D("trueBiomeStream", engine, cacheSize);
|
||||
trueBiomeDerivativeStream = trueBiomeStream.convert(IrisBiome::getDerivative).cache2D("trueBiomeDerivativeStream", engine, cacheSize);
|
||||
heightFluidStream = heightStream.max(fluidHeight).cache2D("heightFluidStream", engine, cacheSize);
|
||||
maxHeightStream = ProceduralStream.ofDouble((x, z) -> height);
|
||||
terrainSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainSurfaceDecoration", engine, cacheSize);
|
||||
terrainCeilingDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCeilingDecoration", engine, cacheSize);
|
||||
terrainCaveSurfaceDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.NONE)).cache2D("terrainCaveSurfaceDecoration", engine, cacheSize);
|
||||
terrainCaveCeilingDecoration = caveBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.CEILING)).cache2D("terrainCaveCeilingDecoration", engine, cacheSize);
|
||||
shoreSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SHORE_LINE)).cache2D("shoreSurfaceDecoration", engine, cacheSize);
|
||||
seaSurfaceDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_SURFACE)).cache2D("seaSurfaceDecoration", engine, cacheSize);
|
||||
seaFloorDecoration = trueBiomeStream
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize);
|
||||
.convertAware2D((b, xx, zz) -> decorateFor(b, xx, zz, IrisDecorationPart.SEA_FLOOR)).cache2D("seaFloorDecoration", engine, cacheSize);
|
||||
baseBiomeIDStream = trueBiomeStream.convertAware2D((b, x, z) -> {
|
||||
UUID d = regionIDStream.get(x, z);
|
||||
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
||||
d.hashCode());
|
||||
})
|
||||
.cache2D("", engine, cacheSize);
|
||||
UUID d = regionIDStream.get(x, z);
|
||||
return new UUID(b.getLoadKey().hashCode() * 818223L,
|
||||
d.hashCode());
|
||||
})
|
||||
.cache2D("", engine, cacheSize);
|
||||
//@done
|
||||
}
|
||||
|
||||
public ProceduralStream<IrisBiome> getBiomeStream(InferredType type) {
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case CAVE:
|
||||
return caveBiomeStream;
|
||||
case LAND:
|
||||
@@ -224,8 +224,8 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
private IrisRegion findRegion(IrisBiome focus, Engine engine) {
|
||||
for (IrisRegion i : engine.getDimension().getAllRegions(engine)) {
|
||||
if (i.getAllBiomeIds().contains(focus.getLoadKey())) {
|
||||
for(IrisRegion i : engine.getDimension().getAllRegions(engine)) {
|
||||
if(i.getAllBiomeIds().contains(focus.getLoadKey())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -236,14 +236,14 @@ public class IrisComplex implements DataProvider {
|
||||
private IrisDecorator decorateFor(IrisBiome b, double x, double z, IrisDecorationPart part) {
|
||||
RNG rngc = new RNG(Cache.key(((int) x), ((int) z)));
|
||||
|
||||
for (IrisDecorator i : b.getDecorators()) {
|
||||
if (!i.getPartOf().equals(part)) {
|
||||
for(IrisDecorator i : b.getDecorators()) {
|
||||
if(!i.getPartOf().equals(part)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
BlockData block = i.getBlockData(b, rngc, x, z, data);
|
||||
|
||||
if (block != null) {
|
||||
if(block != null) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -254,19 +254,19 @@ public class IrisComplex implements DataProvider {
|
||||
private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight) {
|
||||
double sh = region.getShoreHeight(x, z);
|
||||
|
||||
if (height >= fluidHeight - 1 && height <= fluidHeight + sh && !biome.isShore()) {
|
||||
if(height >= fluidHeight - 1 && height <= fluidHeight + sh && !biome.isShore()) {
|
||||
return shoreBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if (height > fluidHeight + sh && !biome.isLand()) {
|
||||
if(height > fluidHeight + sh && !biome.isLand()) {
|
||||
return landBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if (height < fluidHeight && !biome.isAquatic()) {
|
||||
if(height < fluidHeight && !biome.isAquatic()) {
|
||||
return seaBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
if (height == fluidHeight && !biome.isShore()) {
|
||||
if(height == fluidHeight && !biome.isShore()) {
|
||||
return shoreBiomeStream.get(x, z);
|
||||
}
|
||||
|
||||
@@ -274,7 +274,7 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
private double interpolateGenerators(Engine engine, IrisInterpolator interpolator, KSet<IrisGenerator> generators, double x, double z, long seed) {
|
||||
if (generators.isEmpty()) {
|
||||
if(generators.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -283,12 +283,12 @@ public class IrisComplex implements DataProvider {
|
||||
IrisBiome bx = baseBiomeStream.get(xx, zz);
|
||||
double b = 0;
|
||||
|
||||
for (IrisGenerator gen : generators) {
|
||||
for(IrisGenerator gen : generators) {
|
||||
b += bx.getGenLinkMax(gen.getLoadKey());
|
||||
}
|
||||
|
||||
return b;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.error("Failed to sample hi biome at " + xx + " " + zz + "...");
|
||||
@@ -302,12 +302,12 @@ public class IrisComplex implements DataProvider {
|
||||
IrisBiome bx = baseBiomeStream.get(xx, zz);
|
||||
double b = 0;
|
||||
|
||||
for (IrisGenerator gen : generators) {
|
||||
for(IrisGenerator gen : generators) {
|
||||
b += bx.getGenLinkMin(gen.getLoadKey());
|
||||
}
|
||||
|
||||
return b;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.error("Failed to sample lo biome at " + xx + " " + zz + "...");
|
||||
@@ -318,7 +318,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
double d = 0;
|
||||
|
||||
for (IrisGenerator i : generators) {
|
||||
for(IrisGenerator i : generators) {
|
||||
d += M.lerp(lo, hi, i.getHeight(x, z, seed + 239945));
|
||||
}
|
||||
|
||||
@@ -328,7 +328,7 @@ public class IrisComplex implements DataProvider {
|
||||
private double getInterpolatedHeight(Engine engine, double x, double z, long seed) {
|
||||
double h = 0;
|
||||
|
||||
for (IrisInterpolator i : generators.keySet()) {
|
||||
for(IrisInterpolator i : generators.keySet()) {
|
||||
h += interpolateGenerators(engine, i, generators.get(i), x, z, seed);
|
||||
}
|
||||
|
||||
@@ -337,7 +337,7 @@ public class IrisComplex implements DataProvider {
|
||||
|
||||
private double getHeight(Engine engine, IrisBiome b, double x, double z, long seed) {
|
||||
return Math.min(engine.getHeight(),
|
||||
Math.max(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), 0));
|
||||
Math.max(getInterpolatedHeight(engine, x, z, seed) + fluidHeight + overlayStream.get(x, z), 0));
|
||||
}
|
||||
|
||||
private void registerGenerator(IrisGenerator cachedGenerator) {
|
||||
@@ -345,7 +345,7 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z) {
|
||||
if (b.getChildren().isEmpty()) {
|
||||
if(b.getChildren().isEmpty()) {
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -353,11 +353,11 @@ public class IrisComplex implements DataProvider {
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z, int max) {
|
||||
if (max < 0) {
|
||||
if(max < 0) {
|
||||
return b;
|
||||
}
|
||||
|
||||
if (b.getChildren().isEmpty()) {
|
||||
if(b.getChildren().isEmpty()) {
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
@@ -35,7 +35,13 @@ import com.volmit.iris.engine.framework.EngineWorldManager;
|
||||
import com.volmit.iris.engine.framework.SeedManager;
|
||||
import com.volmit.iris.engine.framework.WrongEngineBroException;
|
||||
import com.volmit.iris.engine.mantle.EngineMantle;
|
||||
import com.volmit.iris.engine.object.*;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
|
||||
import com.volmit.iris.engine.object.IrisDecorator;
|
||||
import com.volmit.iris.engine.object.IrisEngineData;
|
||||
import com.volmit.iris.engine.object.IrisJigsawStructure;
|
||||
import com.volmit.iris.engine.object.IrisObjectPlacement;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.engine.scripting.EngineExecutionEnvironment;
|
||||
import com.volmit.iris.util.atomics.AtomicRollingSequence;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
@@ -132,18 +138,18 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void verifySeed() {
|
||||
if (getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) {
|
||||
if(getEngineData().getSeed() != null && getEngineData().getSeed() != target.getWorld().getRawWorldSeed()) {
|
||||
target.getWorld().setRawWorldSeed(getEngineData().getSeed());
|
||||
}
|
||||
}
|
||||
|
||||
private void tickRandomPlayer() {
|
||||
if (perSecondBudLatch.flip()) {
|
||||
if(perSecondBudLatch.flip()) {
|
||||
buds.set(bud.get());
|
||||
bud.set(0);
|
||||
}
|
||||
|
||||
if (effects != null) {
|
||||
if(effects != null) {
|
||||
effects.tickRandomPlayer();
|
||||
}
|
||||
}
|
||||
@@ -168,7 +174,7 @@ public class IrisEngine implements Engine {
|
||||
effects = new IrisEngineEffects(this);
|
||||
setupMode();
|
||||
J.a(this::computeBiomeMaxes);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.error("FAILED TO SETUP ENGINE!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -177,7 +183,7 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void setupMode() {
|
||||
if (mode != null) {
|
||||
if(mode != null) {
|
||||
mode.close();
|
||||
}
|
||||
|
||||
@@ -200,8 +206,8 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void warmupChunk(int x, int z) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
for(int i = 0; i < 16; i++) {
|
||||
for(int j = 0; j < 16; j++) {
|
||||
int xx = x + (i << 4);
|
||||
int zz = z + (z << 4);
|
||||
getComplex().getTrueBiomeStream().get(xx, zz);
|
||||
@@ -237,18 +243,18 @@ public class IrisEngine implements Engine {
|
||||
//TODO: Method this file
|
||||
File f = new File(getWorld().worldFolder(), "iris/engine-data/" + getDimension().getLoadKey() + ".json");
|
||||
|
||||
if (!f.exists()) {
|
||||
if(!f.exists()) {
|
||||
try {
|
||||
f.getParentFile().mkdirs();
|
||||
IO.writeAll(f, new Gson().toJson(new IrisEngineData()));
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return new Gson().fromJson(IO.readAll(f), IrisEngineData.class);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -263,11 +269,11 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public double getGeneratedPerSecond() {
|
||||
if (perSecondLatch.flip()) {
|
||||
if(perSecondLatch.flip()) {
|
||||
double g = generated.get() - generatedLast.get();
|
||||
generatedLast.set(generated.get());
|
||||
|
||||
if (g == 0) {
|
||||
if(g == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -285,24 +291,24 @@ public class IrisEngine implements Engine {
|
||||
}
|
||||
|
||||
private void computeBiomeMaxes() {
|
||||
for (IrisBiome i : getDimension().getAllBiomes(this)) {
|
||||
for(IrisBiome i : getDimension().getAllBiomes(this)) {
|
||||
double density = 0;
|
||||
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
for(IrisObjectPlacement j : i.getObjects()) {
|
||||
density += j.getDensity() * j.getChance();
|
||||
}
|
||||
|
||||
maxBiomeObjectDensity = Math.max(maxBiomeObjectDensity, density);
|
||||
density = 0;
|
||||
|
||||
for (IrisDecorator j : i.getDecorators()) {
|
||||
for(IrisDecorator j : i.getDecorators()) {
|
||||
density += Math.max(j.getStackMax(), 1) * j.getChance();
|
||||
}
|
||||
|
||||
maxBiomeDecoratorDensity = Math.max(maxBiomeDecoratorDensity, density);
|
||||
density = 0;
|
||||
|
||||
for (IrisBiomePaletteLayer j : i.getLayers()) {
|
||||
for(IrisBiomePaletteLayer j : i.getLayers()) {
|
||||
density++;
|
||||
}
|
||||
|
||||
@@ -323,11 +329,11 @@ public class IrisEngine implements Engine {
|
||||
double totalWeight = 0;
|
||||
double wallClock = getMetrics().getTotal().getAverage();
|
||||
|
||||
for (double j : timings.values()) {
|
||||
for(double j : timings.values()) {
|
||||
totalWeight += j;
|
||||
}
|
||||
|
||||
for (String j : timings.k()) {
|
||||
for(String j : timings.k()) {
|
||||
weights.put(getName() + "." + j, (wallClock / totalWeight) * timings.get(j));
|
||||
}
|
||||
|
||||
@@ -335,33 +341,33 @@ public class IrisEngine implements Engine {
|
||||
|
||||
double mtotals = 0;
|
||||
|
||||
for (double i : totals.values()) {
|
||||
for(double i : totals.values()) {
|
||||
mtotals += i;
|
||||
}
|
||||
|
||||
for (String i : totals.k()) {
|
||||
for(String i : totals.k()) {
|
||||
totals.put(i, (masterWallClock / mtotals) * totals.get(i));
|
||||
}
|
||||
|
||||
double v = 0;
|
||||
|
||||
for (double i : weights.values()) {
|
||||
for(double i : weights.values()) {
|
||||
v += i;
|
||||
}
|
||||
|
||||
for (String i : weights.k()) {
|
||||
for(String i : weights.k()) {
|
||||
weights.put(i, weights.get(i) / v);
|
||||
}
|
||||
|
||||
sender.sendMessage("Total: " + C.BOLD + C.WHITE + Form.duration(masterWallClock, 0));
|
||||
|
||||
for (String i : totals.k()) {
|
||||
for(String i : totals.k()) {
|
||||
sender.sendMessage(" Engine " + C.UNDERLINE + C.GREEN + i + C.RESET + ": " + C.BOLD + C.WHITE + Form.duration(totals.get(i), 0));
|
||||
}
|
||||
|
||||
sender.sendMessage("Details: ");
|
||||
|
||||
for (String i : weights.sortKNumber().reverse()) {
|
||||
for(String i : weights.sortKNumber().reverse()) {
|
||||
String befb = C.UNDERLINE + "" + C.GREEN + "" + i.split("\\Q[\\E")[0] + C.RESET + C.GRAY + "[";
|
||||
String num = C.GOLD + i.split("\\Q[\\E")[1].split("]")[0] + C.RESET + C.GRAY + "].";
|
||||
String afb = C.ITALIC + "" + C.AQUA + i.split("\\Q]\\E")[1].substring(1) + C.RESET + C.GRAY;
|
||||
@@ -395,11 +401,11 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
if (!cleanLatch.flip()) {
|
||||
if(!cleanLatch.flip()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cleaning.get()) {
|
||||
if(cleaning.get()) {
|
||||
cleanLatch.flipDown();
|
||||
return;
|
||||
}
|
||||
@@ -410,7 +416,7 @@ public class IrisEngine implements Engine {
|
||||
try {
|
||||
getMantle().trim();
|
||||
getData().getObjectLoader().clean();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("Cleanup failed! Enable debug to see stacktrace.");
|
||||
}
|
||||
@@ -422,7 +428,7 @@ public class IrisEngine implements Engine {
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void generate(int x, int z, Hunk<BlockData> vblocks, Hunk<Biome> vbiomes, boolean multicore) throws WrongEngineBroException {
|
||||
if (closed) {
|
||||
if(closed) {
|
||||
throw new WrongEngineBroException();
|
||||
}
|
||||
|
||||
@@ -432,9 +438,9 @@ public class IrisEngine implements Engine {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Hunk<BlockData> blocks = vblocks.listen((xx, y, zz, t) -> catchBlockUpdates(x + xx, y + getMinHeight(), z + zz, t));
|
||||
|
||||
if (getDimension().isDebugChunkCrossSections() && ((x >> 4) % getDimension().getDebugCrossSectionsMod() == 0 || (z >> 4) % getDimension().getDebugCrossSectionsMod() == 0)) {
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
if(getDimension().isDebugChunkCrossSections() && ((x >> 4) % getDimension().getDebugCrossSectionsMod() == 0 || (z >> 4) % getDimension().getDebugCrossSectionsMod() == 0)) {
|
||||
for(int i = 0; i < 16; i++) {
|
||||
for(int j = 0; j < 16; j++) {
|
||||
blocks.set(i, 0, j, Material.CRYING_OBSIDIAN.createBlockData());
|
||||
}
|
||||
}
|
||||
@@ -446,7 +452,7 @@ public class IrisEngine implements Engine {
|
||||
getMetrics().getTotal().put(p.getMilliseconds());
|
||||
generated.incrementAndGet();
|
||||
recycle();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
fail("Failed to generate " + x + ", " + z, e);
|
||||
}
|
||||
@@ -460,7 +466,7 @@ public class IrisEngine implements Engine {
|
||||
try {
|
||||
IO.writeAll(f, new Gson().toJson(getEngineData()));
|
||||
Iris.debug("Saved Engine Data");
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Iris.error("Failed to save Engine Data");
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -473,7 +479,7 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public IrisBiome getFocus() {
|
||||
if (getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) {
|
||||
if(getDimension().getFocus() == null || getDimension().getFocus().trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -482,12 +488,13 @@ public class IrisEngine implements Engine {
|
||||
|
||||
@Override
|
||||
public IrisRegion getFocusRegion() {
|
||||
if (getDimension().getFocusRegion() == null || getDimension().getFocusRegion().trim().isEmpty()) {
|
||||
if(getDimension().getFocusRegion() == null || getDimension().getFocusRegion().trim().isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return getData().getRegionLoader().load(getDimension().getFocusRegion());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail(String error, Throwable e) {
|
||||
failing = true;
|
||||
|
||||
@@ -45,19 +45,19 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
|
||||
public void updatePlayerMap() {
|
||||
List<Player> pr = getEngine().getWorld().getPlayers();
|
||||
|
||||
if (pr == null) {
|
||||
if(pr == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (Player i : pr) {
|
||||
for(Player i : pr) {
|
||||
boolean pcc = players.containsKey(i.getUniqueId());
|
||||
if (!pcc) {
|
||||
if(!pcc) {
|
||||
players.put(i.getUniqueId(), new EnginePlayer(getEngine(), i));
|
||||
}
|
||||
}
|
||||
|
||||
for (UUID i : players.k()) {
|
||||
if (!pr.contains(players.get(i).getPlayer())) {
|
||||
for(UUID i : players.k()) {
|
||||
if(!pr.contains(players.get(i).getPlayer())) {
|
||||
players.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -65,14 +65,14 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
|
||||
|
||||
@Override
|
||||
public void tickRandomPlayer() {
|
||||
if (limit.tryAcquire()) {
|
||||
if (M.r(0.02)) {
|
||||
if(limit.tryAcquire()) {
|
||||
if(M.r(0.02)) {
|
||||
updatePlayerMap();
|
||||
limit.release();
|
||||
return;
|
||||
}
|
||||
|
||||
if (players.isEmpty()) {
|
||||
if(players.isEmpty()) {
|
||||
limit.release();
|
||||
return;
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class IrisEngineEffects extends EngineAssignedComponent implements Engine
|
||||
int max = players.size();
|
||||
PrecisionStopwatch p = new PrecisionStopwatch();
|
||||
|
||||
while (max-- > 0 && M.ms() - p.getMilliseconds() < limitms) {
|
||||
while(max-- > 0 && M.ms() - p.getMilliseconds() < limitms) {
|
||||
players.v().getRandom().tick();
|
||||
}
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
private KList<IrisRegion> getAllRegions() {
|
||||
KList<IrisRegion> r = new KList<>();
|
||||
|
||||
for (String i : getEngine().getDimension().getRegions()) {
|
||||
for(String i : getEngine().getDimension().getRegions()) {
|
||||
r.add(getEngine().getData().getRegionLoader().load(i));
|
||||
}
|
||||
|
||||
@@ -99,7 +99,7 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
private KList<IrisBiome> getAllBiomes() {
|
||||
KList<IrisBiome> r = new KList<>();
|
||||
|
||||
for (IrisRegion i : getAllRegions()) {
|
||||
for(IrisRegion i : getAllRegions()) {
|
||||
r.addAll(i.getAllBiomes(getEngine()));
|
||||
}
|
||||
|
||||
@@ -107,13 +107,13 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
}
|
||||
|
||||
private void warn(String ob, BlockVector bv) {
|
||||
if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
if(Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
Iris.warn("Object " + ob + " has a large size (" + bv + ") and may increase memory usage!");
|
||||
}
|
||||
}
|
||||
|
||||
private void warnScaled(String ob, BlockVector bv, double ms) {
|
||||
if (Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
if(Math.max(bv.getBlockX(), bv.getBlockZ()) > 128) {
|
||||
Iris.warn("Object " + ob + " has a large size (" + bv + ") and may increase memory usage! (Object scaled up to " + Form.pc(ms, 2) + ")");
|
||||
}
|
||||
}
|
||||
@@ -130,46 +130,46 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
int x = xg.get();
|
||||
int z = zg.get();
|
||||
|
||||
if (getEngine().getDimension().isUseMantle()) {
|
||||
if(getEngine().getDimension().isUseMantle()) {
|
||||
KList<IrisRegion> r = getAllRegions();
|
||||
KList<IrisBiome> b = getAllBiomes();
|
||||
|
||||
for (IrisBiome i : b) {
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
if (j.getScale().canScaleBeyond()) {
|
||||
for(IrisBiome i : b) {
|
||||
for(IrisObjectPlacement j : i.getObjects()) {
|
||||
if(j.getScale().canScaleBeyond()) {
|
||||
scalars.put(j.getScale(), j.getPlace());
|
||||
} else {
|
||||
objects.addAll(j.getPlace());
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisJigsawStructurePlacement j : i.getJigsawStructures()) {
|
||||
for(IrisJigsawStructurePlacement j : i.getJigsawStructures()) {
|
||||
jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension());
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisRegion i : r) {
|
||||
for (IrisObjectPlacement j : i.getObjects()) {
|
||||
if (j.getScale().canScaleBeyond()) {
|
||||
for(IrisRegion i : r) {
|
||||
for(IrisObjectPlacement j : i.getObjects()) {
|
||||
if(j.getScale().canScaleBeyond()) {
|
||||
scalars.put(j.getScale(), j.getPlace());
|
||||
} else {
|
||||
objects.addAll(j.getPlace());
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisJigsawStructurePlacement j : i.getJigsawStructures()) {
|
||||
for(IrisJigsawStructurePlacement j : i.getJigsawStructures()) {
|
||||
jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension());
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisJigsawStructurePlacement j : getEngine().getDimension().getJigsawStructures()) {
|
||||
for(IrisJigsawStructurePlacement j : getEngine().getDimension().getJigsawStructures()) {
|
||||
jig = Math.max(jig, getData().getJigsawStructureLoader().load(j.getStructure()).getMaxDimension());
|
||||
}
|
||||
|
||||
if (getEngine().getDimension().getStronghold() != null) {
|
||||
if(getEngine().getDimension().getStronghold() != null) {
|
||||
try {
|
||||
jig = Math.max(jig, getData().getJigsawStructureLoader().load(getEngine().getDimension().getStronghold()).getMaxDimension());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -178,13 +178,13 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
Iris.verbose("Checking sizes for " + Form.f(objects.size()) + " referenced objects.");
|
||||
BurstExecutor e = getEngine().getTarget().getBurster().burst(objects.size());
|
||||
KMap<String, BlockVector> sizeCache = new KMap<>();
|
||||
for (String i : objects) {
|
||||
for(String i : objects) {
|
||||
e.queue(() -> {
|
||||
try {
|
||||
BlockVector bv = sizeCache.computeIfAbsent(i, (k) -> {
|
||||
try {
|
||||
return IrisObject.sampleSize(getData().getObjectLoader().findFile(i));
|
||||
} catch (IOException ex) {
|
||||
} catch(IOException ex) {
|
||||
Iris.reportError(ex);
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@@ -192,35 +192,35 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
return null;
|
||||
});
|
||||
|
||||
if (bv == null) {
|
||||
if(bv == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
warn(i, bv);
|
||||
|
||||
synchronized (xg) {
|
||||
synchronized(xg) {
|
||||
xg.getAndSet(Math.max(bv.getBlockX(), xg.get()));
|
||||
}
|
||||
|
||||
synchronized (zg) {
|
||||
synchronized(zg) {
|
||||
zg.getAndSet(Math.max(bv.getBlockZ(), zg.get()));
|
||||
}
|
||||
} catch (Throwable ed) {
|
||||
} catch(Throwable ed) {
|
||||
Iris.reportError(ed);
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
for (Map.Entry<IrisObjectScale, KList<String>> entry : scalars.entrySet()) {
|
||||
for(Map.Entry<IrisObjectScale, KList<String>> entry : scalars.entrySet()) {
|
||||
double ms = entry.getKey().getMaximumScale();
|
||||
for (String j : entry.getValue()) {
|
||||
for(String j : entry.getValue()) {
|
||||
e.queue(() -> {
|
||||
try {
|
||||
BlockVector bv = sizeCache.computeIfAbsent(j, (k) -> {
|
||||
try {
|
||||
return IrisObject.sampleSize(getData().getObjectLoader().findFile(j));
|
||||
} catch (IOException ioException) {
|
||||
} catch(IOException ioException) {
|
||||
Iris.reportError(ioException);
|
||||
ioException.printStackTrace();
|
||||
}
|
||||
@@ -228,20 +228,20 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
return null;
|
||||
});
|
||||
|
||||
if (bv == null) {
|
||||
if(bv == null) {
|
||||
throw new RuntimeException();
|
||||
}
|
||||
|
||||
warnScaled(j, bv, ms);
|
||||
|
||||
synchronized (xg) {
|
||||
synchronized(xg) {
|
||||
xg.getAndSet((int) Math.max(Math.ceil(bv.getBlockX() * ms), xg.get()));
|
||||
}
|
||||
|
||||
synchronized (zg) {
|
||||
synchronized(zg) {
|
||||
zg.getAndSet((int) Math.max(Math.ceil(bv.getBlockZ() * ms), zg.get()));
|
||||
}
|
||||
} catch (Throwable ee) {
|
||||
} catch(Throwable ee) {
|
||||
Iris.reportError(ee);
|
||||
|
||||
}
|
||||
@@ -254,22 +254,22 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
x = xg.get();
|
||||
z = zg.get();
|
||||
|
||||
for (IrisDepositGenerator i : getEngine().getDimension().getDeposits()) {
|
||||
for(IrisDepositGenerator i : getEngine().getDimension().getDeposits()) {
|
||||
int max = i.getMaxDimension();
|
||||
x = Math.max(max, x);
|
||||
z = Math.max(max, z);
|
||||
}
|
||||
|
||||
for (IrisRegion v : r) {
|
||||
for (IrisDepositGenerator i : v.getDeposits()) {
|
||||
for(IrisRegion v : r) {
|
||||
for(IrisDepositGenerator i : v.getDeposits()) {
|
||||
int max = i.getMaxDimension();
|
||||
x = Math.max(max, x);
|
||||
z = Math.max(max, z);
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisBiome v : b) {
|
||||
for (IrisDepositGenerator i : v.getDeposits()) {
|
||||
for(IrisBiome v : b) {
|
||||
for(IrisDepositGenerator i : v.getDeposits()) {
|
||||
int max = i.getMaxDimension();
|
||||
x = Math.max(max, x);
|
||||
z = Math.max(max, z);
|
||||
@@ -299,11 +299,11 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
|
||||
m = Math.max(m, getDimension().getFluidBodies().getMaxRange(getData()));
|
||||
|
||||
for (IrisRegion i : getDimension().getAllRegions(getEngine())) {
|
||||
for(IrisRegion i : getDimension().getAllRegions(getEngine())) {
|
||||
m = Math.max(m, i.getFluidBodies().getMaxRange(getData()));
|
||||
}
|
||||
|
||||
for (IrisBiome i : getDimension().getAllBiomes(getEngine())) {
|
||||
for(IrisBiome i : getDimension().getAllBiomes(getEngine())) {
|
||||
m = Math.max(m, i.getFluidBodies().getMaxRange(getData()));
|
||||
}
|
||||
|
||||
@@ -315,11 +315,11 @@ public class IrisEngineMantle implements EngineMantle {
|
||||
|
||||
m = Math.max(m, getDimension().getCarving().getMaxRange(getData()));
|
||||
|
||||
for (IrisRegion i : getDimension().getAllRegions(getEngine())) {
|
||||
for(IrisRegion i : getDimension().getAllRegions(getEngine())) {
|
||||
m = Math.max(m, i.getCarving().getMaxRange(getData()));
|
||||
}
|
||||
|
||||
for (IrisBiome i : getDimension().getAllBiomes(getEngine())) {
|
||||
for(IrisBiome i : getDimension().getAllBiomes(getEngine())) {
|
||||
m = Math.max(m, i.getCarving().getMaxRange(getData()));
|
||||
}
|
||||
|
||||
|
||||
@@ -44,7 +44,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment {
|
||||
try {
|
||||
this.manager.declareBean("Iris", api, api.getClass());
|
||||
this.javaScriptEngine = (JavaScriptEngine) this.manager.loadScriptingEngine("javascript");
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -62,7 +62,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment {
|
||||
Iris.debug("Execute Script (void) " + C.DARK_GREEN + script.getLoadKey());
|
||||
try {
|
||||
javaScriptEngine.exec("", 0, 0, script);
|
||||
} catch (BSFException e) {
|
||||
} catch(BSFException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@@ -71,7 +71,7 @@ public class IrisExecutionEnvironment implements EngineExecutionEnvironment {
|
||||
Iris.debug("Execute Script (for result) " + C.DARK_GREEN + script);
|
||||
try {
|
||||
return javaScriptEngine.eval("", 0, 0, getEngine().getData().getScriptLoader().load(script));
|
||||
} catch (BSFException e) {
|
||||
} catch(BSFException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -118,47 +118,47 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
looper = new Looper() {
|
||||
@Override
|
||||
protected long loop() {
|
||||
if (getEngine().isClosed() || getEngine().getCacheID() != id) {
|
||||
if(getEngine().isClosed() || getEngine().getCacheID() != id) {
|
||||
interrupt();
|
||||
}
|
||||
|
||||
if (!getEngine().getWorld().hasRealWorld() && clw.flip()) {
|
||||
if(!getEngine().getWorld().hasRealWorld() && clw.flip()) {
|
||||
getEngine().getWorld().tryGetRealWorld();
|
||||
}
|
||||
|
||||
if (!IrisSettings.get().getWorld().isMarkerEntitySpawningSystem() && !IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()) {
|
||||
if(!IrisSettings.get().getWorld().isMarkerEntitySpawningSystem() && !IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()) {
|
||||
return 3000;
|
||||
}
|
||||
|
||||
if (getEngine().getWorld().hasRealWorld()) {
|
||||
if (getEngine().getWorld().getPlayers().isEmpty()) {
|
||||
if(getEngine().getWorld().hasRealWorld()) {
|
||||
if(getEngine().getWorld().getPlayers().isEmpty()) {
|
||||
return 5000;
|
||||
}
|
||||
|
||||
if (chunkUpdater.flip()) {
|
||||
if(chunkUpdater.flip()) {
|
||||
updateChunks();
|
||||
}
|
||||
|
||||
|
||||
if (getDimension().isInfiniteEnergy()) {
|
||||
if(getDimension().isInfiniteEnergy()) {
|
||||
energy += 1000;
|
||||
fixEnergy();
|
||||
}
|
||||
|
||||
if (M.ms() < charge) {
|
||||
if(M.ms() < charge) {
|
||||
energy += 70;
|
||||
fixEnergy();
|
||||
}
|
||||
|
||||
if (cln.flip()) {
|
||||
if(cln.flip()) {
|
||||
engine.getEngineData().cleanup(getEngine());
|
||||
}
|
||||
|
||||
if (precount != null) {
|
||||
if(precount != null) {
|
||||
entityCount = 0;
|
||||
for (Entity i : precount) {
|
||||
if (i instanceof LivingEntity) {
|
||||
if (!i.isDead()) {
|
||||
for(Entity i : precount) {
|
||||
if(i instanceof LivingEntity) {
|
||||
if(!i.isDead()) {
|
||||
entityCount++;
|
||||
}
|
||||
}
|
||||
@@ -167,8 +167,8 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
precount = null;
|
||||
}
|
||||
|
||||
if (energy < 650) {
|
||||
if (ecl.flip()) {
|
||||
if(energy < 650) {
|
||||
if(ecl.flip()) {
|
||||
energy *= 1 + (0.02 * M.clip((1D - getEntitySaturation()), 0D, 1D));
|
||||
fixEnergy();
|
||||
}
|
||||
@@ -186,34 +186,34 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private void updateChunks() {
|
||||
for (Player i : getEngine().getWorld().realWorld().getPlayers()) {
|
||||
for(Player i : getEngine().getWorld().realWorld().getPlayers()) {
|
||||
int r = 1;
|
||||
|
||||
Chunk c = i.getLocation().getChunk();
|
||||
for (int x = -r; x <= r; x++) {
|
||||
for (int z = -r; z <= r; z++) {
|
||||
if (c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) {
|
||||
for(int x = -r; x <= r; x++) {
|
||||
for(int z = -r; z <= r; z++) {
|
||||
if(c.getWorld().isChunkLoaded(c.getX() + x, c.getZ() + z) && Chunks.isSafe(getEngine().getWorld().realWorld(), c.getX() + x, c.getZ() + z)) {
|
||||
|
||||
if (IrisSettings.get().getWorld().isPostLoadBlockUpdates()) {
|
||||
if(IrisSettings.get().getWorld().isPostLoadBlockUpdates()) {
|
||||
getEngine().updateChunk(c.getWorld().getChunkAt(c.getX() + x, c.getZ() + z));
|
||||
}
|
||||
|
||||
if (IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) {
|
||||
if(IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) {
|
||||
Chunk cx = getEngine().getWorld().realWorld().getChunkAt(c.getX() + x, c.getZ() + z);
|
||||
int finalX = c.getX() + x;
|
||||
int finalZ = c.getZ() + z;
|
||||
J.a(() -> getMantle().raiseFlag(finalX, finalZ, MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||
() -> {
|
||||
J.a(() -> spawnIn(cx, true), RNG.r.i(5, 200));
|
||||
getSpawnersFromMarkers(cx).forEach((block, spawners) -> {
|
||||
if (spawners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
() -> {
|
||||
J.a(() -> spawnIn(cx, true), RNG.r.i(5, 200));
|
||||
getSpawnersFromMarkers(cx).forEach((block, spawners) -> {
|
||||
if(spawners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||
spawn(block, s, true);
|
||||
});
|
||||
}));
|
||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||
spawn(block, s, true);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -222,42 +222,42 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private boolean onAsyncTick() {
|
||||
if (getEngine().isClosed()) {
|
||||
if(getEngine().isClosed()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
actuallySpawned = 0;
|
||||
|
||||
if (energy < 100) {
|
||||
if(energy < 100) {
|
||||
J.sleep(200);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!getEngine().getWorld().hasRealWorld()) {
|
||||
if(!getEngine().getWorld().hasRealWorld()) {
|
||||
Iris.debug("Can't spawn. No real world");
|
||||
J.sleep(5000);
|
||||
return false;
|
||||
}
|
||||
|
||||
double epx = getEntitySaturation();
|
||||
if (epx > IrisSettings.get().getWorld().getTargetSpawnEntitiesPerChunk()) {
|
||||
if(epx > IrisSettings.get().getWorld().getTargetSpawnEntitiesPerChunk()) {
|
||||
Iris.debug("Can't spawn. The entity per chunk ratio is at " + Form.pc(epx, 2) + " > 100% (total entities " + entityCount + ")");
|
||||
J.sleep(5000);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (cl.flip()) {
|
||||
if(cl.flip()) {
|
||||
try {
|
||||
J.s(() -> precount = getEngine().getWorld().realWorld().getEntities());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
int chunkCooldownSeconds = 60;
|
||||
|
||||
for (Long i : chunkCooldowns.k()) {
|
||||
if (M.ms() - chunkCooldowns.get(i) > TimeUnit.SECONDS.toMillis(chunkCooldownSeconds)) {
|
||||
for(Long i : chunkCooldowns.k()) {
|
||||
if(M.ms() - chunkCooldowns.get(i) > TimeUnit.SECONDS.toMillis(chunkCooldownSeconds)) {
|
||||
chunkCooldowns.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -265,15 +265,15 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
int spawnBuffer = RNG.r.i(2, 12);
|
||||
|
||||
Chunk[] cc = getEngine().getWorld().realWorld().getLoadedChunks();
|
||||
while (spawnBuffer-- > 0) {
|
||||
if (cc.length == 0) {
|
||||
while(spawnBuffer-- > 0) {
|
||||
if(cc.length == 0) {
|
||||
Iris.debug("Can't spawn. No chunks!");
|
||||
return false;
|
||||
}
|
||||
|
||||
Chunk c = cc[RNG.r.nextInt(cc.length)];
|
||||
|
||||
if (!c.isLoaded() || !Chunks.isSafe(c.getWorld(), c.getX(), c.getZ())) {
|
||||
if(!c.isLoaded() || !Chunks.isSafe(c.getWorld(), c.getX(), c.getZ())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -290,55 +290,55 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private void spawnIn(Chunk c, boolean initial) {
|
||||
if (getEngine().isClosed()) {
|
||||
if(getEngine().isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (initial) {
|
||||
if(initial) {
|
||||
energy += 1.2;
|
||||
}
|
||||
|
||||
//@builder
|
||||
IrisBiome biome = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()
|
||||
? getEngine().getSurfaceBiome(c) : null;
|
||||
? getEngine().getSurfaceBiome(c) : null;
|
||||
IrisEntitySpawn v = IrisSettings.get().getWorld().isAnbientEntitySpawningSystem()
|
||||
? spawnRandomly(Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getDimension().getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream()
|
||||
.filter(this::canSpawn)
|
||||
.filter((i) -> i.isValid(biome))
|
||||
.flatMap((i) -> stream(i, initial)),
|
||||
Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap((i) -> stream(i, initial)),
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap((i) -> stream(i, initial))))
|
||||
.collect(Collectors.toList()))
|
||||
.popRandom(RNG.r) : null;
|
||||
? spawnRandomly(Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getDimension().getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream()
|
||||
.filter(this::canSpawn)
|
||||
.filter((i) -> i.isValid(biome))
|
||||
.flatMap((i) -> stream(i, initial)),
|
||||
Stream.concat(getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getRegion(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap((i) -> stream(i, initial)),
|
||||
getData().getSpawnerLoader()
|
||||
.loadAll(getEngine().getSurfaceBiome(c.getX() << 4, c.getZ() << 4).getEntitySpawners())
|
||||
.shuffleCopy(RNG.r).stream().filter(this::canSpawn)
|
||||
.flatMap((i) -> stream(i, initial))))
|
||||
.collect(Collectors.toList()))
|
||||
.popRandom(RNG.r) : null;
|
||||
//@done
|
||||
|
||||
if (IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) {
|
||||
if(IrisSettings.get().getWorld().isMarkerEntitySpawningSystem()) {
|
||||
getSpawnersFromMarkers(c).forEach((block, spawners) -> {
|
||||
if (spawners.isEmpty()) {
|
||||
if(spawners.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisSpawner s = new KList<>(spawners).getRandom();
|
||||
spawn(block, s, false);
|
||||
J.a(() -> getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.INITIAL_SPAWNED_MARKER,
|
||||
() -> spawn(block, s, true)));
|
||||
() -> spawn(block, s, true)));
|
||||
});
|
||||
}
|
||||
|
||||
if (v != null && v.getReferenceSpawner() != null) {
|
||||
if(v != null && v.getReferenceSpawner() != null) {
|
||||
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
|
||||
|
||||
for (Entity i : c.getEntities()) {
|
||||
if (i instanceof LivingEntity) {
|
||||
if (-maxEntCount <= 0) {
|
||||
for(Entity i : c.getEntities()) {
|
||||
if(i instanceof LivingEntity) {
|
||||
if(-maxEntCount <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -346,7 +346,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
try {
|
||||
spawn(c, v);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
J.s(() -> spawn(c, v));
|
||||
}
|
||||
}
|
||||
@@ -355,33 +355,33 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
private void spawn(Chunk c, IrisEntitySpawn i) {
|
||||
boolean allow = true;
|
||||
|
||||
if (!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) {
|
||||
if(!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) {
|
||||
allow = false;
|
||||
IrisEngineChunkData cd = getEngine().getEngineData().getChunk(c.getX(), c.getZ());
|
||||
IrisEngineSpawnerCooldown sc = null;
|
||||
for (IrisEngineSpawnerCooldown j : cd.getCooldowns()) {
|
||||
if (j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) {
|
||||
for(IrisEngineSpawnerCooldown j : cd.getCooldowns()) {
|
||||
if(j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) {
|
||||
sc = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sc == null) {
|
||||
if(sc == null) {
|
||||
sc = new IrisEngineSpawnerCooldown();
|
||||
sc.setSpawner(i.getReferenceSpawner().getLoadKey());
|
||||
cd.getCooldowns().add(sc);
|
||||
}
|
||||
|
||||
if (sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) {
|
||||
if(sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) {
|
||||
sc.spawn(getEngine());
|
||||
allow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (allow) {
|
||||
if(allow) {
|
||||
int s = i.spawn(getEngine(), c, RNG.r);
|
||||
actuallySpawned += s;
|
||||
if (s > 0) {
|
||||
if(s > 0) {
|
||||
getCooldown(i.getReferenceSpawner()).spawn(getEngine());
|
||||
energy -= s * ((i.getEnergyMultiplier() * i.getReferenceSpawner().getEnergyMultiplier() * 1));
|
||||
}
|
||||
@@ -391,33 +391,33 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
private void spawn(IrisPosition c, IrisEntitySpawn i) {
|
||||
boolean allow = true;
|
||||
|
||||
if (!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) {
|
||||
if(!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) {
|
||||
allow = false;
|
||||
IrisEngineChunkData cd = getEngine().getEngineData().getChunk(c.getX() >> 4, c.getZ() >> 4);
|
||||
IrisEngineSpawnerCooldown sc = null;
|
||||
for (IrisEngineSpawnerCooldown j : cd.getCooldowns()) {
|
||||
if (j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) {
|
||||
for(IrisEngineSpawnerCooldown j : cd.getCooldowns()) {
|
||||
if(j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) {
|
||||
sc = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sc == null) {
|
||||
if(sc == null) {
|
||||
sc = new IrisEngineSpawnerCooldown();
|
||||
sc.setSpawner(i.getReferenceSpawner().getLoadKey());
|
||||
cd.getCooldowns().add(sc);
|
||||
}
|
||||
|
||||
if (sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) {
|
||||
if(sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) {
|
||||
sc.spawn(getEngine());
|
||||
allow = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (allow) {
|
||||
if(allow) {
|
||||
int s = i.spawn(getEngine(), c, RNG.r);
|
||||
actuallySpawned += s;
|
||||
if (s > 0) {
|
||||
if(s > 0) {
|
||||
getCooldown(i.getReferenceSpawner()).spawn(getEngine());
|
||||
energy -= s * ((i.getEnergyMultiplier() * i.getReferenceSpawner().getEnergyMultiplier() * 1));
|
||||
}
|
||||
@@ -425,7 +425,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private Stream<IrisEntitySpawn> stream(IrisSpawner s, boolean initial) {
|
||||
for (IrisEntitySpawn i : initial ? s.getInitialSpawns() : s.getSpawns()) {
|
||||
for(IrisEntitySpawn i : initial ? s.getInitialSpawns() : s.getSpawns()) {
|
||||
i.setReferenceSpawner(s);
|
||||
i.setReferenceMarker(s.getReferenceMarker());
|
||||
}
|
||||
@@ -437,11 +437,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
KList<IrisEntitySpawn> rarityTypes = new KList<>();
|
||||
int totalRarity = 0;
|
||||
|
||||
for (IrisEntitySpawn i : types) {
|
||||
for(IrisEntitySpawn i : types) {
|
||||
totalRarity += IRare.get(i);
|
||||
}
|
||||
|
||||
for (IrisEntitySpawn i : types) {
|
||||
for(IrisEntitySpawn i : types) {
|
||||
rarityTypes.addMultiple(i, totalRarity / IRare.get(i));
|
||||
}
|
||||
|
||||
@@ -450,20 +450,20 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
public boolean canSpawn(IrisSpawner i) {
|
||||
return i.isValid(getEngine().getWorld().realWorld())
|
||||
&& getCooldown(i).canSpawn(i.getMaximumRate());
|
||||
&& getCooldown(i).canSpawn(i.getMaximumRate());
|
||||
}
|
||||
|
||||
private IrisEngineSpawnerCooldown getCooldown(IrisSpawner i) {
|
||||
IrisEngineData ed = getEngine().getEngineData();
|
||||
IrisEngineSpawnerCooldown cd = null;
|
||||
|
||||
for (IrisEngineSpawnerCooldown j : ed.getSpawnerCooldowns()) {
|
||||
if (j.getSpawner().equals(i.getLoadKey())) {
|
||||
for(IrisEngineSpawnerCooldown j : ed.getSpawnerCooldowns()) {
|
||||
if(j.getSpawner().equals(i.getLoadKey())) {
|
||||
cd = j;
|
||||
}
|
||||
}
|
||||
|
||||
if (cd == null) {
|
||||
if(cd == null) {
|
||||
cd = new IrisEngineSpawnerCooldown();
|
||||
cd.setSpawner(i.getLoadKey());
|
||||
cd.setLastSpawn(M.ms() - i.getMaximumRate().getInterval());
|
||||
@@ -485,7 +485,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
@Override
|
||||
public void onChunkLoad(Chunk e, boolean generated) {
|
||||
if (getEngine().isClosed()) {
|
||||
if(getEngine().isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -495,16 +495,16 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private void spawn(IrisPosition block, IrisSpawner spawner, boolean initial) {
|
||||
if (getEngine().isClosed()) {
|
||||
if(getEngine().isClosed()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (spawner == null) {
|
||||
if(spawner == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
KList<IrisEntitySpawn> s = initial ? spawner.getInitialSpawns() : spawner.getSpawns();
|
||||
if (s.isEmpty()) {
|
||||
if(s.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
@Override
|
||||
public void teleportAsync(PlayerTeleportEvent e) {
|
||||
if (IrisSettings.get().getWorld().getAsyncTeleport().isEnabled()) {
|
||||
if(IrisSettings.get().getWorld().getAsyncTeleport().isEnabled()) {
|
||||
e.setCancelled(true);
|
||||
warmupAreaAsync(e.getPlayer(), e.getTo(), () -> J.s(() -> {
|
||||
ignoreTP.set(true);
|
||||
@@ -539,21 +539,21 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
J.a(() -> {
|
||||
int viewDistance = IrisSettings.get().getWorld().getAsyncTeleport().getLoadViewDistance();
|
||||
KList<Future<Chunk>> futures = new KList<>();
|
||||
for (int i = -viewDistance; i <= viewDistance; i++) {
|
||||
for (int j = -viewDistance; j <= viewDistance; j++) {
|
||||
for(int i = -viewDistance; i <= viewDistance; i++) {
|
||||
for(int j = -viewDistance; j <= viewDistance; j++) {
|
||||
int finalJ = j;
|
||||
int finalI = i;
|
||||
|
||||
if (to.getWorld().isChunkLoaded((to.getBlockX() >> 4) + i, (to.getBlockZ() >> 4) + j)) {
|
||||
if(to.getWorld().isChunkLoaded((to.getBlockX() >> 4) + i, (to.getBlockZ() >> 4) + j)) {
|
||||
futures.add(CompletableFuture.completedFuture(null));
|
||||
continue;
|
||||
}
|
||||
|
||||
futures.add(MultiBurst.burst.completeValue(()
|
||||
-> PaperLib.getChunkAtAsync(to.getWorld(),
|
||||
(to.getBlockX() >> 4) + finalI,
|
||||
(to.getBlockZ() >> 4) + finalJ,
|
||||
true, IrisSettings.get().getWorld().getAsyncTeleport().isUrgent()).get()));
|
||||
-> PaperLib.getChunkAtAsync(to.getWorld(),
|
||||
(to.getBlockX() >> 4) + finalI,
|
||||
(to.getBlockZ() >> 4) + finalJ,
|
||||
true, IrisSettings.get().getWorld().getAsyncTeleport().isUrgent()).get()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -562,7 +562,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
public void execute(Future<Chunk> chunkFuture) {
|
||||
try {
|
||||
chunkFuture.get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
} catch(InterruptedException | ExecutionException e) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -579,45 +579,45 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
Map<IrisPosition, KSet<IrisSpawner>> p = new KMap<>();
|
||||
Set<IrisPosition> b = new KSet<>();
|
||||
getMantle().iterateChunk(c.getX(), c.getZ(), MatterMarker.class, (x, y, z, t) -> {
|
||||
if (t.getTag().equals("cave_floor") || t.getTag().equals("cave_ceiling")) {
|
||||
if(t.getTag().equals("cave_floor") || t.getTag().equals("cave_ceiling")) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisMarker mark = getData().getMarkerLoader().load(t.getTag());
|
||||
IrisPosition pos = new IrisPosition((c.getX() << 4) + x, y, (c.getZ() << 4) + z);
|
||||
|
||||
if (mark.isEmptyAbove()) {
|
||||
if(mark.isEmptyAbove()) {
|
||||
AtomicBoolean remove = new AtomicBoolean(false);
|
||||
|
||||
try {
|
||||
J.sfut(() -> {
|
||||
if (c.getBlock(x, y + 1, z).getBlockData().getMaterial().isSolid() || c.getBlock(x, y + 2, z).getBlockData().getMaterial().isSolid()) {
|
||||
if(c.getBlock(x, y + 1, z).getBlockData().getMaterial().isSolid() || c.getBlock(x, y + 2, z).getBlockData().getMaterial().isSolid()) {
|
||||
remove.set(true);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException | ExecutionException e) {
|
||||
} catch(InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (remove.get()) {
|
||||
if(remove.get()) {
|
||||
b.add(pos);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (String i : mark.getSpawners()) {
|
||||
for(String i : mark.getSpawners()) {
|
||||
IrisSpawner m = getData().getSpawnerLoader().load(i);
|
||||
m.setReferenceMarker(mark);
|
||||
|
||||
// This is so fucking incorrect its a joke
|
||||
//noinspection ConstantConditions
|
||||
if (m != null) {
|
||||
if(m != null) {
|
||||
p.computeIfAbsent(pos, (k) -> new KSet<>()).add(m);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
for (IrisPosition i : b) {
|
||||
for(IrisPosition i : b) {
|
||||
getEngine().getMantle().getMantle().remove(i.getX(), i.getY(), i.getZ(), MatterMarker.class);
|
||||
}
|
||||
|
||||
@@ -626,19 +626,19 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent e) {
|
||||
if (e.getBlock().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getBlock().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
|
||||
J.a(() -> {
|
||||
MatterMarker marker = getMantle().get(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class);
|
||||
|
||||
if (marker != null) {
|
||||
if (marker.getTag().equals("cave_floor") || marker.getTag().equals("cave_ceiling")) {
|
||||
if(marker != null) {
|
||||
if(marker.getTag().equals("cave_floor") || marker.getTag().equals("cave_ceiling")) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisMarker mark = getData().getMarkerLoader().load(marker.getTag());
|
||||
|
||||
if (mark == null || mark.isRemoveOnChange()) {
|
||||
if(mark == null || mark.isRemoveOnChange()) {
|
||||
getMantle().remove(e.getBlock().getX(), e.getBlock().getY(), e.getBlock().getZ(), MatterMarker.class);
|
||||
}
|
||||
}
|
||||
@@ -648,25 +648,25 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
Runnable drop = () -> J.s(() -> d.forEach((i) -> e.getBlock().getWorld().dropItemNaturally(e.getBlock().getLocation().clone().add(0.5, 0.5, 0.5), i)));
|
||||
IrisBiome b = getEngine().getBiome(e.getBlock().getLocation());
|
||||
|
||||
if (dropItems(e, d, drop, b.getBlockDrops(), b)) {
|
||||
if(dropItems(e, d, drop, b.getBlockDrops(), b)) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisRegion r = getEngine().getRegion(e.getBlock().getLocation());
|
||||
|
||||
if (dropItems(e, d, drop, r.getBlockDrops(), b)) {
|
||||
if(dropItems(e, d, drop, r.getBlockDrops(), b)) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (IrisBlockDrops i : getEngine().getDimension().getBlockDrops()) {
|
||||
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
|
||||
if (i.isReplaceVanillaDrops()) {
|
||||
for(IrisBlockDrops i : getEngine().getDimension().getBlockDrops()) {
|
||||
if(i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
|
||||
if(i.isReplaceVanillaDrops()) {
|
||||
e.setDropItems(false);
|
||||
}
|
||||
|
||||
i.fillDrops(false, d);
|
||||
|
||||
if (i.isSkipParents()) {
|
||||
if(i.isSkipParents()) {
|
||||
drop.run();
|
||||
return;
|
||||
}
|
||||
@@ -676,15 +676,15 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
}
|
||||
|
||||
private boolean dropItems(BlockBreakEvent e, KList<ItemStack> d, Runnable drop, KList<IrisBlockDrops> blockDrops, IrisBiome b) {
|
||||
for (IrisBlockDrops i : blockDrops) {
|
||||
if (i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
|
||||
if (i.isReplaceVanillaDrops()) {
|
||||
for(IrisBlockDrops i : blockDrops) {
|
||||
if(i.shouldDropFor(e.getBlock().getBlockData(), getData())) {
|
||||
if(i.isReplaceVanillaDrops()) {
|
||||
e.setDropItems(false);
|
||||
}
|
||||
|
||||
i.fillDrops(false, d);
|
||||
|
||||
if (i.isSkipParents()) {
|
||||
if(i.isSkipParents()) {
|
||||
drop.run();
|
||||
return true;
|
||||
}
|
||||
@@ -711,7 +711,7 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
|
||||
|
||||
@Override
|
||||
public double getEntitySaturation() {
|
||||
if (!getEngine().getWorld().hasRealWorld()) {
|
||||
if(!getEngine().getWorld().hasRealWorld()) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,16 +45,16 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
||||
@BlockCoordinates
|
||||
private boolean injectBiome(Hunk<Biome> h, int x, int y, int z, Object bb) {
|
||||
try {
|
||||
if (h instanceof BiomeGridHunkView hh) {
|
||||
if(h instanceof BiomeGridHunkView hh) {
|
||||
ChunkGenerator.BiomeGrid g = hh.getChunk();
|
||||
if (g instanceof TerrainChunk) {
|
||||
if(g instanceof TerrainChunk) {
|
||||
((TerrainChunk) g).getBiomeBaseInjector().setBiome(x, y, z, bb);
|
||||
} else {
|
||||
hh.forceBiomeBaseInto(x, y, z, bb);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@@ -67,35 +67,35 @@ public class IrisBiomeActuator extends EngineAssignedActuator<Biome> {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
BurstExecutor burst = burst().burst(multicore);
|
||||
|
||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||
for(int xf = 0; xf < h.getWidth(); xf++) {
|
||||
int finalXf = xf;
|
||||
burst.queue(() -> {
|
||||
IrisBiome ib;
|
||||
for (int zf = 0; zf < h.getDepth(); zf++) {
|
||||
for(int zf = 0; zf < h.getDepth(); zf++) {
|
||||
ib = getComplex().getTrueBiomeStream().get(finalXf + x, zf + z);
|
||||
int maxHeight = (int) (getComplex().getFluidHeight() + ib.getMaxWithObjectHeight(getData()));
|
||||
if (ib.isCustom()) {
|
||||
if(ib.isCustom()) {
|
||||
try {
|
||||
IrisBiomeCustom custom = ib.getCustomBiome(rng, x, 0, z);
|
||||
Object biomeBase = INMS.get().getCustomBiomeBaseFor(getDimension().getLoadKey() + ":" + custom.getId());
|
||||
|
||||
if (biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) {
|
||||
if(biomeBase == null || !injectBiome(h, x, 0, z, biomeBase)) {
|
||||
throw new RuntimeException("Cant inject biome!");
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxHeight; i++) {
|
||||
for(int i = 0; i < maxHeight; i++) {
|
||||
injectBiome(h, finalXf, i, zf, biomeBase);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Biome v = ib.getSkyBiome(rng, x, 0, z);
|
||||
for (int i = 0; i < maxHeight; i++) {
|
||||
for(int i = 0; i < maxHeight; i++) {
|
||||
h.set(finalXf, i, zf, v);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Biome v = ib.getSkyBiome(rng, x, 0, z);
|
||||
for (int i = 0; i < maxHeight; i++) {
|
||||
for(int i = 0; i < maxHeight; i++) {
|
||||
h.set(finalXf, i, zf, v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,21 +67,21 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void onActuate(int x, int z, Hunk<BlockData> output, boolean multicore) {
|
||||
if (!getEngine().getDimension().isDecorate()) {
|
||||
if(!getEngine().getDimension().isDecorate()) {
|
||||
return;
|
||||
}
|
||||
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
BurstExecutor burst = burst().burst(multicore);
|
||||
|
||||
for (int i = 0; i < output.getWidth(); i++) {
|
||||
for(int i = 0; i < output.getWidth(); i++) {
|
||||
int finalI = i;
|
||||
burst.queue(() -> {
|
||||
int height;
|
||||
int realX = Math.round(x + finalI);
|
||||
int realZ;
|
||||
IrisBiome biome, cave;
|
||||
for (int j = 0; j < output.getDepth(); j++) {
|
||||
for(int j = 0; j < output.getDepth(); j++) {
|
||||
boolean solid;
|
||||
int emptyFor = 0;
|
||||
int lastSolid = 0;
|
||||
@@ -90,36 +90,36 @@ public class IrisDecorantActuator extends EngineAssignedActuator<BlockData> {
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
cave = shouldRay ? getComplex().getCaveBiomeStream().get(realX, realZ) : null;
|
||||
|
||||
if (biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
|
||||
if(biome.getDecorators().isEmpty() && (cave == null || cave.getDecorators().isEmpty())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (height < getDimension().getFluidHeight()) {
|
||||
if(height < getDimension().getFluidHeight()) {
|
||||
getSeaSurfaceDecorator().decorate(finalI, j,
|
||||
realX, Math.round(+finalI + 1), Math.round(x + finalI - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, getDimension().getFluidHeight(), getEngine().getHeight());
|
||||
realX, Math.round(+finalI + 1), Math.round(x + finalI - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, getDimension().getFluidHeight(), getEngine().getHeight());
|
||||
getSeaFloorDecorator().decorate(finalI, j,
|
||||
realX, realZ, output, biome, height + 1,
|
||||
getDimension().getFluidHeight() + 1);
|
||||
realX, realZ, output, biome, height + 1,
|
||||
getDimension().getFluidHeight() + 1);
|
||||
}
|
||||
|
||||
if (height == getDimension().getFluidHeight()) {
|
||||
if(height == getDimension().getFluidHeight()) {
|
||||
getShoreLineDecorator().decorate(finalI, j,
|
||||
realX, Math.round(x + finalI + 1), Math.round(x + finalI - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, height, getEngine().getHeight());
|
||||
realX, Math.round(x + finalI + 1), Math.round(x + finalI - 1),
|
||||
realZ, Math.round(z + j + 1), Math.round(z + j - 1),
|
||||
output, biome, height, getEngine().getHeight());
|
||||
}
|
||||
|
||||
getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, biome, height, getEngine().getHeight() - height);
|
||||
|
||||
|
||||
if (cave != null && cave.getDecorators().isNotEmpty()) {
|
||||
for (int k = height; k > 0; k--) {
|
||||
if(cave != null && cave.getDecorators().isNotEmpty()) {
|
||||
for(int k = height; k > 0; k--) {
|
||||
solid = PREDICATE_SOLID.test(output.get(finalI, k, j));
|
||||
|
||||
if (solid) {
|
||||
if (emptyFor > 0) {
|
||||
if(solid) {
|
||||
if(emptyFor > 0) {
|
||||
getSurfaceDecorator().decorate(finalI, j, realX, realZ, output, cave, k, lastSolid);
|
||||
getCeilingDecorator().decorate(finalI, j, realX, realZ, output, cave, lastSolid - 1, emptyFor);
|
||||
emptyFor = 0;
|
||||
|
||||
@@ -21,7 +21,6 @@ package com.volmit.iris.engine.actuator;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedActuator;
|
||||
import com.volmit.iris.engine.object.IrisBiome;
|
||||
import com.volmit.iris.engine.object.IrisDimension;
|
||||
import com.volmit.iris.engine.object.IrisRegion;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
@@ -54,7 +53,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
BurstExecutor e = burst().burst(multicore);
|
||||
for (int xf = 0; xf < h.getWidth(); xf++) {
|
||||
for(int xf = 0; xf < h.getWidth(); xf++) {
|
||||
int finalXf = xf;
|
||||
e.queue(() -> terrainSliver(x, z, finalXf, h));
|
||||
}
|
||||
@@ -71,10 +70,14 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
/**
|
||||
* This is calling 1/16th of a chunk x/z slice. It is a plane from sky to bedrock 1 thick in the x direction.
|
||||
*
|
||||
* @param x the chunk x in blocks
|
||||
* @param z the chunk z in blocks
|
||||
* @param xf the current x slice
|
||||
* @param h the blockdata
|
||||
* @param x
|
||||
* the chunk x in blocks
|
||||
* @param z
|
||||
* the chunk z in blocks
|
||||
* @param xf
|
||||
* the current x slice
|
||||
* @param h
|
||||
* the blockdata
|
||||
*/
|
||||
@BlockCoordinates
|
||||
public void terrainSliver(int x, int z, int xf, Hunk<BlockData> h) {
|
||||
@@ -83,7 +86,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
IrisBiome biome;
|
||||
IrisRegion region;
|
||||
|
||||
for (zf = 0; zf < h.getDepth(); zf++) {
|
||||
for(zf = 0; zf < h.getDepth(); zf++) {
|
||||
realX = xf + x;
|
||||
realZ = zf + z;
|
||||
biome = getComplex().getTrueBiomeStream().get(realX, realZ);
|
||||
@@ -92,7 +95,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
hf = Math.round(Math.max(Math.min(h.getHeight(), getDimension().getFluidHeight()), he));
|
||||
|
||||
// this 0 is where we are going to need to modify the world base height, the Zero, not this instance...
|
||||
if (hf < 0) {
|
||||
if(hf < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -101,28 +104,28 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
int depth, fdepth;
|
||||
|
||||
// Fluid height and lower
|
||||
for (int i = hf; i >= 0; i--) {
|
||||
if (i >= h.getHeight()) { // h.getheight is terrain height
|
||||
for(int i = hf; i >= 0; i--) {
|
||||
if(i >= h.getHeight()) { // h.getheight is terrain height
|
||||
continue;
|
||||
}
|
||||
|
||||
// will need to change
|
||||
if (i == 0) {
|
||||
if (getDimension().isBedrock()) {
|
||||
if(i == 0) {
|
||||
if(getDimension().isBedrock()) {
|
||||
h.set(xf, i, zf, BEDROCK);
|
||||
lastBedrock = i;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if (i > he && i <= hf) {
|
||||
if(i > he && i <= hf) {
|
||||
fdepth = hf - i;
|
||||
|
||||
if (fblocks == null) {
|
||||
if(fblocks == null) {
|
||||
fblocks = biome.generateSeaLayers(realX, realZ, rng, hf - he, getData());
|
||||
}
|
||||
|
||||
if (fblocks.hasIndex(fdepth)) {
|
||||
if(fblocks.hasIndex(fdepth)) {
|
||||
h.set(xf, i, zf, fblocks.get(fdepth));
|
||||
continue;
|
||||
}
|
||||
@@ -132,18 +135,18 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
}
|
||||
|
||||
// top of surface
|
||||
if (i <= he) {
|
||||
if(i <= he) {
|
||||
depth = he - i;
|
||||
if (blocks == null) {
|
||||
if(blocks == null) {
|
||||
blocks = biome.generateLayers(getDimension(), realX, realZ, rng,
|
||||
he,
|
||||
he,
|
||||
getData(),
|
||||
getComplex());
|
||||
he,
|
||||
he,
|
||||
getData(),
|
||||
getComplex());
|
||||
}
|
||||
|
||||
|
||||
if (blocks.hasIndex(depth)) {
|
||||
if(blocks.hasIndex(depth)) {
|
||||
h.set(xf, i, zf, blocks.get(depth));
|
||||
continue;
|
||||
}
|
||||
@@ -152,7 +155,7 @@ public class IrisTerrainNormalActuator extends EngineAssignedActuator<BlockData>
|
||||
ore = ore == null ? region.generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||
ore = ore == null ? getDimension().generateOres(realX, i, realZ, rng, getData()) : ore;
|
||||
|
||||
if (ore != null) {
|
||||
if(ore != null) {
|
||||
h.set(xf, i, zf, ore);
|
||||
} else {
|
||||
h.set(xf, i, zf, getComplex().getRockStream().get(realX, realZ));
|
||||
|
||||
@@ -46,7 +46,7 @@ public class AtomicCache<T> {
|
||||
public void reset() {
|
||||
t.set(null);
|
||||
|
||||
if (nullSupport) {
|
||||
if(nullSupport) {
|
||||
set.set(false);
|
||||
}
|
||||
}
|
||||
@@ -55,7 +55,7 @@ public class AtomicCache<T> {
|
||||
return aquire(() -> {
|
||||
try {
|
||||
return t.get();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@@ -65,7 +65,7 @@ public class AtomicCache<T> {
|
||||
return aquire(() -> {
|
||||
try {
|
||||
return t.get();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
@@ -73,18 +73,18 @@ public class AtomicCache<T> {
|
||||
}
|
||||
|
||||
public T aquire(Supplier<T> t) {
|
||||
if (this.t.get() != null) {
|
||||
if(this.t.get() != null) {
|
||||
return this.t.get();
|
||||
} else if (nullSupport && set.get()) {
|
||||
} else if(nullSupport && set.get()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
lock.lock();
|
||||
|
||||
if (this.t.get() != null) {
|
||||
if(this.t.get() != null) {
|
||||
lock.unlock();
|
||||
return this.t.get();
|
||||
} else if (nullSupport && set.get()) {
|
||||
} else if(nullSupport && set.get()) {
|
||||
lock.unlock();
|
||||
return null;
|
||||
}
|
||||
@@ -92,10 +92,10 @@ public class AtomicCache<T> {
|
||||
try {
|
||||
this.t.set(t.get());
|
||||
|
||||
if (nullSupport) {
|
||||
if(nullSupport) {
|
||||
set.set(true);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.error("Atomic cache failure!");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public interface Cache<V> {
|
||||
idx -= (z * w * h);
|
||||
final int y = idx / w;
|
||||
final int x = idx % w;
|
||||
return new int[]{x, y, z};
|
||||
return new int[] {x, y, z};
|
||||
}
|
||||
|
||||
int getId();
|
||||
|
||||
@@ -56,7 +56,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
||||
@Override
|
||||
public BiomeBaseInjector getBiomeBaseInjector() {
|
||||
|
||||
if (unsafe) {
|
||||
if(unsafe) {
|
||||
return (a, b, c, d) -> {
|
||||
};
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int z) {
|
||||
if (storage != null) {
|
||||
if(storage != null) {
|
||||
return storage.getBiome(x, z);
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
||||
|
||||
@Override
|
||||
public Biome getBiome(int x, int y, int z) {
|
||||
if (storage != null) {
|
||||
if(storage != null) {
|
||||
return storage.getBiome(x, y, z);
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int z, Biome bio) {
|
||||
if (storage != null) {
|
||||
if(storage != null) {
|
||||
storage.setBiome(x, z, bio);
|
||||
return;
|
||||
}
|
||||
@@ -100,7 +100,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
||||
|
||||
@Override
|
||||
public void setBiome(int x, int y, int z, Biome bio) {
|
||||
if (storage != null) {
|
||||
if(storage != null) {
|
||||
storage.setBiome(x, y, z, bio);
|
||||
return;
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
|
||||
|
||||
@Override
|
||||
public void inject(BiomeGrid biome) {
|
||||
if (biome3D != null) {
|
||||
if(biome3D != null) {
|
||||
biome3D.inject(biome);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,11 +81,11 @@ public class MCATerrainChunk implements TerrainChunk {
|
||||
int xx = (x + ox) & 15;
|
||||
int zz = (z + oz) & 15;
|
||||
|
||||
if (y > 255 || y < 0) {
|
||||
if(y > 255 || y < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (blockData == null) {
|
||||
if(blockData == null) {
|
||||
Iris.error("NULL BD");
|
||||
}
|
||||
|
||||
@@ -94,11 +94,11 @@ public class MCATerrainChunk implements TerrainChunk {
|
||||
|
||||
@Override
|
||||
public org.bukkit.block.data.BlockData getBlockData(int x, int y, int z) {
|
||||
if (y > getMaxHeight()) {
|
||||
if(y > getMaxHeight()) {
|
||||
y = getMaxHeight();
|
||||
}
|
||||
|
||||
if (y < 0) {
|
||||
if(y < 0) {
|
||||
y = 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,10 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
|
||||
/**
|
||||
* Get biome at x, z within chunk being generated
|
||||
*
|
||||
* @param x - 0-15
|
||||
* @param z - 0-15
|
||||
* @param x
|
||||
* - 0-15
|
||||
* @param z
|
||||
* - 0-15
|
||||
* @return Biome value
|
||||
* @deprecated biomes are now 3-dimensional
|
||||
*/
|
||||
@@ -61,9 +63,12 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
|
||||
/**
|
||||
* Get biome at x, z within chunk being generated
|
||||
*
|
||||
* @param x - 0-15
|
||||
* @param y - 0-255
|
||||
* @param z - 0-15
|
||||
* @param x
|
||||
* - 0-15
|
||||
* @param y
|
||||
* - 0-255
|
||||
* @param z
|
||||
* - 0-15
|
||||
* @return Biome value
|
||||
*/
|
||||
Biome getBiome(int x, int y, int z);
|
||||
@@ -71,9 +76,12 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
|
||||
/**
|
||||
* Set biome at x, z within chunk being generated
|
||||
*
|
||||
* @param x - 0-15
|
||||
* @param z - 0-15
|
||||
* @param bio - Biome value
|
||||
* @param x
|
||||
* - 0-15
|
||||
* @param z
|
||||
* - 0-15
|
||||
* @param bio
|
||||
* - Biome value
|
||||
* @deprecated biomes are now 3-dimensional
|
||||
*/
|
||||
@Deprecated
|
||||
@@ -82,10 +90,14 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
|
||||
/**
|
||||
* Set biome at x, z within chunk being generated
|
||||
*
|
||||
* @param x - 0-15
|
||||
* @param y - 0-255
|
||||
* @param z - 0-15
|
||||
* @param bio - Biome value
|
||||
* @param x
|
||||
* - 0-15
|
||||
* @param y
|
||||
* - 0-255
|
||||
* @param z
|
||||
* - 0-15
|
||||
* @param bio
|
||||
* - Biome value
|
||||
*/
|
||||
void setBiome(int x, int y, int z, Biome bio);
|
||||
|
||||
@@ -103,11 +115,15 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
|
||||
* <p>
|
||||
* Setting blocks outside the chunk's bounds does nothing.
|
||||
*
|
||||
* @param x the x location in the chunk from 0-15 inclusive
|
||||
* @param y the y location in the chunk from 0 (inclusive) - maxHeight
|
||||
* (exclusive)
|
||||
* @param z the z location in the chunk from 0-15 inclusive
|
||||
* @param blockData the type to set the block to
|
||||
* @param x
|
||||
* the x location in the chunk from 0-15 inclusive
|
||||
* @param y
|
||||
* the y location in the chunk from 0 (inclusive) - maxHeight
|
||||
* (exclusive)
|
||||
* @param z
|
||||
* the z location in the chunk from 0-15 inclusive
|
||||
* @param blockData
|
||||
* the type to set the block to
|
||||
*/
|
||||
void setBlock(int x, int y, int z, BlockData blockData);
|
||||
|
||||
@@ -116,10 +132,13 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
|
||||
* <p>
|
||||
* Getting blocks outside the chunk's bounds returns air.
|
||||
*
|
||||
* @param x the x location in the chunk from 0-15 inclusive
|
||||
* @param y the y location in the chunk from 0 (inclusive) - maxHeight
|
||||
* (exclusive)
|
||||
* @param z the z location in the chunk from 0-15 inclusive
|
||||
* @param x
|
||||
* the x location in the chunk from 0-15 inclusive
|
||||
* @param y
|
||||
* the y location in the chunk from 0 (inclusive) - maxHeight
|
||||
* (exclusive)
|
||||
* @param z
|
||||
* the z location in the chunk from 0-15 inclusive
|
||||
* @return the data of the block or the BlockData for air if x, y or z are
|
||||
* outside the chunk's bounds
|
||||
*/
|
||||
|
||||
@@ -31,7 +31,7 @@ public interface Deserializer<T> {
|
||||
T fromStream(InputStream stream) throws IOException;
|
||||
|
||||
default T fromFile(File file) throws IOException {
|
||||
try (BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
|
||||
try(BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file))) {
|
||||
return fromStream(bis);
|
||||
}
|
||||
}
|
||||
@@ -42,8 +42,8 @@ public interface Deserializer<T> {
|
||||
}
|
||||
|
||||
default T fromResource(Class<?> clazz, String path) throws IOException {
|
||||
try (InputStream stream = clazz.getClassLoader().getResourceAsStream(path)) {
|
||||
if (stream == null) {
|
||||
try(InputStream stream = clazz.getClassLoader().getResourceAsStream(path)) {
|
||||
if(stream == null) {
|
||||
throw new IOException("resource \"" + path + "\" not found");
|
||||
}
|
||||
return fromStream(stream);
|
||||
@@ -51,7 +51,7 @@ public interface Deserializer<T> {
|
||||
}
|
||||
|
||||
default T fromURL(URL url) throws IOException {
|
||||
try (InputStream stream = url.openStream()) {
|
||||
try(InputStream stream = url.openStream()) {
|
||||
return fromStream(stream);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ package com.volmit.iris.engine.data.io;
|
||||
public interface MaxDepthIO {
|
||||
|
||||
default int decrementMaxDepth(int maxDepth) {
|
||||
if (maxDepth < 0) {
|
||||
if(maxDepth < 0) {
|
||||
throw new IllegalArgumentException("negative maximum depth is not allowed");
|
||||
} else if (maxDepth == 0) {
|
||||
} else if(maxDepth == 0) {
|
||||
throw new MaxDepthReachedException("reached maximum depth of NBT structure");
|
||||
}
|
||||
return --maxDepth;
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface Serializer<T> {
|
||||
void toStream(T object, OutputStream out) throws IOException;
|
||||
|
||||
default void toFile(T object, File file) throws IOException {
|
||||
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
try(BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
|
||||
toStream(object, bos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ public interface StringDeserializer<T> extends Deserializer<T> {
|
||||
|
||||
@Override
|
||||
default T fromStream(InputStream stream) throws IOException {
|
||||
try (Reader reader = new InputStreamReader(stream)) {
|
||||
try(Reader reader = new InputStreamReader(stream)) {
|
||||
return fromReader(reader);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
default T fromFile(File file) throws IOException {
|
||||
try (Reader reader = new FileReader(file)) {
|
||||
try(Reader reader = new FileReader(file)) {
|
||||
return fromReader(reader);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ public interface StringSerializer<T> extends Serializer<T> {
|
||||
|
||||
@Override
|
||||
default void toFile(T object, File file) throws IOException {
|
||||
try (Writer writer = new FileWriter(file)) {
|
||||
try(Writer writer = new FileWriter(file)) {
|
||||
toWriter(object, writer);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,49 +40,49 @@ public class IrisCeilingDecorator extends IrisEngineDecorator {
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
if(decorator != null) {
|
||||
if(!decorator.isStacking()) {
|
||||
if(height >= 0 || height < getEngine().getHeight()) {
|
||||
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
|
||||
}
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
if (decorator.isScaleStack()) {
|
||||
if(decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
|
||||
} else {
|
||||
stack = Math.min(max, stack);
|
||||
}
|
||||
|
||||
if (stack == 1) {
|
||||
if(stack == 1) {
|
||||
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
for(int i = 0; i < stack; i++) {
|
||||
int h = height - i;
|
||||
if (h < getEngine().getMinHeight()) {
|
||||
if(h < getEngine().getMinHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double threshold = (((double) i) / (double) (stack - 1));
|
||||
|
||||
BlockData bd = threshold >= decorator.getTopThreshold() ?
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData());
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData());
|
||||
|
||||
if (bd instanceof PointedDripstone) {
|
||||
if(bd instanceof PointedDripstone) {
|
||||
PointedDripstone.Thickness th = PointedDripstone.Thickness.BASE;
|
||||
|
||||
if (stack == 2) {
|
||||
if(stack == 2) {
|
||||
th = PointedDripstone.Thickness.FRUSTUM;
|
||||
|
||||
if (i == stack - 1) {
|
||||
if(i == stack - 1) {
|
||||
th = PointedDripstone.Thickness.TIP;
|
||||
}
|
||||
} else {
|
||||
if (i == stack - 1) {
|
||||
if(i == stack - 1) {
|
||||
th = PointedDripstone.Thickness.TIP;
|
||||
} else if (i == stack - 2) {
|
||||
} else if(i == stack - 2) {
|
||||
th = PointedDripstone.Thickness.FRUSTUM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,18 +48,18 @@ public abstract class IrisEngineDecorator extends EngineAssignedComponent implem
|
||||
KList<IrisDecorator> v = new KList<>();
|
||||
RNG rng = new RNG(Cache.key((int) realX, (int) realZ));
|
||||
|
||||
for (IrisDecorator i : biome.getDecorators()) {
|
||||
for(IrisDecorator i : biome.getDecorators()) {
|
||||
try {
|
||||
if (i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null) {
|
||||
if(i.getPartOf().equals(part) && i.getBlockData(biome, this.rng, realX, realZ, getData()) != null) {
|
||||
v.add(i);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("PART OF: " + biome.getLoadFile().getAbsolutePath() + " HAS AN INVALID DECORATOR near 'partOf'!!!");
|
||||
}
|
||||
}
|
||||
|
||||
if (v.isNotEmpty()) {
|
||||
if(v.isNotEmpty()) {
|
||||
return v.get(rng.nextInt(v.size()));
|
||||
}
|
||||
|
||||
|
||||
@@ -37,33 +37,33 @@ public class IrisSeaFloorDecorator extends IrisEngineDecorator {
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
if(decorator != null) {
|
||||
if(!decorator.isStacking()) {
|
||||
if(height >= 0 || height < getEngine().getHeight()) {
|
||||
data.set(x, height, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
|
||||
}
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
if (decorator.isScaleStack()) {
|
||||
if(decorator.isScaleStack()) {
|
||||
int maxStack = max - height;
|
||||
stack = (int) Math.ceil((double) maxStack * ((double) stack / 100));
|
||||
} else stack = Math.min(stack, max - height);
|
||||
|
||||
if (stack == 1) {
|
||||
if(stack == 1) {
|
||||
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
for(int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
if (h > max || h > getEngine().getHeight()) {
|
||||
if(h > max || h > getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, h, z, threshold >= decorator.getTopThreshold() ?
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()));
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,33 +37,33 @@ public class IrisSeaSurfaceDecorator extends IrisEngineDecorator {
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if (height >= 0 || height < getEngine().getHeight()) {
|
||||
if(decorator != null) {
|
||||
if(!decorator.isStacking()) {
|
||||
if(height >= 0 || height < getEngine().getHeight()) {
|
||||
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
|
||||
}
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
if (decorator.isScaleStack()) {
|
||||
if(decorator.isScaleStack()) {
|
||||
int maxStack = max - height;
|
||||
stack = (int) Math.ceil((double) maxStack * ((double) stack / 100));
|
||||
}
|
||||
|
||||
if (stack == 1) {
|
||||
if(stack == 1) {
|
||||
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
for(int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
if (h >= max || h >= getEngine().getHeight()) {
|
||||
if(h >= max || h >= getEngine().getHeight()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ?
|
||||
decorator.getBlockDataForTop(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()));
|
||||
decorator.getBlockDataForTop(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng().nextParallelRNG(i), realX, h, realZ, getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,35 +36,35 @@ public class IrisShoreLineDecorator extends IrisEngineDecorator {
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
|
||||
if (height == getDimension().getFluidHeight()) {
|
||||
if (Math.round(getComplex().getHeightStream().get(realX1, realZ)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX_1, realZ)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX, realZ1)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight()
|
||||
if(height == getDimension().getFluidHeight()) {
|
||||
if(Math.round(getComplex().getHeightStream().get(realX1, realZ)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX_1, realZ)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX, realZ1)) < getComplex().getFluidHeight() ||
|
||||
Math.round(getComplex().getHeightStream().get(realX, realZ_1)) < getComplex().getFluidHeight()
|
||||
) {
|
||||
IrisDecorator decorator = getDecorator(biome, realX, realZ);
|
||||
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if(decorator != null) {
|
||||
if(!decorator.isStacking()) {
|
||||
data.set(x, height + 1, z, decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData()));
|
||||
} else {
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
if (decorator.isScaleStack()) {
|
||||
if(decorator.isScaleStack()) {
|
||||
int maxStack = max - height;
|
||||
stack = (int) Math.ceil((double) maxStack * ((double) stack / 100));
|
||||
} else stack = Math.min(max - height, stack);
|
||||
|
||||
if (stack == 1) {
|
||||
if(stack == 1) {
|
||||
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
for(int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
data.set(x, h + 1, z, threshold >= decorator.getTopThreshold() ?
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()));
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
public void decorate(int x, int z, int realX, int realX1, int realX_1, int realZ, int realZ1, int realZ_1, Hunk<BlockData> data, IrisBiome biome, int height, int max) {
|
||||
if (biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight()) {
|
||||
if(biome.getInferredType().equals(InferredType.SHORE) && height < getDimension().getFluidHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -50,22 +50,22 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
bdx = data.get(x, height, z);
|
||||
boolean underwater = height < getDimension().getFluidHeight();
|
||||
|
||||
if (decorator != null) {
|
||||
if (!decorator.isStacking()) {
|
||||
if(decorator != null) {
|
||||
if(!decorator.isStacking()) {
|
||||
bd = decorator.getBlockData100(biome, getRng(), realX, height, realZ, getData());
|
||||
|
||||
if (!underwater) {
|
||||
if (!canGoOn(bd, bdx)) {
|
||||
if(!underwater) {
|
||||
if(!canGoOn(bd, bdx)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (bd instanceof Bisected) {
|
||||
if(bd instanceof Bisected) {
|
||||
bd = bd.clone();
|
||||
((Bisected) bd).setHalf(Bisected.Half.TOP);
|
||||
try {
|
||||
data.set(x, height + 2, z, bd);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
bd = bd.clone();
|
||||
@@ -75,55 +75,55 @@ public class IrisSurfaceDecorator extends IrisEngineDecorator {
|
||||
data.set(x, height + 1, z, bd);
|
||||
|
||||
} else {
|
||||
if (height < getDimension().getFluidHeight()) {
|
||||
if(height < getDimension().getFluidHeight()) {
|
||||
max = getDimension().getFluidHeight();
|
||||
}
|
||||
|
||||
int stack = decorator.getHeight(getRng().nextParallelRNG(Cache.key(realX, realZ)), realX, realZ, getData());
|
||||
|
||||
if (decorator.isScaleStack()) {
|
||||
if(decorator.isScaleStack()) {
|
||||
stack = Math.min((int) Math.ceil((double) max * ((double) stack / 100)), decorator.getAbsoluteMaxStack());
|
||||
} else {
|
||||
stack = Math.min(max, stack);
|
||||
}
|
||||
|
||||
if (stack == 1) {
|
||||
if(stack == 1) {
|
||||
data.set(x, height, z, decorator.getBlockDataForTop(biome, getRng(), realX, height, realZ, getData()));
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < stack; i++) {
|
||||
for(int i = 0; i < stack; i++) {
|
||||
int h = height + i;
|
||||
double threshold = ((double) i) / (stack - 1);
|
||||
bd = threshold >= decorator.getTopThreshold() ?
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData());
|
||||
decorator.getBlockDataForTop(biome, getRng(), realX, h, realZ, getData()) :
|
||||
decorator.getBlockData100(biome, getRng(), realX, h, realZ, getData());
|
||||
|
||||
if (bd == null) {
|
||||
if(bd == null) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (i == 0 && !underwater && !canGoOn(bd, bdx)) {
|
||||
if(i == 0 && !underwater && !canGoOn(bd, bdx)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (underwater && height + 1 + i > getDimension().getFluidHeight()) {
|
||||
if(underwater && height + 1 + i > getDimension().getFluidHeight()) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (bd instanceof PointedDripstone) {
|
||||
if(bd instanceof PointedDripstone) {
|
||||
PointedDripstone.Thickness th = PointedDripstone.Thickness.BASE;
|
||||
|
||||
if (stack == 2) {
|
||||
if(stack == 2) {
|
||||
th = PointedDripstone.Thickness.FRUSTUM;
|
||||
|
||||
if (i == stack - 1) {
|
||||
if(i == stack - 1) {
|
||||
th = PointedDripstone.Thickness.TIP;
|
||||
}
|
||||
} else {
|
||||
if (i == stack - 1) {
|
||||
if(i == stack - 1) {
|
||||
th = PointedDripstone.Thickness.TIP;
|
||||
} else if (i == stack - 2) {
|
||||
} else if(i == stack - 2) {
|
||||
th = PointedDripstone.Thickness.FRUSTUM;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -145,7 +145,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
@BlockCoordinates
|
||||
default void generate(int x, int z, TerrainChunk tc, boolean multicore) throws WrongEngineBroException {
|
||||
generate(x, z, Hunk.view((ChunkGenerator.ChunkData) tc), Hunk.view((ChunkGenerator.BiomeGrid) tc, tc.getMinHeight(), tc.getMaxHeight()), multicore);
|
||||
generate(x, z, Hunk.view(tc), Hunk.view(tc, tc.getMinHeight(), tc.getMaxHeight()), multicore);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
@@ -210,10 +210,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
default IrisBiome getCaveOrMantleBiome(int x, int y, int z) {
|
||||
MatterCavern m = getMantle().getMantle().get(x, y, z, MatterCavern.class);
|
||||
|
||||
if (m != null && m.getCustomBiome() != null && !m.getCustomBiome().isEmpty()) {
|
||||
if(m != null && m.getCustomBiome() != null && !m.getCustomBiome().isEmpty()) {
|
||||
IrisBiome biome = getData().getBiomeLoader().load(m.getCustomBiome());
|
||||
|
||||
if (biome != null) {
|
||||
if(biome != null) {
|
||||
return biome;
|
||||
}
|
||||
}
|
||||
@@ -250,11 +250,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
@BlockCoordinates
|
||||
@Override
|
||||
default void catchBlockUpdates(int x, int y, int z, BlockData data) {
|
||||
if (data == null) {
|
||||
if(data == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (B.isUpdatable(data)) {
|
||||
if(B.isUpdatable(data)) {
|
||||
getMantle().updateBlock(x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -269,38 +269,38 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
@ChunkCoordinates
|
||||
@Override
|
||||
default void updateChunk(Chunk c) {
|
||||
if (c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() + 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX(), c.getZ() + 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ())
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() - 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX(), c.getZ() - 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ())
|
||||
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) {
|
||||
if(c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() + 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX(), c.getZ() + 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ())
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() - 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX(), c.getZ() - 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ())
|
||||
&& c.getWorld().isChunkLoaded(c.getX() + 1, c.getZ() - 1)
|
||||
&& c.getWorld().isChunkLoaded(c.getX() - 1, c.getZ() + 1) && getMantle().getMantle().isLoaded(c)) {
|
||||
getMantle().getMantle().raiseFlag(c.getX(), c.getZ(), MantleFlag.UPDATE, () -> J.s(() -> {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
KMap<Long, Integer> updates = new KMap<>();
|
||||
RNG r = new RNG(Cache.key(c.getX(), c.getZ()));
|
||||
getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, v) -> {
|
||||
if (!B.isFluid(c.getBlock(x & 15, y, z & 15).getBlockData())) {
|
||||
if(!B.isFluid(c.getBlock(x & 15, y, z & 15).getBlockData())) {
|
||||
return;
|
||||
}
|
||||
boolean u = false;
|
||||
if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData())) {
|
||||
if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.DOWN).getBlockData())) {
|
||||
u = true;
|
||||
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData())) {
|
||||
} else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.WEST).getBlockData())) {
|
||||
u = true;
|
||||
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData())) {
|
||||
} else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.EAST).getBlockData())) {
|
||||
u = true;
|
||||
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData())) {
|
||||
} else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.SOUTH).getBlockData())) {
|
||||
u = true;
|
||||
} else if (B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData())) {
|
||||
} else if(B.isAir(c.getBlock(x & 15, y, z & 15).getRelative(BlockFace.NORTH).getBlockData())) {
|
||||
u = true;
|
||||
}
|
||||
|
||||
if (u) {
|
||||
if(u) {
|
||||
updates.compute(Cache.key(x & 15, z & 15), (k, vv) -> {
|
||||
if (vv != null) {
|
||||
if(vv != null) {
|
||||
return Math.max(vv, y);
|
||||
}
|
||||
|
||||
@@ -311,11 +311,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
updates.forEach((k, v) -> update(Cache.keyX(k), v, Cache.keyZ(k), c, r));
|
||||
getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterUpdate.class, (x, y, z, v) -> {
|
||||
if (v != null && v.isUpdate()) {
|
||||
if(v != null && v.isUpdate()) {
|
||||
int vx = x & 15;
|
||||
int vz = z & 15;
|
||||
update(x, y, z, c, new RNG(Cache.key(c.getX(), c.getZ())));
|
||||
if (vx > 0 && vx < 15 && vz > 0 && vz < 15) {
|
||||
if(vx > 0 && vx < 15 && vz > 0 && vz < 15) {
|
||||
updateLighting(x, y, z, c);
|
||||
}
|
||||
}
|
||||
@@ -331,11 +331,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
Block block = c.getBlock(x, y, z);
|
||||
BlockData data = block.getBlockData();
|
||||
|
||||
if (B.isLit(data)) {
|
||||
if(B.isLit(data)) {
|
||||
try {
|
||||
block.setType(Material.AIR, false);
|
||||
block.setBlockData(data, true);
|
||||
} catch (Exception e) {
|
||||
} catch(Exception e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
@@ -347,21 +347,21 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
Block block = c.getBlock(x, y, z);
|
||||
BlockData data = block.getBlockData();
|
||||
blockUpdatedMetric();
|
||||
if (B.isStorage(data)) {
|
||||
if(B.isStorage(data)) {
|
||||
RNG rx = rf.nextParallelRNG(BlockPosition.toLong(x, y, z));
|
||||
InventorySlotType slot = null;
|
||||
|
||||
if (B.isStorageChest(data)) {
|
||||
if(B.isStorageChest(data)) {
|
||||
slot = InventorySlotType.STORAGE;
|
||||
}
|
||||
|
||||
if (slot != null) {
|
||||
if(slot != null) {
|
||||
KList<IrisLootTable> tables = getLootTables(rx, block);
|
||||
|
||||
try {
|
||||
InventoryHolder m = (InventoryHolder) block.getState();
|
||||
addItems(false, m.getInventory(), rx, tables, slot, x, y, z, 15);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
}
|
||||
@@ -379,12 +379,12 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
boolean packedFull = false;
|
||||
|
||||
splitting:
|
||||
for (int i = 0; i < nitems.length; i++) {
|
||||
for(int i = 0; i < nitems.length; i++) {
|
||||
ItemStack is = nitems[i];
|
||||
|
||||
if (is != null && is.getAmount() > 1 && !packedFull) {
|
||||
for (int j = 0; j < nitems.length; j++) {
|
||||
if (nitems[j] == null) {
|
||||
if(is != null && is.getAmount() > 1 && !packedFull) {
|
||||
for(int j = 0; j < nitems.length; j++) {
|
||||
if(nitems[j] == null) {
|
||||
int take = rng.nextInt(is.getAmount());
|
||||
take = take == 0 ? 1 : take;
|
||||
is.setAmount(is.getAmount() - take);
|
||||
@@ -398,11 +398,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
for(int i = 0; i < 4; i++) {
|
||||
try {
|
||||
Arrays.parallelSort(nitems, (a, b) -> rng.nextInt());
|
||||
break;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -413,7 +413,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
@Override
|
||||
default void injectTables(KList<IrisLootTable> list, IrisLootReference r) {
|
||||
if (r.getMode().equals(IrisLootMode.CLEAR) || r.getMode().equals(IrisLootMode.REPLACE)) {
|
||||
if(r.getMode().equals(IrisLootMode.CLEAR) || r.getMode().equals(IrisLootMode.REPLACE)) {
|
||||
list.clear();
|
||||
}
|
||||
|
||||
@@ -427,11 +427,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
int rz = b.getZ();
|
||||
double he = getComplex().getHeightStream().get(rx, rz);
|
||||
PlacedObject po = getObjectPlacement(rx, b.getY(), rz);
|
||||
if (po != null && po.getPlacement() != null) {
|
||||
if(po != null && po.getPlacement() != null) {
|
||||
|
||||
if (B.isStorageChest(b.getBlockData())) {
|
||||
if(B.isStorageChest(b.getBlockData())) {
|
||||
IrisLootTable table = po.getPlacement().getTable(b.getBlockData(), getData());
|
||||
if (table != null) {
|
||||
if(table != null) {
|
||||
return new KList<>(table);
|
||||
}
|
||||
}
|
||||
@@ -446,14 +446,14 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
injectTables(tables, biomeSurface.getLoot());
|
||||
injectTables(tables, biomeUnder.getLoot());
|
||||
|
||||
if (tables.isNotEmpty()) {
|
||||
if(tables.isNotEmpty()) {
|
||||
int target = (int) Math.round(tables.size() * multiplier);
|
||||
|
||||
while (tables.size() < target && tables.isNotEmpty()) {
|
||||
while(tables.size() < target && tables.isNotEmpty()) {
|
||||
tables.add(tables.get(rng.i(tables.size() - 1)));
|
||||
}
|
||||
|
||||
while (tables.size() > target && tables.isNotEmpty()) {
|
||||
while(tables.size() > target && tables.isNotEmpty()) {
|
||||
tables.remove(rng.i(tables.size() - 1));
|
||||
}
|
||||
}
|
||||
@@ -466,29 +466,29 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
KList<ItemStack> items = new KList<>();
|
||||
|
||||
int b = 4;
|
||||
for (IrisLootTable i : tables) {
|
||||
for(IrisLootTable i : tables) {
|
||||
b++;
|
||||
items.addAll(i.getLoot(debug, items.isEmpty(), rng, slot, x, y, z, b + b, mgf + b));
|
||||
}
|
||||
|
||||
if (PaperLib.isPaper() && getWorld().hasRealWorld()) {
|
||||
if(PaperLib.isPaper() && getWorld().hasRealWorld()) {
|
||||
PaperLib.getChunkAtAsync(getWorld().realWorld(), x >> 4, z >> 4).thenAccept((c) -> {
|
||||
Runnable r = () -> {
|
||||
for (ItemStack i : items) {
|
||||
for(ItemStack i : items) {
|
||||
inv.addItem(i);
|
||||
}
|
||||
|
||||
scramble(inv, rng);
|
||||
};
|
||||
|
||||
if (Bukkit.isPrimaryThread()) {
|
||||
if(Bukkit.isPrimaryThread()) {
|
||||
r.run();
|
||||
} else {
|
||||
J.s(r);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
for (ItemStack i : items) {
|
||||
for(ItemStack i : items) {
|
||||
inv.addItem(i);
|
||||
}
|
||||
|
||||
@@ -548,17 +548,17 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
AtomicReference<IrisPosition> r = new AtomicReference<>();
|
||||
BurstExecutor b = burst().burst();
|
||||
|
||||
while (M.ms() - time.get() < timeout && r.get() == null) {
|
||||
while(M.ms() - time.get() < timeout && r.get() == null) {
|
||||
b.queue(() -> {
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
if (M.ms() - time.get() > timeout) {
|
||||
for(int i = 0; i < 1000; i++) {
|
||||
if(M.ms() - time.get() > timeout) {
|
||||
return;
|
||||
}
|
||||
|
||||
int x = RNG.r.i(-29999970, 29999970);
|
||||
int z = RNG.r.i(-29999970, 29999970);
|
||||
checked.incrementAndGet();
|
||||
if (matcher.apply(stream.get(x, z), find)) {
|
||||
if(matcher.apply(stream.get(x, z), find)) {
|
||||
r.set(new IrisPosition(x, 120, z));
|
||||
time.set(0);
|
||||
}
|
||||
@@ -570,7 +570,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
|
||||
default IrisPosition lookForBiome(IrisBiome biome, long timeout, Consumer<Integer> triesc) {
|
||||
if (!getWorld().hasRealWorld()) {
|
||||
if(!getWorld().hasRealWorld()) {
|
||||
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
||||
return null;
|
||||
}
|
||||
@@ -579,7 +579,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
long s = M.ms();
|
||||
int cpus = (Runtime.getRuntime().availableProcessors());
|
||||
|
||||
if (!getDimension().getAllBiomes(this).contains(biome)) {
|
||||
if(!getDimension().getAllBiomes(this).contains(biome)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -587,50 +587,50 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
AtomicBoolean found = new AtomicBoolean(false);
|
||||
AtomicBoolean running = new AtomicBoolean(true);
|
||||
AtomicReference<IrisPosition> location = new AtomicReference<>();
|
||||
for (int i = 0; i < cpus; i++) {
|
||||
for(int i = 0; i < cpus; i++) {
|
||||
J.a(() -> {
|
||||
try {
|
||||
Engine e;
|
||||
IrisBiome b;
|
||||
int x, z;
|
||||
|
||||
while (!found.get() && running.get()) {
|
||||
while(!found.get() && running.get()) {
|
||||
try {
|
||||
x = RNG.r.i(-29999970, 29999970);
|
||||
z = RNG.r.i(-29999970, 29999970);
|
||||
b = getSurfaceBiome(x, z);
|
||||
|
||||
if (b != null && b.getLoadKey() == null) {
|
||||
if(b != null && b.getLoadKey() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (b != null && b.getLoadKey().equals(biome.getLoadKey())) {
|
||||
if(b != null && b.getLoadKey().equals(biome.getLoadKey())) {
|
||||
found.lazySet(true);
|
||||
location.lazySet(new IrisPosition(x, getHeight(x, z), z));
|
||||
}
|
||||
|
||||
tries.getAndIncrement();
|
||||
} catch (Throwable ex) {
|
||||
} catch(Throwable ex) {
|
||||
Iris.reportError(ex);
|
||||
ex.printStackTrace();
|
||||
return;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
while (!found.get() || location.get() == null) {
|
||||
while(!found.get() || location.get() == null) {
|
||||
J.sleep(50);
|
||||
|
||||
if (cl.flip()) {
|
||||
if(cl.flip()) {
|
||||
triesc.accept(tries.get());
|
||||
}
|
||||
|
||||
if (M.ms() - s > timeout) {
|
||||
if(M.ms() - s > timeout) {
|
||||
running.set(false);
|
||||
return null;
|
||||
}
|
||||
@@ -641,7 +641,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
|
||||
default IrisPosition lookForRegion(IrisRegion reg, long timeout, Consumer<Integer> triesc) {
|
||||
if (getWorld().hasRealWorld()) {
|
||||
if(getWorld().hasRealWorld()) {
|
||||
Iris.error("Cannot GOTO without a bound world (headless mode)");
|
||||
return null;
|
||||
}
|
||||
@@ -650,7 +650,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
long s = M.ms();
|
||||
int cpus = (Runtime.getRuntime().availableProcessors());
|
||||
|
||||
if (!getDimension().getRegions().contains(reg.getLoadKey())) {
|
||||
if(!getDimension().getRegions().contains(reg.getLoadKey())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -659,25 +659,25 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
AtomicBoolean running = new AtomicBoolean(true);
|
||||
AtomicReference<IrisPosition> location = new AtomicReference<>();
|
||||
|
||||
for (int i = 0; i < cpus; i++) {
|
||||
for(int i = 0; i < cpus; i++) {
|
||||
J.a(() -> {
|
||||
Engine e;
|
||||
IrisRegion b;
|
||||
int x, z;
|
||||
|
||||
while (!found.get() && running.get()) {
|
||||
while(!found.get() && running.get()) {
|
||||
try {
|
||||
x = RNG.r.i(-29999970, 29999970);
|
||||
z = RNG.r.i(-29999970, 29999970);
|
||||
b = getRegion(x, z);
|
||||
|
||||
if (b != null && b.getLoadKey() != null && b.getLoadKey().equals(reg.getLoadKey())) {
|
||||
if(b != null && b.getLoadKey() != null && b.getLoadKey().equals(reg.getLoadKey())) {
|
||||
found.lazySet(true);
|
||||
location.lazySet(new IrisPosition(x, getHeight(x, z), z));
|
||||
}
|
||||
|
||||
tries.getAndIncrement();
|
||||
} catch (Throwable xe) {
|
||||
} catch(Throwable xe) {
|
||||
Iris.reportError(xe);
|
||||
xe.printStackTrace();
|
||||
return;
|
||||
@@ -686,14 +686,14 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
});
|
||||
}
|
||||
|
||||
while (!found.get() || location.get() != null) {
|
||||
while(!found.get() || location.get() != null) {
|
||||
J.sleep(50);
|
||||
|
||||
if (cl.flip()) {
|
||||
if(cl.flip()) {
|
||||
triesc.accept(tries.get());
|
||||
}
|
||||
|
||||
if (M.ms() - s > timeout) {
|
||||
if(M.ms() - s > timeout) {
|
||||
triesc.accept(tries.get());
|
||||
running.set(false);
|
||||
return null;
|
||||
@@ -714,7 +714,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
boolean isStudio();
|
||||
|
||||
default IrisBiome getBiome(int x, int y, int z) {
|
||||
if (y <= getHeight(x, z) - 2) {
|
||||
if(y <= getHeight(x, z) - 2) {
|
||||
return getCaveBiome(x, z);
|
||||
}
|
||||
|
||||
@@ -722,7 +722,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
|
||||
default IrisBiome getBiomeOrMantle(int x, int y, int z) {
|
||||
if (y <= getHeight(x, z) - 2) {
|
||||
if(y <= getHeight(x, z) - 2) {
|
||||
return getCaveOrMantleBiome(x, y, z);
|
||||
}
|
||||
|
||||
@@ -732,7 +732,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
default String getObjectPlacementKey(int x, int y, int z) {
|
||||
PlacedObject o = getObjectPlacement(x, y, z);
|
||||
|
||||
if (o != null && o.getObject() != null) {
|
||||
if(o != null && o.getObject() != null) {
|
||||
return o.getObject().getLoadKey() + "@" + o.getId();
|
||||
}
|
||||
|
||||
@@ -742,7 +742,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
default PlacedObject getObjectPlacement(int x, int y, int z) {
|
||||
String objectAt = getMantle().getMantle().get(x, y, z, String.class);
|
||||
|
||||
if (objectAt == null || objectAt.isEmpty()) {
|
||||
if(objectAt == null || objectAt.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -751,16 +751,16 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
int id = Integer.parseInt(v[1]);
|
||||
IrisRegion region = getRegion(x, z);
|
||||
|
||||
for (IrisObjectPlacement i : region.getObjects()) {
|
||||
if (i.getPlace().contains(object)) {
|
||||
for(IrisObjectPlacement i : region.getObjects()) {
|
||||
if(i.getPlace().contains(object)) {
|
||||
return new PlacedObject(i, getData().getObjectLoader().load(object), id, x, z);
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome biome = getBiome(x, y, z);
|
||||
|
||||
for (IrisObjectPlacement i : biome.getObjects()) {
|
||||
if (i.getPlace().contains(object)) {
|
||||
for(IrisObjectPlacement i : biome.getObjects()) {
|
||||
if(i.getPlace().contains(object)) {
|
||||
return new PlacedObject(i, getData().getObjectLoader().load(object), id, x, z);
|
||||
}
|
||||
}
|
||||
@@ -777,16 +777,16 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
default void gotoBiome(IrisBiome biome, Player player) {
|
||||
Set<String> regionKeys = getDimension()
|
||||
.getAllRegions(this).stream()
|
||||
.filter((i) -> i.getAllBiomes(this).contains(biome))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
.getAllRegions(this).stream()
|
||||
.filter((i) -> i.getAllBiomes(this).contains(biome))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
Locator<IrisBiome> lb = Locator.surfaceBiome(biome.getLoadKey());
|
||||
Locator<IrisBiome> locator = (engine, chunk)
|
||||
-> regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())
|
||||
&& lb.matches(engine, chunk);
|
||||
-> regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())
|
||||
&& lb.matches(engine, chunk);
|
||||
|
||||
if (!regionKeys.isEmpty()) {
|
||||
if(!regionKeys.isEmpty()) {
|
||||
locator.find(player);
|
||||
} else {
|
||||
player.sendMessage(C.RED + biome.getName() + " is not in any defined regions!");
|
||||
@@ -794,10 +794,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
|
||||
default void gotoJigsaw(IrisJigsawStructure s, Player player) {
|
||||
if (s.getLoadKey().equals(getDimension().getStronghold())) {
|
||||
if(s.getLoadKey().equals(getDimension().getStronghold())) {
|
||||
KList<Position2> p = getDimension().getStrongholds(getSeedManager().getSpawn());
|
||||
|
||||
if (p.isEmpty()) {
|
||||
if(p.isEmpty()) {
|
||||
player.sendMessage(C.GOLD + "No strongholds in world.");
|
||||
}
|
||||
|
||||
@@ -807,19 +807,19 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
Iris.debug("Ps: " + p.size());
|
||||
|
||||
for (Position2 i : p) {
|
||||
for(Position2 i : p) {
|
||||
Iris.debug("- " + i.getX() + " " + i.getZ());
|
||||
}
|
||||
|
||||
for (Position2 i : p) {
|
||||
for(Position2 i : p) {
|
||||
double dx = i.distance(px);
|
||||
if (dx < d) {
|
||||
if(dx < d) {
|
||||
d = dx;
|
||||
pr = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (pr != null) {
|
||||
if(pr != null) {
|
||||
Location ll = new Location(player.getWorld(), pr.getX(), 40, pr.getZ());
|
||||
J.s(() -> player.teleport(ll));
|
||||
}
|
||||
@@ -827,36 +827,36 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
return;
|
||||
}
|
||||
|
||||
if (getDimension().getJigsawStructures().stream()
|
||||
.map(IrisJigsawStructurePlacement::getStructure)
|
||||
.collect(Collectors.toSet()).contains(s.getLoadKey())) {
|
||||
if(getDimension().getJigsawStructures().stream()
|
||||
.map(IrisJigsawStructurePlacement::getStructure)
|
||||
.collect(Collectors.toSet()).contains(s.getLoadKey())) {
|
||||
Locator.jigsawStructure(s.getLoadKey()).find(player);
|
||||
} else {
|
||||
Set<String> biomeKeys = getDimension().getAllBiomes(this).stream()
|
||||
.filter((i) -> i.getJigsawStructures()
|
||||
.stream()
|
||||
.anyMatch((j) -> j.getStructure().equals(s.getLoadKey())))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
.filter((i) -> i.getJigsawStructures()
|
||||
.stream()
|
||||
.anyMatch((j) -> j.getStructure().equals(s.getLoadKey())))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> regionKeys = getDimension().getAllRegions(this).stream()
|
||||
.filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains)
|
||||
|| i.getJigsawStructures()
|
||||
.stream()
|
||||
.anyMatch((j) -> j.getStructure().equals(s.getLoadKey())))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
.filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains)
|
||||
|| i.getJigsawStructures()
|
||||
.stream()
|
||||
.anyMatch((j) -> j.getStructure().equals(s.getLoadKey())))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Locator<IrisJigsawStructure> sl = Locator.jigsawStructure(s.getLoadKey());
|
||||
Locator<IrisBiome> locator = (engine, chunk) -> {
|
||||
if (biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
if(biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
return sl.matches(engine, chunk);
|
||||
} else if (regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
} else if(regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
return sl.matches(engine, chunk);
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
if (!regionKeys.isEmpty()) {
|
||||
if(!regionKeys.isEmpty()) {
|
||||
locator.find(player);
|
||||
} else {
|
||||
player.sendMessage(C.RED + s.getLoadKey() + " is not in any defined regions, biomes or dimensions!");
|
||||
@@ -867,27 +867,27 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
|
||||
default void gotoObject(String s, Player player) {
|
||||
Set<String> biomeKeys = getDimension().getAllBiomes(this).stream()
|
||||
.filter((i) -> i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s)))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
.filter((i) -> i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s)))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
Set<String> regionKeys = getDimension().getAllRegions(this).stream()
|
||||
.filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains)
|
||||
|| i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s)))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
.filter((i) -> i.getAllBiomeIds().stream().anyMatch(biomeKeys::contains)
|
||||
|| i.getObjects().stream().anyMatch((f) -> f.getPlace().contains(s)))
|
||||
.map(IrisRegistrant::getLoadKey)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
Locator<IrisObject> sl = Locator.object(s);
|
||||
Locator<IrisBiome> locator = (engine, chunk) -> {
|
||||
if (biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
if(biomeKeys.contains(getSurfaceBiome((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
return sl.matches(engine, chunk);
|
||||
} else if (regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
} else if(regionKeys.contains(getRegion((chunk.getX() << 4) + 8, (chunk.getZ() << 4) + 8).getLoadKey())) {
|
||||
return sl.matches(engine, chunk);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if (!regionKeys.isEmpty()) {
|
||||
if(!regionKeys.isEmpty()) {
|
||||
locator.find(player);
|
||||
} else {
|
||||
player.sendMessage(C.RED + s + " is not in any defined regions or biomes!");
|
||||
@@ -895,7 +895,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
|
||||
default void gotoRegion(IrisRegion r, Player player) {
|
||||
if (!getDimension().getAllRegions(this).contains(r)) {
|
||||
if(!getDimension().getAllRegions(this).contains(r)) {
|
||||
player.sendMessage(C.RED + r.getName() + " is not defined in the dimension!");
|
||||
return;
|
||||
}
|
||||
@@ -904,7 +904,7 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
|
||||
}
|
||||
|
||||
default void cleanupMantleChunk(int x, int z) {
|
||||
if (IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio()) {
|
||||
if(IrisSettings.get().getPerformance().isTrimMantleInStudio() || !isStudio()) {
|
||||
J.a(() -> getMantle().cleanupChunk(x, z));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ public abstract class EngineAssignedModifier<T> extends EngineAssignedComponent
|
||||
public void modify(int x, int z, Hunk<T> output, boolean multicore) {
|
||||
try {
|
||||
onModify(x, z, output, multicore);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.error("Modifier Failure: " + getName());
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
||||
|
||||
@EventHandler
|
||||
public void on(IrisEngineHotloadEvent e) {
|
||||
for (Player i : e.getEngine().getWorld().getPlayers()) {
|
||||
for(Player i : e.getEngine().getWorld().getPlayers()) {
|
||||
i.playSound(i.getLocation(), Sound.BLOCK_AMETHYST_BLOCK_BREAK, 1f, 1.8f);
|
||||
VolmitSender s = new VolmitSender(i);
|
||||
s.sendTitle(C.IRIS + "Engine " + C.AQUA + "<font:minecraft:uniform>Hotloaded", 70, 60, 410);
|
||||
@@ -71,34 +71,34 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void on(PlayerTeleportEvent e) {
|
||||
if (ignoreTP.get()) {
|
||||
if(ignoreTP.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!PaperLib.isPaper() || e.getTo() == null) {
|
||||
if(!PaperLib.isPaper() || e.getTo() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
if (e.getTo().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getTo().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
getEngine().getWorldManager().teleportAsync(e);
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
} catch(Throwable ex) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldSaveEvent e) {
|
||||
if (e.getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
getEngine().save();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(EntitySpawnEvent e) {
|
||||
if (e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if (e.getEntityType().equals(EntityType.ENDER_SIGNAL)) {
|
||||
if(e.getEntity().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getEntityType().equals(EntityType.ENDER_SIGNAL)) {
|
||||
KList<Position2> p = getEngine().getDimension().getStrongholds(getEngine().getSeedManager().getSpawn());
|
||||
Position2 px = new Position2(e.getEntity().getLocation().getBlockX(), e.getEntity().getLocation().getBlockZ());
|
||||
Position2 pr = null;
|
||||
@@ -106,19 +106,19 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
||||
|
||||
Iris.debug("Ps: " + p.size());
|
||||
|
||||
for (Position2 i : p) {
|
||||
for(Position2 i : p) {
|
||||
Iris.debug("- " + i.getX() + " " + i.getZ());
|
||||
}
|
||||
|
||||
for (Position2 i : p) {
|
||||
for(Position2 i : p) {
|
||||
double dx = i.distance(px);
|
||||
if (dx < d) {
|
||||
if(dx < d) {
|
||||
d = dx;
|
||||
pr = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (pr != null) {
|
||||
if(pr != null) {
|
||||
e.getEntity().getWorld().playSound(e.getEntity().getLocation(), Sound.ITEM_TRIDENT_THROW, 1f, 1.6f);
|
||||
Location ll = new Location(e.getEntity().getWorld(), pr.getX(), 40, pr.getZ());
|
||||
Iris.debug("ESignal: " + ll.getBlockX() + " " + ll.getBlockZ());
|
||||
@@ -130,28 +130,28 @@ public abstract class EngineAssignedWorldManager extends EngineAssignedComponent
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldUnloadEvent e) {
|
||||
if (e.getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
getEngine().close();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(BlockBreakEvent e) {
|
||||
if (e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
onBlockBreak(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(BlockPlaceEvent e) {
|
||||
if (e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getPlayer().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
onBlockPlace(e);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(ChunkLoadEvent e) {
|
||||
if (e.getChunk().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
if(e.getChunk().getWorld().equals(getTarget().getWorld().realWorld())) {
|
||||
onChunkLoad(e.getChunk(), e.isNewChunk());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,10 +39,10 @@ public interface EngineComponent {
|
||||
|
||||
default void close() {
|
||||
try {
|
||||
if (this instanceof Listener) {
|
||||
if(this instanceof Listener) {
|
||||
Iris.instance.unregisterListener((Listener) this);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ public class EngineData {
|
||||
try {
|
||||
f.getParentFile().mkdirs();
|
||||
return new Gson().fromJson(IO.readAll(f), EngineData.class);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -50,7 +50,7 @@ public class EngineData {
|
||||
try {
|
||||
f.getParentFile().mkdirs();
|
||||
IO.writeAll(f, new Gson().toJson(this));
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public interface EngineDecorator extends EngineComponent {
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
default boolean canGoOn(BlockData decorant, BlockData atop) {
|
||||
if (atop == null || B.isAir(atop)) {
|
||||
if(atop == null || B.isAir(atop)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public interface EngineMode extends Staged {
|
||||
BurstExecutor e = burst().burst(stages.length);
|
||||
e.setMulticore(multicore);
|
||||
|
||||
for (EngineStage i : stages) {
|
||||
for(EngineStage i : stages) {
|
||||
e.queue(() -> i.generate(x, z, blocks, biomes, multicore));
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public interface EngineMode extends Staged {
|
||||
|
||||
@BlockCoordinates
|
||||
default void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore) {
|
||||
for (EngineStage i : getStages()) {
|
||||
for(EngineStage i : getStages()) {
|
||||
i.generate(x, z, blocks, biomes, multicore);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,22 +49,22 @@ public class EnginePlayer {
|
||||
sample();
|
||||
|
||||
J.a(() -> {
|
||||
if (region != null) {
|
||||
for (IrisEffect j : region.getEffects()) {
|
||||
if(region != null) {
|
||||
for(IrisEffect j : region.getEffects()) {
|
||||
try {
|
||||
j.apply(player, getEngine());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (biome != null) {
|
||||
for (IrisEffect j : biome.getEffects()) {
|
||||
if(biome != null) {
|
||||
for(IrisEffect j : biome.getEffects()) {
|
||||
try {
|
||||
j.apply(player, getEngine());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -79,12 +79,12 @@ public class EnginePlayer {
|
||||
|
||||
public void sample() {
|
||||
try {
|
||||
if (ticksSinceLastSample() > 55 && player.getLocation().distanceSquared(lastLocation) > 9 * 9) {
|
||||
if(ticksSinceLastSample() > 55 && player.getLocation().distanceSquared(lastLocation) > 9 * 9) {
|
||||
lastLocation = player.getLocation().clone();
|
||||
lastSample = M.ms();
|
||||
sampleBiomeRegion();
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ public interface EngineStage {
|
||||
void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes, boolean multicore);
|
||||
|
||||
default void close() {
|
||||
if (this instanceof EngineComponent c) {
|
||||
if(this instanceof EngineComponent c) {
|
||||
c.close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ public interface Fallible {
|
||||
default void fail(String error) {
|
||||
try {
|
||||
throw new RuntimeException();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
fail(error, e);
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class IrisEngineMode implements EngineMode {
|
||||
|
||||
@Override
|
||||
public synchronized void close() {
|
||||
if (closed) {
|
||||
if(closed) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ public interface Locator<T> {
|
||||
boolean matches(Engine engine, Position2 chunk);
|
||||
|
||||
static void cancelSearch() {
|
||||
if (LocatorCanceller.cancel != null) {
|
||||
if(LocatorCanceller.cancel != null) {
|
||||
LocatorCanceller.cancel.run();
|
||||
LocatorCanceller.cancel = null;
|
||||
}
|
||||
@@ -68,14 +68,14 @@ public interface Locator<T> {
|
||||
try {
|
||||
Position2 at = find(IrisToolbelt.access(player.getWorld()).getEngine(), new Position2(player.getLocation().getBlockX() >> 4, player.getLocation().getBlockZ() >> 4), timeout, checks::set).get();
|
||||
|
||||
if (at != null) {
|
||||
if(at != null) {
|
||||
J.s(() -> player.teleport(new Location(player.getWorld(), (at.getX() << 4) + 8,
|
||||
IrisToolbelt.access(player.getWorld()).getEngine().getHeight(
|
||||
(at.getX() << 4) + 8,
|
||||
(at.getZ() << 4) + 8, false),
|
||||
(at.getZ() << 4) + 8)));
|
||||
IrisToolbelt.access(player.getWorld()).getEngine().getHeight(
|
||||
(at.getX() << 4) + 8,
|
||||
(at.getZ() << 4) + 8, false),
|
||||
(at.getZ() << 4) + 8)));
|
||||
}
|
||||
} catch (WrongEngineBroException | InterruptedException | ExecutionException e) {
|
||||
} catch(WrongEngineBroException | InterruptedException | ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}) {
|
||||
@@ -97,7 +97,7 @@ public interface Locator<T> {
|
||||
}
|
||||
|
||||
default Future<Position2> find(Engine engine, Position2 pos, long timeout, Consumer<Integer> checks) throws WrongEngineBroException {
|
||||
if (engine.isClosed()) {
|
||||
if(engine.isClosed()) {
|
||||
throw new WrongEngineBroException();
|
||||
}
|
||||
|
||||
@@ -117,15 +117,15 @@ public interface Locator<T> {
|
||||
Spiraler s = new Spiraler(100000, 100000, (x, z) -> next.set(new Position2(x, z)));
|
||||
s.setOffset(cursor.getX(), cursor.getZ());
|
||||
s.next();
|
||||
while (!found.get() && !stop.get() && px.getMilliseconds() < timeout) {
|
||||
while(!found.get() && !stop.get() && px.getMilliseconds() < timeout) {
|
||||
BurstExecutor e = burst.burst(tc);
|
||||
|
||||
for (int i = 0; i < tc; i++) {
|
||||
for(int i = 0; i < tc; i++) {
|
||||
Position2 p = next.get();
|
||||
s.next();
|
||||
e.queue(() -> {
|
||||
if (matches(engine, p)) {
|
||||
if (foundPos.get() == null) {
|
||||
if(matches(engine, p)) {
|
||||
if(foundPos.get() == null) {
|
||||
foundPos.set(p);
|
||||
}
|
||||
|
||||
@@ -141,7 +141,7 @@ public interface Locator<T> {
|
||||
|
||||
LocatorCanceller.cancel = null;
|
||||
|
||||
if (found.get() && foundPos.get() != null) {
|
||||
if(found.get() && foundPos.get() != null) {
|
||||
return foundPos.get();
|
||||
}
|
||||
|
||||
@@ -177,11 +177,11 @@ public interface Locator<T> {
|
||||
AtomicBoolean found = new AtomicBoolean(false);
|
||||
e.generateMatter(c.getX(), c.getZ(), true);
|
||||
e.getMantle().getMantle().iterateChunk(c.getX(), c.getZ(), MatterCavern.class, (x, y, z, t) -> {
|
||||
if (found.get()) {
|
||||
if(found.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (t != null && t.getCustomBiome().equals(loadKey)) {
|
||||
if(t != null && t.getCustomBiome().equals(loadKey)) {
|
||||
found.set(true);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -45,18 +45,18 @@ public class PregeneratedData {
|
||||
|
||||
public Runnable inject(TerrainChunk tc) {
|
||||
blocks.iterateSync((x, y, z, b) -> {
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
tc.setBlock(x, y, z, b);
|
||||
}
|
||||
|
||||
Biome bf = biomes.get(x, y, z);
|
||||
if (bf != null) {
|
||||
if(bf != null) {
|
||||
tc.setBiome(x, y, z, bf);
|
||||
}
|
||||
});
|
||||
|
||||
if (postMod.get()) {
|
||||
return () -> Hunk.view((ChunkGenerator.ChunkData) tc).insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b));
|
||||
if(postMod.get()) {
|
||||
return () -> Hunk.view(tc).insertSoftly(0, 0, 0, post, (b) -> b == null || B.isAirOrFluid(b));
|
||||
}
|
||||
|
||||
return () -> {
|
||||
|
||||
@@ -94,7 +94,7 @@ public class SeedManager {
|
||||
RNG e = new RNG((IRIS_TERRAIN_VERSION * 42) + IRIS_SIGNATURE);
|
||||
double gsoup = 0;
|
||||
int gk = a.i(1_000, 10_000);
|
||||
for (char i : (a.s(4) + b.s(4) + c.s(4) + d.s(4) + e.s(4)).toCharArray()) {
|
||||
for(char i : (a.s(4) + b.s(4) + c.s(4) + d.s(4) + e.s(4)).toCharArray()) {
|
||||
gsoup += ((gk * b.d(3, Math.PI)) / c.d(10, 18 * Math.E)) + 6_549;
|
||||
gsoup *= d.d(90.5, 1_234_567);
|
||||
gsoup += e.d(39.95, 99.25);
|
||||
|
||||
@@ -93,7 +93,7 @@ public class PlannedPiece {
|
||||
}
|
||||
|
||||
public AxisAlignedBB getBox() {
|
||||
if (box != null) {
|
||||
if(box != null) {
|
||||
return box;
|
||||
}
|
||||
|
||||
@@ -111,18 +111,18 @@ public class PlannedPiece {
|
||||
}
|
||||
|
||||
public KList<IrisJigsawPieceConnector> getAvailableConnectors() {
|
||||
if (connected.isEmpty()) {
|
||||
if(connected.isEmpty()) {
|
||||
return piece.getConnectors().copy();
|
||||
}
|
||||
|
||||
if (connected.size() == piece.getConnectors().size()) {
|
||||
if(connected.size() == piece.getConnectors().size()) {
|
||||
return new KList<>();
|
||||
}
|
||||
|
||||
KList<IrisJigsawPieceConnector> c = new KList<>();
|
||||
|
||||
for (IrisJigsawPieceConnector i : piece.getConnectors()) {
|
||||
if (!connected.contains(i)) {
|
||||
for(IrisJigsawPieceConnector i : piece.getConnectors()) {
|
||||
if(!connected.contains(i)) {
|
||||
c.add(i);
|
||||
}
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class PlannedPiece {
|
||||
}
|
||||
|
||||
public boolean connect(IrisJigsawPieceConnector c) {
|
||||
if (piece.getConnectors().contains(c)) {
|
||||
if(piece.getConnectors().contains(c)) {
|
||||
return connected.addIfMissing(c);
|
||||
}
|
||||
|
||||
@@ -154,10 +154,10 @@ public class PlannedPiece {
|
||||
PlatformChunkGenerator a = IrisToolbelt.access(world);
|
||||
|
||||
int minY = 0;
|
||||
if (a != null) {
|
||||
if(a != null) {
|
||||
minY = a.getEngine().getMinHeight();
|
||||
|
||||
if (!a.getEngine().getDimension().isBedrock())
|
||||
if(!a.getEngine().getDimension().isBedrock())
|
||||
minY--; //If the dimension has no bedrock, allow it to go a block lower
|
||||
}
|
||||
|
||||
@@ -183,19 +183,19 @@ public class PlannedPiece {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
|
||||
//Prevent blocks being set in or bellow bedrock
|
||||
if (y <= finalMinY || block.getType() == Material.BEDROCK) return;
|
||||
if(y <= finalMinY || block.getType() == Material.BEDROCK) return;
|
||||
|
||||
block.setBlockData(d);
|
||||
|
||||
if (a != null && getPiece().getPlacementOptions().getLoot().isNotEmpty() &&
|
||||
block.getState() instanceof InventoryHolder) {
|
||||
if(a != null && getPiece().getPlacementOptions().getLoot().isNotEmpty() &&
|
||||
block.getState() instanceof InventoryHolder) {
|
||||
|
||||
IrisLootTable table = getPiece().getPlacementOptions().getTable(block.getBlockData(), getData());
|
||||
if (table == null) return;
|
||||
if(table == null) return;
|
||||
Engine engine = a.getEngine();
|
||||
engine.addItems(false, ((InventoryHolder) block.getState()).getInventory(),
|
||||
rng.nextParallelRNG(BlockPosition.toLong(x, y, z)),
|
||||
new KList<>(table), InventorySlotType.STORAGE, x, y, z, 15);
|
||||
rng.nextParallelRNG(BlockPosition.toLong(x, y, z)),
|
||||
new KList<>(table), InventorySlotType.STORAGE, x, y, z, 15);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -243,7 +243,7 @@ public class PlannedPiece {
|
||||
|
||||
@Override
|
||||
public Engine getEngine() {
|
||||
if (IrisToolbelt.isIrisWorld(world)) {
|
||||
if(IrisToolbelt.isIrisWorld(world)) {
|
||||
return IrisToolbelt.access(world).getEngine();
|
||||
}
|
||||
|
||||
|
||||
@@ -43,11 +43,11 @@ import org.bukkit.World;
|
||||
@Data
|
||||
public class PlannedStructure {
|
||||
private static transient ConcurrentLinkedHashMap<String, IrisObject> objectRotationCache
|
||||
= new ConcurrentLinkedHashMap.Builder<String, IrisObject>()
|
||||
.initialCapacity(64)
|
||||
.maximumWeightedCapacity(1024)
|
||||
.concurrencyLevel(32)
|
||||
.build();
|
||||
= new ConcurrentLinkedHashMap.Builder<String, IrisObject>()
|
||||
.initialCapacity(64)
|
||||
.maximumWeightedCapacity(1024)
|
||||
.concurrencyLevel(32)
|
||||
.build();
|
||||
private KList<PlannedPiece> pieces;
|
||||
private IrisJigsawStructure structure;
|
||||
private IrisPosition position;
|
||||
@@ -66,7 +66,7 @@ public class PlannedStructure {
|
||||
this.data = structure.getLoader();
|
||||
generateStartPiece();
|
||||
|
||||
for (int i = 0; i < structure.getMaxDepth(); i++) {
|
||||
for(int i = 0; i < structure.getMaxDepth(); i++) {
|
||||
generateOutwards();
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ public class PlannedStructure {
|
||||
|
||||
Iris.debug("JPlace: ROOT @ relative " + position.toString());
|
||||
|
||||
for (PlannedPiece i : pieces) {
|
||||
for(PlannedPiece i : pieces) {
|
||||
Iris.debug("Place: " + i.getObject().getLoadKey() + " at @ relative " + i.getPosition().toString());
|
||||
}
|
||||
}
|
||||
@@ -84,7 +84,7 @@ public class PlannedStructure {
|
||||
options.getRotation().setEnabled(false);
|
||||
int startHeight = pieces.get(0).getPosition().getY();
|
||||
|
||||
for (PlannedPiece i : pieces) {
|
||||
for(PlannedPiece i : pieces) {
|
||||
place(i, startHeight, options, placer, e, eng);
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,7 @@ public class PlannedStructure {
|
||||
public void place(PlannedPiece i, int startHeight, IrisObjectPlacement o, IObjectPlacer placer, Mantle e, Engine eng) {
|
||||
IrisObjectPlacement options = o;
|
||||
|
||||
if (i.getPiece().getPlacementOptions() != null) {
|
||||
if(i.getPiece().getPlacementOptions() != null) {
|
||||
options = i.getPiece().getPlacementOptions();
|
||||
options.getRotation().setEnabled(false);
|
||||
} else {
|
||||
@@ -109,8 +109,8 @@ public class PlannedStructure {
|
||||
int offset = i.getPosition().getY() - startHeight;
|
||||
int height = 0;
|
||||
|
||||
if (i.getStructure().getStructure().getLockY() == -1) {
|
||||
if (i.getStructure().getStructure().getOverrideYRange() != null) {
|
||||
if(i.getStructure().getStructure().getLockY() == -1) {
|
||||
if(i.getStructure().getStructure().getOverrideYRange() != null) {
|
||||
height = (int) i.getStructure().getStructure().getOverrideYRange().get(rng, xx, zz, getData());
|
||||
} else {
|
||||
height = placer.getHighest(xx, zz, getData());
|
||||
@@ -121,24 +121,24 @@ public class PlannedStructure {
|
||||
|
||||
height += offset + (v.getH() / 2);
|
||||
|
||||
if (options.getMode().equals(ObjectPlaceMode.PAINT)) {
|
||||
if(options.getMode().equals(ObjectPlaceMode.PAINT)) {
|
||||
height = -1;
|
||||
}
|
||||
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
vo.place(xx, height, zz, placer, options, rng, e.shouldReduce(eng) ? null : (b)
|
||||
-> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
|
||||
-> e.set(b.getX(), b.getY(), b.getZ(), v.getLoadKey() + "@" + id), null, getData());
|
||||
}
|
||||
|
||||
public void place(World world) {
|
||||
for (PlannedPiece i : pieces) {
|
||||
for(PlannedPiece i : pieces) {
|
||||
Iris.sq(() -> i.place(world));
|
||||
}
|
||||
}
|
||||
|
||||
private void generateOutwards() {
|
||||
for (PlannedPiece i : getPiecesWithAvailableConnectors().shuffle(rng)) {
|
||||
if (!generatePieceOutwards(i)) {
|
||||
for(PlannedPiece i : getPiecesWithAvailableConnectors().shuffle(rng)) {
|
||||
if(!generatePieceOutwards(i)) {
|
||||
i.setDead(true);
|
||||
}
|
||||
}
|
||||
@@ -147,8 +147,8 @@ public class PlannedStructure {
|
||||
private boolean generatePieceOutwards(PlannedPiece piece) {
|
||||
boolean b = false;
|
||||
|
||||
for (IrisJigsawPieceConnector i : piece.getAvailableConnectors().shuffleCopy(rng)) {
|
||||
if (generateConnectorOutwards(piece, i)) {
|
||||
for(IrisJigsawPieceConnector i : piece.getAvailableConnectors().shuffleCopy(rng)) {
|
||||
if(generateConnectorOutwards(piece, i)) {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
@@ -157,8 +157,8 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
private boolean generateConnectorOutwards(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector) {
|
||||
for (IrisJigsawPiece i : getShuffledPiecesFor(pieceConnector)) {
|
||||
if (generateRotatedPiece(piece, pieceConnector, i)) {
|
||||
for(IrisJigsawPiece i : getShuffledPiecesFor(pieceConnector)) {
|
||||
if(generateRotatedPiece(piece, pieceConnector, i)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -167,8 +167,8 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea) {
|
||||
if (!piece.getPiece().getPlacementOptions().getRotation().isEnabled()) {
|
||||
if (generateRotatedPiece(piece, pieceConnector, idea, 0, 0, 0)) {
|
||||
if(!piece.getPiece().getPlacementOptions().getRotation().isEnabled()) {
|
||||
if(generateRotatedPiece(piece, pieceConnector, idea, 0, 0, 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -176,23 +176,23 @@ public class PlannedStructure {
|
||||
KList<Integer> forder1 = new KList<Integer>().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng);
|
||||
KList<Integer> forder2 = new KList<Integer>().qadd(0).qadd(1).qadd(2).qadd(3).shuffle(rng);
|
||||
|
||||
for (Integer i : forder1) {
|
||||
if (pieceConnector.isRotateConnector()) {
|
||||
for(Integer i : forder1) {
|
||||
if(pieceConnector.isRotateConnector()) {
|
||||
assert pieceConnector.getDirection().getAxis() != null;
|
||||
if (!pieceConnector.getDirection().getAxis().equals(Axis.Y)) {
|
||||
for (Integer j : forder2) {
|
||||
if (pieceConnector.getDirection().getAxis().equals(Axis.X) && generateRotatedPiece(piece, pieceConnector, idea, j, i, 0)) {
|
||||
if(!pieceConnector.getDirection().getAxis().equals(Axis.Y)) {
|
||||
for(Integer j : forder2) {
|
||||
if(pieceConnector.getDirection().getAxis().equals(Axis.X) && generateRotatedPiece(piece, pieceConnector, idea, j, i, 0)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (pieceConnector.getDirection().getAxis().equals(Axis.Z) && generateRotatedPiece(piece, pieceConnector, idea, 0, i, j)) {
|
||||
if(pieceConnector.getDirection().getAxis().equals(Axis.Z) && generateRotatedPiece(piece, pieceConnector, idea, 0, i, j)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (generateRotatedPiece(piece, pieceConnector, idea, 0, i, 0)) {
|
||||
if(generateRotatedPiece(piece, pieceConnector, idea, 0, i, 0)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -201,14 +201,14 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
private boolean generateRotatedPiece(PlannedPiece piece, IrisJigsawPieceConnector pieceConnector, IrisJigsawPiece idea, IrisObjectRotation rotation) {
|
||||
if (!idea.getPlacementOptions().getRotation().isEnabled()) {
|
||||
if(!idea.getPlacementOptions().getRotation().isEnabled()) {
|
||||
rotation = piece.getRotation();
|
||||
}
|
||||
|
||||
PlannedPiece test = new PlannedPiece(this, piece.getPosition(), idea, rotation);
|
||||
|
||||
for (IrisJigsawPieceConnector j : test.getPiece().getConnectors().shuffleCopy(rng)) {
|
||||
if (generatePositionedPiece(piece, pieceConnector, test, j)) {
|
||||
for(IrisJigsawPieceConnector j : test.getPiece().getConnectors().shuffleCopy(rng)) {
|
||||
if(generatePositionedPiece(piece, pieceConnector, test, j)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -229,18 +229,18 @@ public class PlannedStructure {
|
||||
IrisDirection desiredDirection = pieceConnector.getDirection().reverse();
|
||||
IrisPosition desiredPosition = connector.sub(new IrisPosition(desiredDirection.toVector()));
|
||||
|
||||
if (!pieceConnector.getTargetName().equals("*") && !pieceConnector.getTargetName().equals(testConnector.getName())) {
|
||||
if(!pieceConnector.getTargetName().equals("*") && !pieceConnector.getTargetName().equals(testConnector.getName())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!testConnector.getDirection().equals(desiredDirection)) {
|
||||
if(!testConnector.getDirection().equals(desiredDirection)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
IrisPosition shift = test.getWorldPosition(testConnector);
|
||||
test.setPosition(desiredPosition.sub(shift));
|
||||
|
||||
if (collidesWith(test, piece)) {
|
||||
if(collidesWith(test, piece)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -254,11 +254,11 @@ public class PlannedStructure {
|
||||
private KList<IrisJigsawPiece> getShuffledPiecesFor(IrisJigsawPieceConnector c) {
|
||||
KList<IrisJigsawPiece> p = new KList<>();
|
||||
|
||||
for (String i : c.getPools().shuffleCopy(rng)) {
|
||||
for (String j : getData().getJigsawPoolLoader().load(i).getPieces().shuffleCopy(rng)) {
|
||||
for(String i : c.getPools().shuffleCopy(rng)) {
|
||||
for(String j : getData().getJigsawPoolLoader().load(i).getPieces().shuffleCopy(rng)) {
|
||||
IrisJigsawPiece pi = getData().getJigsawPieceLoader().load(j);
|
||||
|
||||
if (pi == null || (terminating && !pi.isTerminal())) {
|
||||
if(pi == null || (terminating && !pi.isTerminal())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
private void generateTerminators() {
|
||||
if (getStructure().isTerminate()) {
|
||||
if(getStructure().isTerminate()) {
|
||||
terminating = true;
|
||||
generateOutwards();
|
||||
}
|
||||
@@ -286,7 +286,7 @@ public class PlannedStructure {
|
||||
public int getVolume() {
|
||||
int v = 0;
|
||||
|
||||
for (PlannedPiece i : pieces) {
|
||||
for(PlannedPiece i : pieces) {
|
||||
v += i.getObject().getH() * i.getObject().getW() * i.getObject().getD();
|
||||
}
|
||||
|
||||
@@ -296,7 +296,7 @@ public class PlannedStructure {
|
||||
public int getMass() {
|
||||
int v = 0;
|
||||
|
||||
for (PlannedPiece i : pieces) {
|
||||
for(PlannedPiece i : pieces) {
|
||||
v += i.getObject().getBlocks().size();
|
||||
}
|
||||
|
||||
@@ -304,12 +304,12 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
public boolean collidesWith(PlannedPiece piece, PlannedPiece ignore) {
|
||||
for (PlannedPiece i : pieces) {
|
||||
if (i.equals(ignore)) {
|
||||
for(PlannedPiece i : pieces) {
|
||||
if(i.equals(ignore)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i.collidesWith(piece)) {
|
||||
if(i.collidesWith(piece)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -318,8 +318,8 @@ public class PlannedStructure {
|
||||
}
|
||||
|
||||
public boolean contains(IrisPosition p) {
|
||||
for (PlannedPiece i : pieces) {
|
||||
if (i.contains(p)) {
|
||||
for(PlannedPiece i : pieces) {
|
||||
if(i.contains(p)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
default KList<IrisPosition> findMarkers(int x, int z, MatterMarker marker) {
|
||||
KList<IrisPosition> p = new KList<>();
|
||||
getMantle().iterateChunk(x, z, MatterMarker.class, (xx, yy, zz, mm) -> {
|
||||
if (marker.equals(mm)) {
|
||||
if(marker.equals(mm)) {
|
||||
p.add(new IrisPosition(xx + (x << 4), yy, zz + (z << 4)));
|
||||
}
|
||||
});
|
||||
@@ -116,7 +116,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
default BlockData get(int x, int y, int z) {
|
||||
BlockData block = getMantle().get(x, y, z, BlockData.class);
|
||||
|
||||
if (block == null) {
|
||||
if(block == null) {
|
||||
return AIR;
|
||||
}
|
||||
|
||||
@@ -195,15 +195,15 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
|
||||
@ChunkCoordinates
|
||||
default void generateMatter(int x, int z, boolean multicore) {
|
||||
if (!getEngine().getDimension().isUseMantle()) {
|
||||
if(!getEngine().getDimension().isUseMantle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int s = getRealRadius();
|
||||
BurstExecutor burst = burst().burst(multicore);
|
||||
MantleWriter writer = getMantle().write(this, x, z, s * 2);
|
||||
for (int i = -s; i <= s; i++) {
|
||||
for (int j = -s; j <= s; j++) {
|
||||
for(int i = -s; i <= s; i++) {
|
||||
for(int j = -s; j <= s; j++) {
|
||||
int xx = i + x;
|
||||
int zz = j + z;
|
||||
burst.queue(() -> {
|
||||
@@ -211,7 +211,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
getMantle().raiseFlag(xx, zz, MantleFlag.PLANNED, () -> {
|
||||
MantleChunk mc = getMantle().getChunk(xx, zz);
|
||||
|
||||
for (MantleComponent k : getComponents()) {
|
||||
for(MantleComponent k : getComponents()) {
|
||||
generateMantleComponent(writer, xx, zz, k, mc);
|
||||
}
|
||||
});
|
||||
@@ -228,7 +228,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
|
||||
@ChunkCoordinates
|
||||
default <T> void insertMatter(int x, int z, Class<T> t, Hunk<T> blocks, boolean multicore) {
|
||||
if (!getEngine().getDimension().isUseMantle()) {
|
||||
if(!getEngine().getDimension().isUseMantle()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
default void dropCavernBlock(int x, int y, int z) {
|
||||
Matter matter = getMantle().getChunk(x & 15, z & 15).get(y & 15);
|
||||
|
||||
if (matter != null) {
|
||||
if(matter != null) {
|
||||
matter.slice(MatterCavern.class).set(x & 15, y & 15, z & 15, null);
|
||||
}
|
||||
}
|
||||
@@ -268,11 +268,11 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
default boolean isCovered(int x, int z) {
|
||||
int s = getRealRadius();
|
||||
|
||||
for (int i = -s; i <= s; i++) {
|
||||
for (int j = -s; j <= s; j++) {
|
||||
for(int i = -s; i <= s; i++) {
|
||||
for(int j = -s; j <= s; j++) {
|
||||
int xx = i + x;
|
||||
int zz = j + z;
|
||||
if (!getMantle().hasFlag(xx, zz, MantleFlag.REAL)) {
|
||||
if(!getMantle().hasFlag(xx, zz, MantleFlag.REAL)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public interface EngineMantle extends IObjectPlacer {
|
||||
}
|
||||
|
||||
default void cleanupChunk(int x, int z) {
|
||||
if (!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z)) {
|
||||
if(!getMantle().hasFlag(x, z, MantleFlag.CLEANED) && isCovered(x, z)) {
|
||||
getMantle().raiseFlag(x, z, MantleFlag.CLEANED, () -> {
|
||||
getMantle().deleteChunkSlice(x, z, BlockData.class);
|
||||
getMantle().deleteChunkSlice(x, z, String.class);
|
||||
|
||||
@@ -58,8 +58,8 @@ public class MantleWriter implements IObjectPlacer {
|
||||
this.x = x;
|
||||
this.z = z;
|
||||
|
||||
for (int i = -radius; i <= radius; i++) {
|
||||
for (int j = -radius; j <= radius; j++) {
|
||||
for(int i = -radius; i <= radius; i++) {
|
||||
for(int j = -radius; j <= radius; j++) {
|
||||
cachedChunks.put(Cache.key(i + x, j + z), mantle.getChunk(i + x, j + z));
|
||||
}
|
||||
}
|
||||
@@ -69,15 +69,15 @@ public class MantleWriter implements IObjectPlacer {
|
||||
Set<IrisPosition> returnset = new HashSet<>();
|
||||
int ceilrad = (int) Math.ceil(radius);
|
||||
|
||||
for (IrisPosition v : vset) {
|
||||
for(IrisPosition v : vset) {
|
||||
int tipx = v.getX();
|
||||
int tipy = v.getY();
|
||||
int tipz = v.getZ();
|
||||
|
||||
for (int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for (int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
|
||||
for (int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||
if (hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) {
|
||||
for(int loopx = tipx - ceilrad; loopx <= tipx + ceilrad; loopx++) {
|
||||
for(int loopy = tipy - ceilrad; loopy <= tipy + ceilrad; loopy++) {
|
||||
for(int loopz = tipz - ceilrad; loopz <= tipz + ceilrad; loopz++) {
|
||||
if(hypot(loopx - tipx, loopy - tipy, loopz - tipz) <= radius) {
|
||||
returnset.add(new IrisPosition(loopx, loopy, loopz));
|
||||
}
|
||||
}
|
||||
@@ -89,16 +89,16 @@ public class MantleWriter implements IObjectPlacer {
|
||||
|
||||
private static Set<IrisPosition> getHollowed(Set<IrisPosition> vset) {
|
||||
Set<IrisPosition> returnset = new KSet<>();
|
||||
for (IrisPosition v : vset) {
|
||||
for(IrisPosition v : vset) {
|
||||
double x = v.getX();
|
||||
double y = v.getY();
|
||||
double z = v.getZ();
|
||||
if (!(vset.contains(new IrisPosition(x + 1, y, z))
|
||||
&& vset.contains(new IrisPosition(x - 1, y, z))
|
||||
&& vset.contains(new IrisPosition(x, y + 1, z))
|
||||
&& vset.contains(new IrisPosition(x, y - 1, z))
|
||||
&& vset.contains(new IrisPosition(x, y, z + 1))
|
||||
&& vset.contains(new IrisPosition(x, y, z - 1)))) {
|
||||
if(!(vset.contains(new IrisPosition(x + 1, y, z))
|
||||
&& vset.contains(new IrisPosition(x - 1, y, z))
|
||||
&& vset.contains(new IrisPosition(x, y + 1, z))
|
||||
&& vset.contains(new IrisPosition(x, y - 1, z))
|
||||
&& vset.contains(new IrisPosition(x, y, z + 1))
|
||||
&& vset.contains(new IrisPosition(x, y, z - 1)))) {
|
||||
returnset.add(v);
|
||||
}
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class MantleWriter implements IObjectPlacer {
|
||||
|
||||
private static double hypot(double... pars) {
|
||||
double sum = 0;
|
||||
for (double d : pars) {
|
||||
for(double d : pars) {
|
||||
sum += Math.pow(d, 2);
|
||||
}
|
||||
return Math.sqrt(sum);
|
||||
@@ -122,22 +122,22 @@ public class MantleWriter implements IObjectPlacer {
|
||||
}
|
||||
|
||||
public <T> void setData(int x, int y, int z, T t) {
|
||||
if (t == null) {
|
||||
if(t == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
|
||||
if (y < 0 || y >= mantle.getWorldHeight()) {
|
||||
if(y < 0 || y >= mantle.getWorldHeight()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (cx >= this.x - radius && cx <= this.x + radius
|
||||
&& cz >= this.z - radius && cz <= this.z + radius) {
|
||||
if(cx >= this.x - radius && cx <= this.x + radius
|
||||
&& cz >= this.z - radius && cz <= this.z + radius) {
|
||||
MantleChunk chunk = cachedChunks.get(Cache.key(cx, cz));
|
||||
|
||||
if (chunk == null) {
|
||||
if(chunk == null) {
|
||||
Iris.error("Mantle Writer Accessed " + cx + "," + cz + " and came up null (and yet within bounds!)");
|
||||
return;
|
||||
}
|
||||
@@ -210,13 +210,20 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set a sphere into the mantle
|
||||
*
|
||||
* @param cx the center x
|
||||
* @param cy the center y
|
||||
* @param cz the center z
|
||||
* @param radius the radius of this sphere
|
||||
* @param fill should it be filled? or just the outer shell?
|
||||
* @param data the data to set
|
||||
* @param <T> the type of data to apply to the mantle
|
||||
* @param cx
|
||||
* the center x
|
||||
* @param cy
|
||||
* the center y
|
||||
* @param cz
|
||||
* the center z
|
||||
* @param radius
|
||||
* the radius of this sphere
|
||||
* @param fill
|
||||
* should it be filled? or just the outer shell?
|
||||
* @param data
|
||||
* the data to set
|
||||
* @param <T>
|
||||
* the type of data to apply to the mantle
|
||||
*/
|
||||
public <T> void setSphere(int cx, int cy, int cz, double radius, boolean fill, T data) {
|
||||
setElipsoid(cx, cy, cz, radius, radius, radius, fill, data);
|
||||
@@ -229,15 +236,24 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set an elipsoid into the mantle
|
||||
*
|
||||
* @param cx the center x
|
||||
* @param cy the center y
|
||||
* @param cz the center z
|
||||
* @param rx the x radius
|
||||
* @param ry the y radius
|
||||
* @param rz the z radius
|
||||
* @param fill should it be filled or just the outer shell?
|
||||
* @param data the data to set
|
||||
* @param <T> the type of data to apply to the mantle
|
||||
* @param cx
|
||||
* the center x
|
||||
* @param cy
|
||||
* the center y
|
||||
* @param cz
|
||||
* the center z
|
||||
* @param rx
|
||||
* the x radius
|
||||
* @param ry
|
||||
* the y radius
|
||||
* @param rz
|
||||
* the z radius
|
||||
* @param fill
|
||||
* should it be filled or just the outer shell?
|
||||
* @param data
|
||||
* the data to set
|
||||
* @param <T>
|
||||
* the type of data to apply to the mantle
|
||||
*/
|
||||
public <T> void setElipsoidFunction(int cx, int cy, int cz, double rx, double ry, double rz, boolean fill, Function3<Integer, Integer, Integer, T> data) {
|
||||
rx += 0.5;
|
||||
@@ -252,23 +268,23 @@ public class MantleWriter implements IObjectPlacer {
|
||||
double nextXn = 0;
|
||||
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
for(int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextYn = 0;
|
||||
forY:
|
||||
for (int y = 0; y <= ceilRadiusY; ++y) {
|
||||
for(int y = 0; y <= ceilRadiusY; ++y) {
|
||||
final double yn = nextYn;
|
||||
nextYn = (y + 1) * invRadiusY;
|
||||
double nextZn = 0;
|
||||
for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
for(int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
|
||||
double distanceSq = lengthSq(xn, yn, zn);
|
||||
if (distanceSq > 1) {
|
||||
if (z == 0) {
|
||||
if (y == 0) {
|
||||
if(distanceSq > 1) {
|
||||
if(z == 0) {
|
||||
if(y == 0) {
|
||||
break forX;
|
||||
}
|
||||
break forY;
|
||||
@@ -276,8 +292,8 @@ public class MantleWriter implements IObjectPlacer {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!fill) {
|
||||
if (lengthSq(nextXn, yn, zn) <= 1 && lengthSq(xn, nextYn, zn) <= 1 && lengthSq(xn, yn, nextZn) <= 1) {
|
||||
if(!fill) {
|
||||
if(lengthSq(nextXn, yn, zn) <= 1 && lengthSq(xn, nextYn, zn) <= 1 && lengthSq(xn, yn, nextZn) <= 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@@ -299,21 +315,29 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set a cuboid of data in the mantle
|
||||
*
|
||||
* @param x1 the min x
|
||||
* @param y1 the min y
|
||||
* @param z1 the min z
|
||||
* @param x2 the max x
|
||||
* @param y2 the max y
|
||||
* @param z2 the max z
|
||||
* @param data the data to set
|
||||
* @param <T> the type of data to apply to the mantle
|
||||
* @param x1
|
||||
* the min x
|
||||
* @param y1
|
||||
* the min y
|
||||
* @param z1
|
||||
* the min z
|
||||
* @param x2
|
||||
* the max x
|
||||
* @param y2
|
||||
* the max y
|
||||
* @param z2
|
||||
* the max z
|
||||
* @param data
|
||||
* the data to set
|
||||
* @param <T>
|
||||
* the type of data to apply to the mantle
|
||||
*/
|
||||
public <T> void setCuboid(int x1, int y1, int z1, int x2, int y2, int z2, T data) {
|
||||
int j, k;
|
||||
|
||||
for (int i = x1; i <= x2; i++) {
|
||||
for (j = x1; j <= x2; j++) {
|
||||
for (k = x1; k <= x2; k++) {
|
||||
for(int i = x1; i <= x2; i++) {
|
||||
for(j = x1; j <= x2; j++) {
|
||||
for(k = x1; k <= x2; k++) {
|
||||
setData(i, j, k, data);
|
||||
}
|
||||
}
|
||||
@@ -323,23 +347,30 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set a pyramid of data in the mantle
|
||||
*
|
||||
* @param cx the center x
|
||||
* @param cy the base y
|
||||
* @param cz the center z
|
||||
* @param data the data to set
|
||||
* @param size the size of the pyramid (width of base & height)
|
||||
* @param filled should it be filled or hollow
|
||||
* @param <T> the type of data to apply to the mantle
|
||||
* @param cx
|
||||
* the center x
|
||||
* @param cy
|
||||
* the base y
|
||||
* @param cz
|
||||
* the center z
|
||||
* @param data
|
||||
* the data to set
|
||||
* @param size
|
||||
* the size of the pyramid (width of base & height)
|
||||
* @param filled
|
||||
* should it be filled or hollow
|
||||
* @param <T>
|
||||
* the type of data to apply to the mantle
|
||||
*/
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public <T> void setPyramid(int cx, int cy, int cz, T data, int size, boolean filled) {
|
||||
int height = size;
|
||||
|
||||
for (int y = 0; y <= height; ++y) {
|
||||
for(int y = 0; y <= height; ++y) {
|
||||
size--;
|
||||
for (int x = 0; x <= size; ++x) {
|
||||
for (int z = 0; z <= size; ++z) {
|
||||
if ((filled && z <= size && x <= size) || z == size || x == size) {
|
||||
for(int x = 0; x <= size; ++x) {
|
||||
for(int z = 0; z <= size; ++z) {
|
||||
if((filled && z <= size && x <= size) || z == size || x == size) {
|
||||
setData(x + cx, y + cy, z + cz, data);
|
||||
setData(-x + cx, y + cy, z + cz, data);
|
||||
setData(x + cx, y + cy, -z + cz, data);
|
||||
@@ -353,12 +384,18 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set a 3d line
|
||||
*
|
||||
* @param a the first point
|
||||
* @param b the second point
|
||||
* @param radius the radius
|
||||
* @param filled hollow or filled?
|
||||
* @param data the data
|
||||
* @param <T> the type of data to apply to the mantle
|
||||
* @param a
|
||||
* the first point
|
||||
* @param b
|
||||
* the second point
|
||||
* @param radius
|
||||
* the radius
|
||||
* @param filled
|
||||
* hollow or filled?
|
||||
* @param data
|
||||
* the data
|
||||
* @param <T>
|
||||
* the type of data to apply to the mantle
|
||||
*/
|
||||
public <T> void setLine(IrisPosition a, IrisPosition b, double radius, boolean filled, T data) {
|
||||
setLine(ImmutableList.of(a, b), radius, filled, data);
|
||||
@@ -371,16 +408,21 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set lines for points
|
||||
*
|
||||
* @param vectors the points
|
||||
* @param radius the radius
|
||||
* @param filled hollow or filled?
|
||||
* @param data the data to set
|
||||
* @param <T> the type of data to apply to the mantle
|
||||
* @param vectors
|
||||
* the points
|
||||
* @param radius
|
||||
* the radius
|
||||
* @param filled
|
||||
* hollow or filled?
|
||||
* @param data
|
||||
* the data to set
|
||||
* @param <T>
|
||||
* the type of data to apply to the mantle
|
||||
*/
|
||||
public <T> void setLineConsumer(List<IrisPosition> vectors, double radius, boolean filled, Function3<Integer, Integer, Integer, T> data) {
|
||||
Set<IrisPosition> vset = new KSet<>();
|
||||
|
||||
for (int i = 0; vectors.size() != 0 && i < vectors.size() - 1; i++) {
|
||||
for(int i = 0; vectors.size() != 0 && i < vectors.size() - 1; i++) {
|
||||
IrisPosition pos1 = vectors.get(i);
|
||||
IrisPosition pos2 = vectors.get(i + 1);
|
||||
int x1 = pos1.getX();
|
||||
@@ -396,22 +438,22 @@ public class MantleWriter implements IObjectPlacer {
|
||||
int dy = Math.abs(y2 - y1);
|
||||
int dz = Math.abs(z2 - z1);
|
||||
|
||||
if (dx + dy + dz == 0) {
|
||||
if(dx + dy + dz == 0) {
|
||||
vset.add(new IrisPosition(tipx, tipy, tipz));
|
||||
continue;
|
||||
}
|
||||
|
||||
int dMax = Math.max(Math.max(dx, dy), dz);
|
||||
if (dMax == dx) {
|
||||
for (int domstep = 0; domstep <= dx; domstep++) {
|
||||
if(dMax == dx) {
|
||||
for(int domstep = 0; domstep <= dx; domstep++) {
|
||||
tipx = x1 + domstep * (x2 - x1 > 0 ? 1 : -1);
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dx) * (y2 - y1 > 0 ? 1 : -1));
|
||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dx) * (z2 - z1 > 0 ? 1 : -1));
|
||||
|
||||
vset.add(new IrisPosition(tipx, tipy, tipz));
|
||||
}
|
||||
} else if (dMax == dy) {
|
||||
for (int domstep = 0; domstep <= dy; domstep++) {
|
||||
} else if(dMax == dy) {
|
||||
for(int domstep = 0; domstep <= dy; domstep++) {
|
||||
tipy = y1 + domstep * (y2 - y1 > 0 ? 1 : -1);
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dy) * (x2 - x1 > 0 ? 1 : -1));
|
||||
tipz = (int) Math.round(z1 + domstep * ((double) dz) / ((double) dy) * (z2 - z1 > 0 ? 1 : -1));
|
||||
@@ -419,7 +461,7 @@ public class MantleWriter implements IObjectPlacer {
|
||||
vset.add(new IrisPosition(tipx, tipy, tipz));
|
||||
}
|
||||
} else /* if (dMax == dz) */ {
|
||||
for (int domstep = 0; domstep <= dz; domstep++) {
|
||||
for(int domstep = 0; domstep <= dz; domstep++) {
|
||||
tipz = z1 + domstep * (z2 - z1 > 0 ? 1 : -1);
|
||||
tipy = (int) Math.round(y1 + domstep * ((double) dy) / ((double) dz) * (y2 - y1 > 0 ? 1 : -1));
|
||||
tipx = (int) Math.round(x1 + domstep * ((double) dx) / ((double) dz) * (x2 - x1 > 0 ? 1 : -1));
|
||||
@@ -431,7 +473,7 @@ public class MantleWriter implements IObjectPlacer {
|
||||
|
||||
vset = getBallooned(vset, radius);
|
||||
|
||||
if (!filled) {
|
||||
if(!filled) {
|
||||
vset = getHollowed(vset);
|
||||
}
|
||||
|
||||
@@ -441,13 +483,20 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set a cylinder in the mantle
|
||||
*
|
||||
* @param cx the center x
|
||||
* @param cy the base y
|
||||
* @param cz the center z
|
||||
* @param data the data to set
|
||||
* @param radius the radius
|
||||
* @param height the height of the cyl
|
||||
* @param filled filled or not
|
||||
* @param cx
|
||||
* the center x
|
||||
* @param cy
|
||||
* the base y
|
||||
* @param cz
|
||||
* the center z
|
||||
* @param data
|
||||
* the data to set
|
||||
* @param radius
|
||||
* the radius
|
||||
* @param height
|
||||
* the height of the cyl
|
||||
* @param filled
|
||||
* filled or not
|
||||
*/
|
||||
public <T> void setCylinder(int cx, int cy, int cz, T data, double radius, int height, boolean filled) {
|
||||
setCylinder(cx, cy, cz, data, radius, radius, height, filled);
|
||||
@@ -456,30 +505,38 @@ public class MantleWriter implements IObjectPlacer {
|
||||
/**
|
||||
* Set a cylinder in the mantle
|
||||
*
|
||||
* @param cx the center x
|
||||
* @param cy the base y
|
||||
* @param cz the center z
|
||||
* @param data the data to set
|
||||
* @param radiusX the x radius
|
||||
* @param radiusZ the z radius
|
||||
* @param height the height of this cyl
|
||||
* @param filled filled or hollow?
|
||||
* @param cx
|
||||
* the center x
|
||||
* @param cy
|
||||
* the base y
|
||||
* @param cz
|
||||
* the center z
|
||||
* @param data
|
||||
* the data to set
|
||||
* @param radiusX
|
||||
* the x radius
|
||||
* @param radiusZ
|
||||
* the z radius
|
||||
* @param height
|
||||
* the height of this cyl
|
||||
* @param filled
|
||||
* filled or hollow?
|
||||
*/
|
||||
public <T> void setCylinder(int cx, int cy, int cz, T data, double radiusX, double radiusZ, int height, boolean filled) {
|
||||
int affected = 0;
|
||||
radiusX += 0.5;
|
||||
radiusZ += 0.5;
|
||||
|
||||
if (height == 0) {
|
||||
if(height == 0) {
|
||||
return;
|
||||
} else if (height < 0) {
|
||||
} else if(height < 0) {
|
||||
height = -height;
|
||||
cy = cy - height;
|
||||
}
|
||||
|
||||
if (cy < 0) {
|
||||
if(cy < 0) {
|
||||
cy = 0;
|
||||
} else if (cy + height - 1 > getMantle().getWorldHeight()) {
|
||||
} else if(cy + height - 1 > getMantle().getWorldHeight()) {
|
||||
height = getMantle().getWorldHeight() - cy + 1;
|
||||
}
|
||||
|
||||
@@ -490,30 +547,30 @@ public class MantleWriter implements IObjectPlacer {
|
||||
double nextXn = 0;
|
||||
|
||||
forX:
|
||||
for (int x = 0; x <= ceilRadiusX; ++x) {
|
||||
for(int x = 0; x <= ceilRadiusX; ++x) {
|
||||
final double xn = nextXn;
|
||||
nextXn = (x + 1) * invRadiusX;
|
||||
double nextZn = 0;
|
||||
for (int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
for(int z = 0; z <= ceilRadiusZ; ++z) {
|
||||
final double zn = nextZn;
|
||||
nextZn = (z + 1) * invRadiusZ;
|
||||
double distanceSq = lengthSq(xn, zn);
|
||||
|
||||
if (distanceSq > 1) {
|
||||
if (z == 0) {
|
||||
if(distanceSq > 1) {
|
||||
if(z == 0) {
|
||||
break forX;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
if (!filled) {
|
||||
if (lengthSq(nextXn, zn) <= 1 && lengthSq(xn, nextZn) <= 1) {
|
||||
if(!filled) {
|
||||
if(lengthSq(nextXn, zn) <= 1 && lengthSq(xn, nextZn) <= 1) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
for (int y = 0; y < height; ++y) {
|
||||
for(int y = 0; y < height; ++y) {
|
||||
setData(cx + x, cy + y, cz + z, data);
|
||||
setData(cx + -x, cy + y, cz + z, data);
|
||||
setData(cx + x, cy + y, cz + -z, data);
|
||||
@@ -524,31 +581,27 @@ public class MantleWriter implements IObjectPlacer {
|
||||
}
|
||||
|
||||
public <T> void set(IrisPosition pos, T data) {
|
||||
try
|
||||
{
|
||||
try {
|
||||
setData(pos.getX(), pos.getY(), pos.getZ(), data);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
} catch(Throwable e) {
|
||||
Iris.error("No set? " + data.toString() + " for " + pos.toString());
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void set(List<IrisPosition> positions, T data) {
|
||||
for (IrisPosition i : positions) {
|
||||
for(IrisPosition i : positions) {
|
||||
set(i, data);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void set(Set<IrisPosition> positions, T data) {
|
||||
for (IrisPosition i : positions) {
|
||||
for(IrisPosition i : positions) {
|
||||
set(i, data);
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void setConsumer(Set<IrisPosition> positions, Function3<Integer, Integer, Integer, T> data) {
|
||||
for (IrisPosition i : positions) {
|
||||
for(IrisPosition i : positions) {
|
||||
set(i, data.apply(i.getX(), i.getY(), i.getZ()));
|
||||
}
|
||||
}
|
||||
@@ -561,11 +614,11 @@ public class MantleWriter implements IObjectPlacer {
|
||||
int cx = x >> 4;
|
||||
int cz = z >> 4;
|
||||
|
||||
if (y < 0 || y >= mantle.getWorldHeight()) {
|
||||
if(y < 0 || y >= mantle.getWorldHeight()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return cx >= this.x - radius && cx <= this.x + radius
|
||||
&& cz >= this.z - radius && cz <= this.z + radius;
|
||||
&& cz >= this.z - radius && cz <= this.z + radius;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,12 +59,12 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
private void generateJigsaw(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region) {
|
||||
boolean placed = false;
|
||||
|
||||
if (getDimension().getStronghold() != null) {
|
||||
if(getDimension().getStronghold() != null) {
|
||||
List<Position2> poss = getDimension().getStrongholds(seed());
|
||||
|
||||
if (poss != null) {
|
||||
for (Position2 pos : poss) {
|
||||
if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) {
|
||||
if(poss != null) {
|
||||
for(Position2 pos : poss) {
|
||||
if(x == pos.getX() >> 4 && z == pos.getZ() >> 4) {
|
||||
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getDimension().getStronghold());
|
||||
place(writer, pos.toIris(), structure, rng);
|
||||
placed = true;
|
||||
@@ -73,9 +73,9 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
}
|
||||
}
|
||||
|
||||
if (!placed) {
|
||||
for (IrisJigsawStructurePlacement i : biome.getJigsawStructures()) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
if(!placed) {
|
||||
for(IrisJigsawStructurePlacement i : biome.getJigsawStructures()) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
|
||||
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
|
||||
place(writer, position, structure, rng);
|
||||
@@ -84,9 +84,9 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
}
|
||||
}
|
||||
|
||||
if (!placed) {
|
||||
for (IrisJigsawStructurePlacement i : region.getJigsawStructures()) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
if(!placed) {
|
||||
for(IrisJigsawStructurePlacement i : region.getJigsawStructures()) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
|
||||
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
|
||||
place(writer, position, structure, rng);
|
||||
@@ -95,9 +95,9 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
}
|
||||
}
|
||||
|
||||
if (!placed) {
|
||||
for (IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
if(!placed) {
|
||||
for(IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15));
|
||||
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
|
||||
place(writer, position, structure, rng);
|
||||
@@ -112,32 +112,32 @@ public class MantleJigsawComponent extends IrisMantleComponent {
|
||||
IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8);
|
||||
IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8);
|
||||
|
||||
if (getDimension().getStronghold() != null) {
|
||||
if(getDimension().getStronghold() != null) {
|
||||
List<Position2> poss = getDimension().getStrongholds(seed());
|
||||
|
||||
if (poss != null) {
|
||||
for (Position2 pos : poss) {
|
||||
if (x == pos.getX() >> 4 && z == pos.getZ() >> 4) {
|
||||
if(poss != null) {
|
||||
for(Position2 pos : poss) {
|
||||
if(x == pos.getX() >> 4 && z == pos.getZ() >> 4) {
|
||||
return getData().getJigsawStructureLoader().load(getDimension().getStronghold());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisJigsawStructurePlacement i : biome.getJigsawStructures()) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
for(IrisJigsawStructurePlacement i : biome.getJigsawStructures()) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
return getData().getJigsawStructureLoader().load(i.getStructure());
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisJigsawStructurePlacement i : region.getJigsawStructures()) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
for(IrisJigsawStructurePlacement i : region.getJigsawStructures()) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
return getData().getJigsawStructureLoader().load(i.getStructure());
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
for(IrisJigsawStructurePlacement i : getDimension().getJigsawStructures()) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
return getData().getJigsawStructureLoader().load(i.getStructure());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,12 +54,12 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
private void placeObjects(MantleWriter writer, RNG rng, int x, int z, IrisBiome biome, IrisRegion region) {
|
||||
long s = Cache.key(x, z) + seed();
|
||||
RNG rnp = new RNG(s);
|
||||
for (IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
||||
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
for(IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
||||
if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
try {
|
||||
placeObject(writer, rnp, x << 4, z << 4, i);
|
||||
rnp.setSeed(s);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("Failed to place objects in the following biome: " + biome.getName());
|
||||
Iris.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
|
||||
@@ -69,12 +69,12 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement i : region.getSurfaceObjects()) {
|
||||
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
for(IrisObjectPlacement i : region.getSurfaceObjects()) {
|
||||
if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
try {
|
||||
placeObject(writer, rnp, x << 4, z << 4, i);
|
||||
rnp.setSeed(s);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("Failed to place objects in the following region: " + region.getName());
|
||||
Iris.error("Object(s) " + i.getPlace().toString(", ") + " (" + e.getClass().getSimpleName() + ").");
|
||||
@@ -87,26 +87,26 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
|
||||
@BlockCoordinates
|
||||
private void placeObject(MantleWriter writer, RNG rng, int x, int z, IrisObjectPlacement objectPlacement) {
|
||||
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
||||
for(int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
||||
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng));
|
||||
if (v == null) {
|
||||
if(v == null) {
|
||||
return;
|
||||
}
|
||||
int xx = rng.i(x, x + 15);
|
||||
int zz = rng.i(z, z + 15);
|
||||
int id = rng.i(0, Integer.MAX_VALUE);
|
||||
v.place(xx, -1, zz, writer, objectPlacement, rng,
|
||||
getMantle().shouldReduce(getEngineMantle().getEngine()) ? null : (b) -> writer.setData(b.getX(), b.getY(), b.getZ(),
|
||||
v.getLoadKey() + "@" + id), null, getData());
|
||||
getMantle().shouldReduce(getEngineMantle().getEngine()) ? null : (b) -> writer.setData(b.getX(), b.getY(), b.getZ(),
|
||||
v.getLoadKey() + "@" + id), null, getData());
|
||||
}
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
private Set<String> guessPlacedKeys(RNG rng, int x, int z, IrisObjectPlacement objectPlacement) {
|
||||
Set<String> f = new KSet<>();
|
||||
for (int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
||||
for(int i = 0; i < objectPlacement.getDensity(rng, x, z, getData()); i++) {
|
||||
IrisObject v = objectPlacement.getScale().get(rng, objectPlacement.getObject(getComplex(), rng));
|
||||
if (v == null) {
|
||||
if(v == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -123,15 +123,15 @@ public class MantleObjectComponent extends IrisMantleComponent {
|
||||
IrisBiome biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8);
|
||||
IrisRegion region = getEngineMantle().getEngine().getRegion((x << 4) + 8, (z << 4) + 8);
|
||||
Set<String> v = new KSet<>();
|
||||
for (IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
||||
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
for(IrisObjectPlacement i : biome.getSurfaceObjects()) {
|
||||
if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
v.addAll(guessPlacedKeys(rngd, x, z, i));
|
||||
rngd.setSeed(s);
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisObjectPlacement i : region.getSurfaceObjects()) {
|
||||
if (rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
for(IrisObjectPlacement i : region.getSurfaceObjects()) {
|
||||
if(rng.chance(i.getChance() + rng.d(-0.005, 0.005))) {
|
||||
v.addAll(guessPlacedKeys(rngd, x, z, i));
|
||||
rngd.setSeed(s);
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ModeEnclosure extends IrisEngineMode implements EngineMode {
|
||||
var biome = new IrisBiomeActuator(getEngine());
|
||||
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ModeIslands extends IrisEngineMode implements EngineMode {
|
||||
var biome = new IrisBiomeActuator(getEngine());
|
||||
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,9 +43,9 @@ public class ModeOverworld extends IrisEngineMode implements EngineMode {
|
||||
var perfection = new IrisPerfectionModifier(getEngine());
|
||||
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m),
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
(x, z, k, p, m) -> generateMatter(x >> 4, z >> 4, m),
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
));
|
||||
registerStage((x, z, k, p, m) -> cave.modify(x >> 4, z >> 4, k, m));
|
||||
registerStage((x, z, k, p, m) -> deposit.modify(x, z, k, m));
|
||||
|
||||
@@ -31,8 +31,8 @@ public class ModeSuperFlat extends IrisEngineMode implements EngineMode {
|
||||
var biome = new IrisBiomeActuator(getEngine());
|
||||
|
||||
registerStage(burst(
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
(x, z, k, p, m) -> terrain.actuate(x, z, k, m),
|
||||
(x, z, k, p, m) -> biome.actuate(x, z, p, m)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,11 +64,11 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
KMap<Long, KList<Integer>> positions = new KMap<>();
|
||||
KMap<IrisPosition, MatterCavern> walls = new KMap<>();
|
||||
Consumer4<Integer, Integer, Integer, MatterCavern> iterator = (xx, yy, zz, c) -> {
|
||||
if (c == null) {
|
||||
if(c == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (yy >= 256 || yy <= 0) { // Yes, skip bedrock
|
||||
if(yy >= 256 || yy <= 0) { // Yes, skip bedrock
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
BlockData current = output.get(rx, yy, rz);
|
||||
|
||||
if (B.isFluid(current)) {
|
||||
if(B.isFluid(current)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -85,29 +85,29 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
//todo: Fix chunk decoration not working on chunk's border
|
||||
|
||||
if (rz < 15 && mantle.get(xx, yy, zz + 1, MatterCavern.class) == null) {
|
||||
if(rz < 15 && mantle.get(xx, yy, zz + 1, MatterCavern.class) == null) {
|
||||
walls.put(new IrisPosition(rx, yy, rz + 1), c);
|
||||
}
|
||||
|
||||
if (rx < 15 && mantle.get(xx + 1, yy, zz, MatterCavern.class) == null) {
|
||||
if(rx < 15 && mantle.get(xx + 1, yy, zz, MatterCavern.class) == null) {
|
||||
walls.put(new IrisPosition(rx + 1, yy, rz), c);
|
||||
}
|
||||
|
||||
if (rz > 0 && mantle.get(xx, yy, zz - 1, MatterCavern.class) == null) {
|
||||
if(rz > 0 && mantle.get(xx, yy, zz - 1, MatterCavern.class) == null) {
|
||||
walls.put(new IrisPosition(rx, yy, rz - 1), c);
|
||||
}
|
||||
|
||||
if (rx > 0 && mantle.get(xx - 1, yy, zz, MatterCavern.class) == null) {
|
||||
if(rx > 0 && mantle.get(xx - 1, yy, zz, MatterCavern.class) == null) {
|
||||
walls.put(new IrisPosition(rx - 1, yy, rz), c);
|
||||
}
|
||||
|
||||
if (current.getMaterial().isAir()) {
|
||||
if(current.getMaterial().isAir()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (c.isWater()) {
|
||||
if(c.isWater()) {
|
||||
output.set(rx, yy, rz, WATER);
|
||||
} else if (c.isLava()) {
|
||||
} else if(c.isLava()) {
|
||||
output.set(rx, yy, rz, LAVA);
|
||||
} else {
|
||||
output.set(rx, yy, rz, AIR);
|
||||
@@ -118,21 +118,21 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
walls.forEach((i, v) -> {
|
||||
IrisBiome biome = v.getCustomBiome().isEmpty()
|
||||
? getEngine().getCaveBiome(i.getX() + (x << 4), i.getZ() + (z << 4))
|
||||
: getEngine().getData().getBiomeLoader().load(v.getCustomBiome());
|
||||
? getEngine().getCaveBiome(i.getX() + (x << 4), i.getZ() + (z << 4))
|
||||
: getEngine().getData().getBiomeLoader().load(v.getCustomBiome());
|
||||
|
||||
if (biome != null) {
|
||||
if(biome != null) {
|
||||
biome.setInferredType(InferredType.CAVE);
|
||||
BlockData d = biome.getWall().get(rng, i.getX() + (x << 4), i.getY(), i.getZ() + (z << 4), getData());
|
||||
|
||||
if (d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= getComplex().getHeightStream().get(i.getX() + (x << 4), i.getZ() + (z << 4))) {
|
||||
if(d != null && B.isSolid(output.get(i.getX(), i.getY(), i.getZ())) && i.getY() <= getComplex().getHeightStream().get(i.getX() + (x << 4), i.getZ() + (z << 4))) {
|
||||
output.set(i.getX(), i.getY(), i.getZ(), d);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
positions.forEach((k, v) -> {
|
||||
if (v.isEmpty()) {
|
||||
if(v.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -143,15 +143,15 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
zone.setFloor(v.get(0));
|
||||
int buf = v.get(0) - 1;
|
||||
|
||||
for (Integer i : v) {
|
||||
if (i < 0 || i > 255) {
|
||||
for(Integer i : v) {
|
||||
if(i < 0 || i > 255) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == buf + 1) {
|
||||
if(i == buf + 1) {
|
||||
buf = i;
|
||||
zone.ceiling = buf;
|
||||
} else if (zone.isValid()) {
|
||||
} else if(zone.isValid()) {
|
||||
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||
zone = new CaveZone();
|
||||
zone.setFloor(i);
|
||||
@@ -159,7 +159,7 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
}
|
||||
|
||||
if (zone.isValid()) {
|
||||
if(zone.isValid()) {
|
||||
processZone(output, mc, mantle, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||
}
|
||||
});
|
||||
@@ -174,62 +174,62 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
int thickness = zone.airThickness();
|
||||
String customBiome = "";
|
||||
|
||||
if (B.isDecorant(output.getClosest(rx, zone.ceiling + 1, rz))) {
|
||||
if(B.isDecorant(output.getClosest(rx, zone.ceiling + 1, rz))) {
|
||||
output.set(rx, zone.ceiling + 1, rz, AIR);
|
||||
}
|
||||
|
||||
if (B.isDecorant(output.get(rx, zone.ceiling, rz))) {
|
||||
if(B.isDecorant(output.get(rx, zone.ceiling, rz))) {
|
||||
output.set(rx, zone.ceiling, rz, AIR);
|
||||
}
|
||||
|
||||
if (M.r(1D / 16D)) {
|
||||
if(M.r(1D / 16D)) {
|
||||
mantle.set(xx, zone.ceiling, zz, MarkerMatter.CAVE_CEILING);
|
||||
}
|
||||
|
||||
if (M.r(1D / 16D)) {
|
||||
if(M.r(1D / 16D)) {
|
||||
mantle.set(xx, zone.floor, zz, MarkerMatter.CAVE_FLOOR);
|
||||
}
|
||||
|
||||
for (int i = zone.floor; i <= zone.ceiling; i++) {
|
||||
for(int i = zone.floor; i <= zone.ceiling; i++) {
|
||||
MatterCavern cavernData = (MatterCavern) mc.getOrCreate(i >> 4).slice(MatterCavern.class)
|
||||
.get(rx, i & 15, rz);
|
||||
.get(rx, i & 15, rz);
|
||||
|
||||
if (cavernData != null && !cavernData.getCustomBiome().isEmpty()) {
|
||||
if(cavernData != null && !cavernData.getCustomBiome().isEmpty()) {
|
||||
customBiome = cavernData.getCustomBiome();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome biome = customBiome.isEmpty()
|
||||
? getEngine().getCaveBiome(xx, zz)
|
||||
: getEngine().getData().getBiomeLoader().load(customBiome);
|
||||
? getEngine().getCaveBiome(xx, zz)
|
||||
: getEngine().getData().getBiomeLoader().load(customBiome);
|
||||
|
||||
if (biome == null) {
|
||||
if(biome == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
biome.setInferredType(InferredType.CAVE);
|
||||
|
||||
for (IrisDecorator i : biome.getDecorators()) {
|
||||
if (i.getPartOf().equals(IrisDecorationPart.NONE) && B.isSolid(output.get(rx, zone.getFloor() - 1, rz))) {
|
||||
for(IrisDecorator i : biome.getDecorators()) {
|
||||
if(i.getPartOf().equals(IrisDecorationPart.NONE) && B.isSolid(output.get(rx, zone.getFloor() - 1, rz))) {
|
||||
decorant.getSurfaceDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getFloor() - 1, zone.airThickness());
|
||||
} else if (i.getPartOf().equals(IrisDecorationPart.CEILING) && B.isSolid(output.get(rx, zone.getCeiling() + 1, rz))) {
|
||||
} else if(i.getPartOf().equals(IrisDecorationPart.CEILING) && B.isSolid(output.get(rx, zone.getCeiling() + 1, rz))) {
|
||||
decorant.getCeilingDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getCeiling(), zone.airThickness());
|
||||
}
|
||||
}
|
||||
|
||||
KList<BlockData> blocks = biome.generateLayers(getDimension(), xx, zz, rng, 3, zone.floor, getData(), getComplex());
|
||||
|
||||
for (int i = 0; i < zone.floor - 1; i++) {
|
||||
if (!blocks.hasIndex(i)) {
|
||||
for(int i = 0; i < zone.floor - 1; i++) {
|
||||
if(!blocks.hasIndex(i)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!B.isSolid(output.get(rx, zone.floor - i - 1, rz))) {
|
||||
if(!B.isSolid(output.get(rx, zone.floor - i - 1, rz))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (B.isOre(output.get(rx, zone.floor - i - 1, rz))) {
|
||||
if(B.isOre(output.get(rx, zone.floor - i - 1, rz))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -238,20 +238,20 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
|
||||
blocks = biome.generateCeilingLayers(getDimension(), xx, zz, rng, 3, zone.ceiling, getData(), getComplex());
|
||||
|
||||
if (zone.ceiling + 1 < mantle.getWorldHeight()) {
|
||||
for (int i = 0; i < zone.ceiling + 1; i++) {
|
||||
if (!blocks.hasIndex(i)) {
|
||||
if(zone.ceiling + 1 < mantle.getWorldHeight()) {
|
||||
for(int i = 0; i < zone.ceiling + 1; i++) {
|
||||
if(!blocks.hasIndex(i)) {
|
||||
break;
|
||||
}
|
||||
|
||||
BlockData b = blocks.get(i);
|
||||
BlockData up = output.get(rx, zone.ceiling + i + 1, rz);
|
||||
|
||||
if (!B.isSolid(up)) {
|
||||
if(!B.isSolid(up)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (B.isOre(up)) {
|
||||
if(B.isOre(up)) {
|
||||
output.set(rx, zone.ceiling + i + 1, rz, B.toDeepSlateOre(up, b));
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -54,18 +54,18 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get((x * 16) + 7, (z * 16) + 7);
|
||||
BurstExecutor burst = burst().burst(multicore);
|
||||
|
||||
for (IrisDepositGenerator k : getDimension().getDeposits()) {
|
||||
for(IrisDepositGenerator k : getDimension().getDeposits()) {
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false));
|
||||
}
|
||||
|
||||
for (IrisDepositGenerator k : region.getDeposits()) {
|
||||
for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
for(IrisDepositGenerator k : region.getDeposits()) {
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false));
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisDepositGenerator k : biome.getDeposits()) {
|
||||
for (int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
for(IrisDepositGenerator k : biome.getDeposits()) {
|
||||
for(int l = 0; l < ro.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
burst.queue(() -> generate(k, terrain, ro, x, z, false));
|
||||
}
|
||||
}
|
||||
@@ -77,25 +77,25 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
public void generate(IrisDepositGenerator k, Hunk<BlockData> data, RNG rng, int cx, int cz, boolean safe, HeightMap he) {
|
||||
for (int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
for(int l = 0; l < rng.i(k.getMinPerChunk(), k.getMaxPerChunk()); l++) {
|
||||
IrisObject clump = k.getClump(rng, getData());
|
||||
|
||||
int af = (int) Math.floor(clump.getW() / 2D);
|
||||
int bf = (int) Math.floor(16D - (clump.getW() / 2D));
|
||||
|
||||
if (af > bf || af < 0 || bf > 15 || af > 15 || bf < 0) {
|
||||
if(af > bf || af < 0 || bf > 15 || af > 15 || bf < 0) {
|
||||
af = 6;
|
||||
bf = 9;
|
||||
}
|
||||
|
||||
af = Math.max(af-1, 0);
|
||||
af = Math.max(af - 1, 0);
|
||||
int x = rng.i(af, bf);
|
||||
int z = rng.i(af, bf);
|
||||
int height = (he != null ? he.getHeight((cx << 4) + x, (cz << 4) + z) : (int) (Math.round(
|
||||
getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z)
|
||||
getComplex().getHeightStream().get((cx << 4) + x, (cz << 4) + z)
|
||||
))) - 7;
|
||||
|
||||
if (height <= 0) {
|
||||
if(height <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -103,26 +103,26 @@ public class IrisDepositModifier extends EngineAssignedModifier<BlockData> {
|
||||
// TODO: WARNING HEIGHT
|
||||
int a = Math.min(height, Math.min(256, k.getMaxHeight()));
|
||||
|
||||
if (i >= a) {
|
||||
if(i >= a) {
|
||||
return;
|
||||
}
|
||||
|
||||
int h = rng.i(i, a);
|
||||
|
||||
if (h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2) {
|
||||
if(h > k.getMaxHeight() || h < k.getMinHeight() || h > height - 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (BlockVector j : clump.getBlocks().keySet()) {
|
||||
for(BlockVector j : clump.getBlocks().keySet()) {
|
||||
int nx = j.getBlockX() + x;
|
||||
int ny = j.getBlockY() + h;
|
||||
int nz = j.getBlockZ() + z;
|
||||
|
||||
if (ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) {
|
||||
if(ny > height || nx > 15 || nx < 0 || ny > 255 || ny < 0 || nz < 0 || nz > 15) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!getEngine().getMantle().isCarved((cx << 4) + nx, ny, (cz << 4) + nz)) {
|
||||
if(!getEngine().getMantle().isCarved((cx << 4) + nx, ny, (cz << 4) + nz)) {
|
||||
data.set(nx, ny, nz, B.toDeepSlateOre(data.get(nx, ny, nz), clump.getBlocks().get(j)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,27 +49,27 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<BlockData> {
|
||||
List<Integer> surfaces = new ArrayList<>();
|
||||
List<Integer> ceilings = new ArrayList<>();
|
||||
BurstExecutor burst = burst().burst(multicore);
|
||||
while (changed.get()) {
|
||||
while(changed.get()) {
|
||||
passes++;
|
||||
changed.set(false);
|
||||
for (int i = 0; i < 16; i++) {
|
||||
for(int i = 0; i < 16; i++) {
|
||||
int finalI = i;
|
||||
burst.queue(() -> {
|
||||
for (int j = 0; j < 16; j++) {
|
||||
for(int j = 0; j < 16; j++) {
|
||||
surfaces.clear();
|
||||
ceilings.clear();
|
||||
int top = getHeight(output, finalI, j);
|
||||
boolean inside = true;
|
||||
surfaces.add(top);
|
||||
|
||||
for (int k = top; k >= 0; k--) {
|
||||
for(int k = top; k >= 0; k--) {
|
||||
BlockData b = output.get(finalI, k, j);
|
||||
boolean now = b != null && !(B.isAir(b) || B.isFluid(b));
|
||||
|
||||
if (now != inside) {
|
||||
if(now != inside) {
|
||||
inside = now;
|
||||
|
||||
if (inside) {
|
||||
if(inside) {
|
||||
surfaces.add(k);
|
||||
} else {
|
||||
ceilings.add(k + 1);
|
||||
@@ -77,37 +77,37 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
}
|
||||
|
||||
for (int k : surfaces) {
|
||||
for(int k : surfaces) {
|
||||
BlockData tip = output.get(finalI, k, j);
|
||||
|
||||
if (tip == null) {
|
||||
if(tip == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
boolean remove = false;
|
||||
boolean remove2 = false;
|
||||
|
||||
if (B.isDecorant(tip)) {
|
||||
if(B.isDecorant(tip)) {
|
||||
BlockData bel = output.get(finalI, k - 1, j);
|
||||
|
||||
if (bel == null) {
|
||||
if(bel == null) {
|
||||
remove = true;
|
||||
} else if (!B.canPlaceOnto(tip.getMaterial(), bel.getMaterial())) {
|
||||
} else if(!B.canPlaceOnto(tip.getMaterial(), bel.getMaterial())) {
|
||||
remove = true;
|
||||
} else if (bel instanceof Bisected) {
|
||||
} else if(bel instanceof Bisected) {
|
||||
BlockData bb = output.get(finalI, k - 2, j);
|
||||
if (bb == null || !B.canPlaceOnto(bel.getMaterial(), bb.getMaterial())) {
|
||||
if(bb == null || !B.canPlaceOnto(bel.getMaterial(), bb.getMaterial())) {
|
||||
remove = true;
|
||||
remove2 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (remove) {
|
||||
if(remove) {
|
||||
changed.set(true);
|
||||
changes.getAndIncrement();
|
||||
output.set(finalI, k, j, AIR);
|
||||
|
||||
if (remove2) {
|
||||
if(remove2) {
|
||||
changes.getAndIncrement();
|
||||
output.set(finalI, k - 1, j, AIR);
|
||||
}
|
||||
@@ -123,10 +123,10 @@ public class IrisPerfectionModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
private int getHeight(Hunk<BlockData> output, int x, int z) {
|
||||
for (int i = output.getHeight() - 1; i >= 0; i--) {
|
||||
for(int i = output.getHeight() - 1; i >= 0; i--) {
|
||||
BlockData b = output.get(x, i, z);
|
||||
|
||||
if (b != null && !B.isAir(b) && !B.isFluid(b)) {
|
||||
if(b != null && !B.isAir(b) && !B.isFluid(b)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
AtomicInteger i = new AtomicInteger();
|
||||
AtomicInteger j = new AtomicInteger();
|
||||
Hunk<BlockData> sync = output.synchronize();
|
||||
for (i.set(0); i.get() < output.getWidth(); i.getAndIncrement()) {
|
||||
for (j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) {
|
||||
for(i.set(0); i.get() < output.getWidth(); i.getAndIncrement()) {
|
||||
for(j.set(0); j.get() < output.getDepth(); j.getAndIncrement()) {
|
||||
int ii = i.get();
|
||||
int jj = j.get();
|
||||
post(ii, jj, sync, ii + x, jj + z);
|
||||
@@ -71,7 +71,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Floating Nibs
|
||||
int g = 0;
|
||||
|
||||
if (h < 1) {
|
||||
if(h < 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -80,11 +80,11 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += hc < h - 1 ? 1 : 0;
|
||||
g += hd < h - 1 ? 1 : 0;
|
||||
|
||||
if (g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData)) {
|
||||
if(g == 4 && isAir(x, h - 1, z, currentPostX, currentPostZ, currentData)) {
|
||||
setPostBlock(x, h, z, AIR, currentPostX, currentPostZ, currentData);
|
||||
|
||||
for (int i = h - 1; i > 0; i--) {
|
||||
if (!isAir(x, i, z, currentPostX, currentPostZ, currentData)) {
|
||||
for(int i = h - 1; i > 0; i--) {
|
||||
if(!isAir(x, i, z, currentPostX, currentPostZ, currentData)) {
|
||||
h = i;
|
||||
break;
|
||||
}
|
||||
@@ -98,13 +98,13 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += hc == h - 1 ? 1 : 0;
|
||||
g += hd == h - 1 ? 1 : 0;
|
||||
|
||||
if (g >= 4) {
|
||||
if(g >= 4) {
|
||||
BlockData bc = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
|
||||
Material m = bc.getMaterial();
|
||||
|
||||
if ((b.getMaterial().isOccluding() && b.getMaterial().isSolid())) {
|
||||
if (m.isSolid()) {
|
||||
if((b.getMaterial().isOccluding() && b.getMaterial().isSolid())) {
|
||||
if(m.isSolid()) {
|
||||
setPostBlock(x, h, z, b, currentPostX, currentPostZ, currentData);
|
||||
h--;
|
||||
}
|
||||
@@ -117,7 +117,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g += hc == h + 1 ? 1 : 0;
|
||||
g += hd == h + 1 ? 1 : 0;
|
||||
|
||||
if (g >= 4) {
|
||||
if(g >= 4) {
|
||||
BlockData ba = getPostBlock(x, ha, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bb = getPostBlock(x, hb, z, currentPostX, currentPostZ, currentData);
|
||||
BlockData bc = getPostBlock(x, hc, z, currentPostX, currentPostZ, currentData);
|
||||
@@ -128,7 +128,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
g = B.isSolid(bc) ? g + 1 : g;
|
||||
g = B.isSolid(bd) ? g + 1 : g;
|
||||
|
||||
if (g >= 3) {
|
||||
if(g >= 3) {
|
||||
setPostBlock(x, h + 1, z, getPostBlock(x, h, z, currentPostX, currentPostZ, currentData), currentPostX, currentPostZ, currentData);
|
||||
h++;
|
||||
}
|
||||
@@ -138,18 +138,18 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Wall Patcher
|
||||
IrisBiome biome = getComplex().getTrueBiomeStream().get(x, z);
|
||||
|
||||
if (getDimension().isPostProcessingWalls()) {
|
||||
if (!biome.getWall().getPalette().isEmpty()) {
|
||||
if (ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) {
|
||||
if(getDimension().isPostProcessingWalls()) {
|
||||
if(!biome.getWall().getPalette().isEmpty()) {
|
||||
if(ha < h - 2 || hb < h - 2 || hc < h - 2 || hd < h - 2) {
|
||||
boolean brokeGround = false;
|
||||
int max = Math.abs(Math.max(h - ha, Math.max(h - hb, Math.max(h - hc, h - hd))));
|
||||
|
||||
for (int i = h; i > h - max; i--) {
|
||||
for(int i = h; i > h - max; i--) {
|
||||
BlockData d = biome.getWall().get(rng, x + i, i + h, z + i, getData());
|
||||
|
||||
if (d != null) {
|
||||
if (isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) {
|
||||
if (brokeGround) {
|
||||
if(d != null) {
|
||||
if(isAirOrWater(x, i, z, currentPostX, currentPostZ, currentData)) {
|
||||
if(brokeGround) {
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -165,28 +165,28 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
// Slab
|
||||
if (getDimension().isPostProcessingSlabs()) {
|
||||
if(getDimension().isPostProcessingSlabs()) {
|
||||
//@builder
|
||||
if ((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData))
|
||||
|| (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData))
|
||||
|| (hc == h + 1 && isSolidNonSlab(x - 1, hc, z, currentPostX, currentPostZ, currentData))
|
||||
|| (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
if((ha == h + 1 && isSolidNonSlab(x + 1, ha, z, currentPostX, currentPostZ, currentData))
|
||||
|| (hb == h + 1 && isSolidNonSlab(x, hb, z + 1, currentPostX, currentPostZ, currentData))
|
||||
|| (hc == h + 1 && isSolidNonSlab(x - 1, hc, z, currentPostX, currentPostZ, currentData))
|
||||
|| (hd == h + 1 && isSolidNonSlab(x, hd, z - 1, currentPostX, currentPostZ, currentData)))
|
||||
//@done
|
||||
{
|
||||
BlockData d = biome.getSlab().get(rng, x, h, z, getData());
|
||||
|
||||
if (d != null) {
|
||||
if(d != null) {
|
||||
boolean cancel = B.isAir(d);
|
||||
|
||||
if (d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight()) {
|
||||
if(d.getMaterial().equals(Material.SNOW) && h + 1 <= getDimension().getFluidHeight()) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) {
|
||||
if(isSnowLayer(x, h, z, currentPostX, currentPostZ, currentData)) {
|
||||
cancel = true;
|
||||
}
|
||||
|
||||
if (!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData)) {
|
||||
if(!cancel && isAirOrWater(x, h + 1, z, currentPostX, currentPostZ, currentData)) {
|
||||
setPostBlock(x, h + 1, z, d, currentPostX, currentPostZ, currentData);
|
||||
h++;
|
||||
}
|
||||
@@ -197,24 +197,24 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Waterlogging
|
||||
BlockData b = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData);
|
||||
|
||||
if (b instanceof Waterlogged) {
|
||||
if(b instanceof Waterlogged) {
|
||||
Waterlogged ww = (Waterlogged) b.clone();
|
||||
boolean w = false;
|
||||
|
||||
if (h <= getDimension().getFluidHeight() + 1) {
|
||||
if (isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData)) {
|
||||
if(h <= getDimension().getFluidHeight() + 1) {
|
||||
if(isWaterOrWaterlogged(x, h + 1, z, currentPostX, currentPostZ, currentData)) {
|
||||
w = true;
|
||||
} else if ((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) {
|
||||
} else if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) {
|
||||
w = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (w != ww.isWaterlogged()) {
|
||||
if(w != ww.isWaterlogged()) {
|
||||
ww.setWaterlogged(w);
|
||||
setPostBlock(x, h, z, ww, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
} else if (b.getMaterial().equals(Material.AIR) && h <= getDimension().getFluidHeight()) {
|
||||
if ((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) {
|
||||
} else if(b.getMaterial().equals(Material.AIR) && h <= getDimension().getFluidHeight()) {
|
||||
if((isWaterOrWaterlogged(x + 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x - 1, h, z, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z + 1, currentPostX, currentPostZ, currentData) || isWaterOrWaterlogged(x, h, z - 1, currentPostX, currentPostZ, currentData))) {
|
||||
setPostBlock(x, h, z, WATER, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
@@ -222,10 +222,10 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
// Foliage
|
||||
b = getPostBlock(x, h + 1, z, currentPostX, currentPostZ, currentData);
|
||||
|
||||
if (B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) {
|
||||
if(B.isFoliage(b) || b.getMaterial().equals(Material.DEAD_BUSH)) {
|
||||
Material onto = getPostBlock(x, h, z, currentPostX, currentPostZ, currentData).getMaterial();
|
||||
|
||||
if (!B.canPlaceOnto(b.getMaterial(), onto)) {
|
||||
if(!B.canPlaceOnto(b.getMaterial(), onto)) {
|
||||
setPostBlock(x, h + 1, z, AIR, currentPostX, currentPostZ, currentData);
|
||||
}
|
||||
}
|
||||
@@ -282,7 +282,7 @@ public class IrisPostModifier extends EngineAssignedModifier<BlockData> {
|
||||
}
|
||||
|
||||
public void setPostBlock(int x, int y, int z, BlockData d, int currentPostX, int currentPostZ, Hunk<BlockData> currentData) {
|
||||
if (y < currentData.getHeight()) {
|
||||
if(y < currentData.getHeight()) {
|
||||
currentData.set(x & 15, y, z & 15, d);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -50,24 +50,24 @@ public class HeadlessWorld {
|
||||
this.dimension = dimension;
|
||||
this.studio = studio;
|
||||
world = IrisWorld.builder()
|
||||
.environment(dimension.getEnvironment())
|
||||
.worldFolder(new File(worldName))
|
||||
.seed(seed)
|
||||
.maxHeight(256)
|
||||
.minHeight(0)
|
||||
.name(worldName)
|
||||
.build();
|
||||
.environment(dimension.getEnvironment())
|
||||
.worldFolder(new File(worldName))
|
||||
.seed(seed)
|
||||
.maxHeight(256)
|
||||
.minHeight(0)
|
||||
.name(worldName)
|
||||
.build();
|
||||
world.worldFolder().mkdirs();
|
||||
new File(world.worldFolder(), "region").mkdirs();
|
||||
|
||||
if (!studio && !new File(world.worldFolder(), "iris/pack").exists()) {
|
||||
if(!studio && !new File(world.worldFolder(), "iris/pack").exists()) {
|
||||
Iris.service(StudioSVC.class).installIntoWorld(new VolmitSender(Bukkit.getConsoleSender(), Iris.instance.getTag("Headless")), dimension.getLoadKey(), world.worldFolder());
|
||||
}
|
||||
}
|
||||
|
||||
public static HeadlessWorld from(World world) {
|
||||
return new HeadlessWorld(world.getName(), IrisToolbelt.access(world)
|
||||
.getEngine().getTarget().getDimension(), world.getSeed());
|
||||
.getEngine().getTarget().getDimension(), world.getSeed());
|
||||
}
|
||||
|
||||
public static HeadlessWorld from(String name, String dimension, long seed) {
|
||||
@@ -78,13 +78,13 @@ public class HeadlessWorld {
|
||||
public HeadlessGenerator generate() {
|
||||
Engine e = null;
|
||||
|
||||
if (getWorld().tryGetRealWorld()) {
|
||||
if (IrisToolbelt.isIrisWorld(getWorld().realWorld())) {
|
||||
if(getWorld().tryGetRealWorld()) {
|
||||
if(IrisToolbelt.isIrisWorld(getWorld().realWorld())) {
|
||||
e = IrisToolbelt.access(getWorld().realWorld()).getEngine();
|
||||
}
|
||||
}
|
||||
|
||||
if (e != null) {
|
||||
if(e != null) {
|
||||
Iris.info("Using Existing Engine " + getWorld().name() + " for Headless Pregeneration.");
|
||||
}
|
||||
|
||||
@@ -93,11 +93,11 @@ public class HeadlessWorld {
|
||||
|
||||
public World load() {
|
||||
World w = new WorldCreator(worldName)
|
||||
.environment(dimension.getEnvironment())
|
||||
.seed(world.getRawWorldSeed())
|
||||
.generator(new BukkitChunkGenerator(world, studio, dimension.getLoader().getDataFolder(),
|
||||
dimension.getLoadKey()))
|
||||
.createWorld();
|
||||
.environment(dimension.getEnvironment())
|
||||
.seed(world.getRawWorldSeed())
|
||||
.generator(new BukkitChunkGenerator(world, studio, dimension.getLoader().getDataFolder(),
|
||||
dimension.getLoadKey()))
|
||||
.createWorld();
|
||||
world.realWorld(w);
|
||||
return w;
|
||||
}
|
||||
|
||||
@@ -18,54 +18,46 @@
|
||||
|
||||
package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.engine.EnginePanic;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.reflect.V;
|
||||
import com.volmit.iris.util.scheduling.J;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
import com.volmit.iris.util.stream.arithmetic.FittedStream;
|
||||
import com.volmit.iris.util.stream.interpolation.Interpolated;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public interface IRare {
|
||||
static <T extends IRare> ProceduralStream<T> stream(ProceduralStream<Double> noise, List<T> possibilities) {
|
||||
return ProceduralStream.of((x, z) -> pick(possibilities, noise.get(x, z)),
|
||||
(x, y, z) -> pick(possibilities, noise.get(x, y, z)),
|
||||
new Interpolated<T>() {
|
||||
@Override
|
||||
public double toDouble(T t) {
|
||||
return 0;
|
||||
}
|
||||
(x, y, z) -> pick(possibilities, noise.get(x, y, z)),
|
||||
new Interpolated<T>() {
|
||||
@Override
|
||||
public double toDouble(T t) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public T fromDouble(double d) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public T fromDouble(double d) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
static <T extends IRare> T pickSlowly(List<T> possibilities, double noiseValue) {
|
||||
if (possibilities.isEmpty()) {
|
||||
if(possibilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (possibilities.size() == 1) {
|
||||
if(possibilities.size() == 1) {
|
||||
return possibilities.get(0);
|
||||
}
|
||||
|
||||
KList<T> rarityTypes = new KList<>();
|
||||
int totalRarity = 0;
|
||||
for (T i : possibilities) {
|
||||
for(T i : possibilities) {
|
||||
totalRarity += IRare.get(i);
|
||||
}
|
||||
|
||||
for (T i : possibilities) {
|
||||
for(T i : possibilities) {
|
||||
rarityTypes.addMultiple(i, totalRarity / IRare.get(i));
|
||||
}
|
||||
|
||||
@@ -73,23 +65,23 @@ public interface IRare {
|
||||
}
|
||||
|
||||
static <T extends IRare> T pick(List<T> possibilities, double noiseValue) {
|
||||
if (possibilities.isEmpty()) {
|
||||
if(possibilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (possibilities.size() == 1) {
|
||||
if(possibilities.size() == 1) {
|
||||
return possibilities.get(0);
|
||||
}
|
||||
int totalWeight = 0; // This is he baseline
|
||||
int buffer = 0;
|
||||
for (T i : possibilities) { // Im adding all of the rarity together
|
||||
for(T i : possibilities) { // Im adding all of the rarity together
|
||||
totalWeight += i.getRarity();
|
||||
}
|
||||
double threshold = totalWeight * (possibilities.size() - 1) * noiseValue;
|
||||
for (T i : possibilities) {
|
||||
for(T i : possibilities) {
|
||||
buffer += totalWeight - i.getRarity();
|
||||
|
||||
if (buffer >= threshold) {
|
||||
if(buffer >= threshold) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -98,18 +90,18 @@ public interface IRare {
|
||||
|
||||
|
||||
static <T extends IRare> T pickOld(List<T> possibilities, double noiseValue) {
|
||||
if (possibilities.isEmpty()) {
|
||||
if(possibilities.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (possibilities.size() == 1) {
|
||||
if(possibilities.size() == 1) {
|
||||
return possibilities.get(0);
|
||||
}
|
||||
|
||||
double completeWeight = 0.0;
|
||||
double highestWeight = 0.0;
|
||||
|
||||
for (T item : possibilities) {
|
||||
for(T item : possibilities) {
|
||||
double weight = Math.max(item.getRarity(), 1);
|
||||
highestWeight = Math.max(highestWeight, weight);
|
||||
completeWeight += weight;
|
||||
@@ -118,10 +110,10 @@ public interface IRare {
|
||||
double r = noiseValue * completeWeight;
|
||||
double countWeight = 0.0;
|
||||
|
||||
for (T item : possibilities) {
|
||||
for(T item : possibilities) {
|
||||
double weight = Math.max(highestWeight - Math.max(item.getRarity(), 1), 1);
|
||||
countWeight += weight;
|
||||
if (countWeight >= r) {
|
||||
if(countWeight >= r) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,13 +65,13 @@ public class IrisAttributeModifier {
|
||||
private double chance = 1;
|
||||
|
||||
public void apply(RNG rng, ItemMeta meta) {
|
||||
if (rng.nextDouble() < getChance()) {
|
||||
if(rng.nextDouble() < getChance()) {
|
||||
meta.addAttributeModifier(getAttribute(), new AttributeModifier(getName(), getAmount(rng), getOperation()));
|
||||
}
|
||||
}
|
||||
|
||||
public void apply(RNG rng, Attributable meta) {
|
||||
if (rng.nextDouble() < getChance()) {
|
||||
if(rng.nextDouble() < getChance()) {
|
||||
meta.getAttribute(getAttribute()).addModifier(new AttributeModifier(getName(), getAmount(rng), getOperation()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -78,19 +78,19 @@ public class IrisAxisRotationClamp {
|
||||
}
|
||||
|
||||
public double getRadians(int rng) {
|
||||
if (forceLock) {
|
||||
if(forceLock) {
|
||||
return Math.toRadians(Math.ceil(Math.abs((max % 360D))));
|
||||
}
|
||||
|
||||
if (isUnlimited()) {
|
||||
if (interval < 1) {
|
||||
if(isUnlimited()) {
|
||||
if(interval < 1) {
|
||||
interval = 1;
|
||||
}
|
||||
|
||||
return Math.toRadians((interval * (Math.ceil(Math.abs((rng % 360D) / interval)))) % 360D);
|
||||
}
|
||||
|
||||
if (min == max && min != 0) {
|
||||
if(min == max && min != 0) {
|
||||
return Math.toRadians(max);
|
||||
}
|
||||
|
||||
|
||||
@@ -183,14 +183,14 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
private KList<IrisOreGenerator> ores = new KList<>();
|
||||
|
||||
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
if (ores.isEmpty()) {
|
||||
if(ores.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
BlockData b = null;
|
||||
for (IrisOreGenerator i : ores) {
|
||||
for(IrisOreGenerator i : ores) {
|
||||
|
||||
b = i.generate(x,y,z,rng,data);
|
||||
if(b != null ){
|
||||
b = i.generate(x, y, z, rng, data);
|
||||
if(b != null) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
@@ -210,7 +210,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
KMap<String, Integer> l = new KMap<>();
|
||||
|
||||
for (IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
for(IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
l.put(i.getGenerator(), i.getMax());
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
KMap<String, Integer> l = new KMap<>();
|
||||
|
||||
for (IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
for(IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
l.put(i.getGenerator(), i.getMin());
|
||||
}
|
||||
|
||||
@@ -240,7 +240,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
KMap<String, IrisBiomeGeneratorLink> l = new KMap<>();
|
||||
|
||||
for (IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
for(IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
l.put(i.getGenerator(), i);
|
||||
}
|
||||
|
||||
@@ -253,7 +253,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
IrisBiome biome = data.getBiomeLoader().load(getCarvingBiome());
|
||||
|
||||
if (biome == null) {
|
||||
if(biome == null) {
|
||||
biome = this;
|
||||
}
|
||||
|
||||
@@ -266,8 +266,8 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
KList<IrisObjectPlacement> o = getObjects().copy();
|
||||
|
||||
for (IrisObjectPlacement i : o.copy()) {
|
||||
if (!i.getCarvingSupport().supportsSurface()) {
|
||||
for(IrisObjectPlacement i : o.copy()) {
|
||||
if(!i.getCarvingSupport().supportsSurface()) {
|
||||
o.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -281,8 +281,8 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
KList<IrisObjectPlacement> o = getObjects().copy();
|
||||
|
||||
for (IrisObjectPlacement i : o.copy()) {
|
||||
if (!i.getCarvingSupport().supportsCarving()) {
|
||||
for(IrisObjectPlacement i : o.copy()) {
|
||||
if(!i.getCarvingSupport().supportsCarving()) {
|
||||
o.remove(i);
|
||||
}
|
||||
}
|
||||
@@ -294,7 +294,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
public double getHeight(Engine xg, double x, double z, long seed) {
|
||||
double height = 0;
|
||||
|
||||
for (IrisBiomeGeneratorLink i : generators) {
|
||||
for(IrisBiomeGeneratorLink i : generators) {
|
||||
height += i.getHeight(xg, x, z, seed);
|
||||
}
|
||||
|
||||
@@ -303,7 +303,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
public CNG getBiomeGenerator(RNG random) {
|
||||
return biomeGenerator.aquire(() ->
|
||||
biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()), getLoader()));
|
||||
biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()), getLoader()));
|
||||
}
|
||||
|
||||
public CNG getChildrenGenerator(RNG random, int sig, double scale) {
|
||||
@@ -311,54 +311,54 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
}
|
||||
|
||||
public KList<BlockData> generateLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
if (isLockLayers()) {
|
||||
if(isLockLayers()) {
|
||||
return generateLockedLayers(wx, wz, random, maxDepth, height, rdata, complex);
|
||||
}
|
||||
|
||||
KList<BlockData> data = new KList<>();
|
||||
|
||||
if (maxDepth <= 0) {
|
||||
if(maxDepth <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
for(int i = 0; i < layers.size(); i++) {
|
||||
CNG hgen = getLayerHeightGenerators(random, rdata).get(i);
|
||||
double d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
|
||||
|
||||
IrisSlopeClip sc = getLayers().get(i).getSlopeCondition();
|
||||
|
||||
if (!sc.isDefault()) {
|
||||
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
if(!sc.isDefault()) {
|
||||
if(!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (d <= 0) {
|
||||
if(d <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
if (data.size() >= maxDepth) {
|
||||
for(int j = 0; j < d; j++) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom(), rdata));
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (dim.isExplodeBiomePalettes()) {
|
||||
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||
if(dim.isExplodeBiomePalettes()) {
|
||||
for(int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||
data.add(BARRIER);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -371,40 +371,40 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
public KList<BlockData> generateCeilingLayers(IrisDimension dim, double wx, double wz, RNG random, int maxDepth, int height, IrisData rdata, IrisComplex complex) {
|
||||
KList<BlockData> data = new KList<>();
|
||||
|
||||
if (maxDepth <= 0) {
|
||||
if(maxDepth <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
for (int i = 0; i < caveCeilingLayers.size(); i++) {
|
||||
for(int i = 0; i < caveCeilingLayers.size(); i++) {
|
||||
CNG hgen = getLayerHeightGenerators(random, rdata).get(i);
|
||||
double d = hgen.fit(caveCeilingLayers.get(i).getMinHeight(), caveCeilingLayers.get(i).getMaxHeight(), wx / caveCeilingLayers.get(i).getZoom(), wz / caveCeilingLayers.get(i).getZoom());
|
||||
|
||||
if (d <= 0) {
|
||||
if(d <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
if (data.size() >= maxDepth) {
|
||||
for(int j = 0; j < d; j++) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
data.add(getCaveCeilingLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / caveCeilingLayers.get(i).getZoom(), j, (wz - j) / caveCeilingLayers.get(i).getZoom(), rdata));
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (dim.isExplodeBiomePalettes()) {
|
||||
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||
if(dim.isExplodeBiomePalettes()) {
|
||||
for(int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||
data.add(BARRIER);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -418,41 +418,41 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
KList<BlockData> data = new KList<>();
|
||||
KList<BlockData> real = new KList<>();
|
||||
int maxDepth = Math.min(maxDepthf, getLockLayersMax());
|
||||
if (maxDepth <= 0) {
|
||||
if(maxDepth <= 0) {
|
||||
return data;
|
||||
}
|
||||
|
||||
for (int i = 0; i < layers.size(); i++) {
|
||||
for(int i = 0; i < layers.size(); i++) {
|
||||
CNG hgen = getLayerHeightGenerators(random, rdata).get(i);
|
||||
double d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
|
||||
|
||||
IrisSlopeClip sc = getLayers().get(i).getSlopeCondition();
|
||||
|
||||
if (!sc.isDefault()) {
|
||||
if (!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
if(!sc.isDefault()) {
|
||||
if(!sc.isValid(complex.getSlopeStream().get(wx, wz))) {
|
||||
d = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (d <= 0) {
|
||||
if(d <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
for(int j = 0; j < d; j++) {
|
||||
try {
|
||||
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom(), rdata));
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (data.isEmpty()) {
|
||||
if(data.isEmpty()) {
|
||||
return real;
|
||||
}
|
||||
|
||||
for (int i = 0; i < maxDepth; i++) {
|
||||
for(int i = 0; i < maxDepth; i++) {
|
||||
int offset = (255 - height) - i;
|
||||
int index = offset % data.size();
|
||||
real.add(data.get(Math.max(index, 0)));
|
||||
@@ -466,7 +466,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
int maxHeight = 0;
|
||||
|
||||
for (IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
for(IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
maxHeight += i.getMax();
|
||||
}
|
||||
|
||||
@@ -479,14 +479,14 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
int maxHeight = 0;
|
||||
|
||||
for (IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
for(IrisBiomeGeneratorLink i : getGenerators()) {
|
||||
maxHeight += i.getMax();
|
||||
}
|
||||
|
||||
int gg = 0;
|
||||
|
||||
for (IrisObjectPlacement i : getObjects()) {
|
||||
for (IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) {
|
||||
for(IrisObjectPlacement i : getObjects()) {
|
||||
for(IrisObject j : data.getObjectLoader().loadAll(i.getPlace())) {
|
||||
gg = Math.max(gg, j.getH());
|
||||
}
|
||||
}
|
||||
@@ -503,28 +503,28 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
public KList<BlockData> generateSeaLayers(double wx, double wz, RNG random, int maxDepth, IrisData rdata) {
|
||||
KList<BlockData> data = new KList<>();
|
||||
|
||||
for (int i = 0; i < seaLayers.size(); i++) {
|
||||
for(int i = 0; i < seaLayers.size(); i++) {
|
||||
CNG hgen = getLayerSeaHeightGenerators(random, rdata).get(i);
|
||||
int d = hgen.fit(seaLayers.get(i).getMinHeight(), seaLayers.get(i).getMaxHeight(), wx / seaLayers.get(i).getZoom(), wz / seaLayers.get(i).getZoom());
|
||||
|
||||
if (d < 0) {
|
||||
if(d < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < d; j++) {
|
||||
if (data.size() >= maxDepth) {
|
||||
for(int j = 0; j < d; j++) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
try {
|
||||
data.add(getSeaLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / seaLayers.get(i).getZoom(), j, (wz - j) / seaLayers.get(i).getZoom(), rdata));
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
if(data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -539,7 +539,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
int m = 7235;
|
||||
|
||||
for (IrisBiomePaletteLayer i : getLayers()) {
|
||||
for(IrisBiomePaletteLayer i : getLayers()) {
|
||||
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), rdata));
|
||||
}
|
||||
|
||||
@@ -554,7 +554,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
int m = 7735;
|
||||
|
||||
for (IrisBiomePaletteLayer i : getSeaLayers()) {
|
||||
for(IrisBiomePaletteLayer i : getSeaLayers()) {
|
||||
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m), data));
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
}
|
||||
|
||||
public boolean isLand() {
|
||||
if (inferredType == null) {
|
||||
if(inferredType == null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
}
|
||||
|
||||
public boolean isSea() {
|
||||
if (inferredType == null) {
|
||||
if(inferredType == null) {
|
||||
return false;
|
||||
}
|
||||
return inferredType.equals(InferredType.SEA);
|
||||
@@ -583,18 +583,18 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
|
||||
public boolean isShore() {
|
||||
if (inferredType == null) {
|
||||
if(inferredType == null) {
|
||||
return false;
|
||||
}
|
||||
return inferredType.equals(InferredType.SHORE);
|
||||
}
|
||||
|
||||
public Biome getSkyBiome(RNG rng, double x, double y, double z) {
|
||||
if (biomeSkyScatter.size() == 1) {
|
||||
if(biomeSkyScatter.size() == 1) {
|
||||
return biomeSkyScatter.get(0);
|
||||
}
|
||||
|
||||
if (biomeSkyScatter.isEmpty()) {
|
||||
if(biomeSkyScatter.isEmpty()) {
|
||||
return getGroundBiome(rng, x, y, z);
|
||||
}
|
||||
|
||||
@@ -602,7 +602,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
}
|
||||
|
||||
public IrisBiomeCustom getCustomBiome(RNG rng, double x, double y, double z) {
|
||||
if (customDerivitives.size() == 1) {
|
||||
if(customDerivitives.size() == 1) {
|
||||
return customDerivitives.get(0);
|
||||
}
|
||||
|
||||
@@ -614,7 +614,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
{
|
||||
KList<IrisBiome> realChildren = new KList<>();
|
||||
|
||||
for (String i : getChildren()) {
|
||||
for(String i : getChildren()) {
|
||||
realChildren.add(g.getData().getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
@@ -627,8 +627,8 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
m.addAll(getChildren());
|
||||
limit--;
|
||||
|
||||
if (limit > 0) {
|
||||
for (String i : getChildren()) {
|
||||
if(limit > 0) {
|
||||
for(String i : getChildren()) {
|
||||
IrisBiome b = g.getData().getBiomeLoader().load(i);
|
||||
m.addAll(b.getAllChildren(g, limit));
|
||||
}
|
||||
@@ -639,11 +639,11 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
//TODO: Test
|
||||
public Biome getGroundBiome(RNG rng, double x, double y, double z) {
|
||||
if (biomeScatter.isEmpty()) {
|
||||
if(biomeScatter.isEmpty()) {
|
||||
return getDerivative();
|
||||
}
|
||||
|
||||
if (biomeScatter.size() == 1) {
|
||||
if(biomeScatter.size() == 1) {
|
||||
return biomeScatter.get(0);
|
||||
}
|
||||
|
||||
@@ -651,7 +651,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
}
|
||||
|
||||
public BlockData getSurfaceBlock(int x, int z, RNG rng, IrisData idm) {
|
||||
if (getLayers().isEmpty()) {
|
||||
if(getLayers().isEmpty()) {
|
||||
return B.get("AIR");
|
||||
}
|
||||
|
||||
@@ -659,12 +659,12 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
}
|
||||
|
||||
public Color getColor(Engine engine, RenderType type) {
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case BIOME, HEIGHT, CAVE_LAND, REGION, BIOME_SEA, BIOME_LAND -> {
|
||||
return this.cacheColor.aquire(() -> {
|
||||
if (this.color == null) {
|
||||
if(this.color == null) {
|
||||
RandomColor randomColor = new RandomColor(getName().hashCode());
|
||||
if (this.getVanillaDerivative() == null) {
|
||||
if(this.getVanillaDerivative() == null) {
|
||||
Iris.warn("No vanilla biome found for " + getName());
|
||||
return new Color(randomColor.randomColor());
|
||||
}
|
||||
@@ -678,7 +678,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
|
||||
try {
|
||||
return Color.decode(this.color);
|
||||
} catch (NumberFormatException e) {
|
||||
} catch(NumberFormatException e) {
|
||||
Iris.warn("Could not parse color \"" + this.color + "\" for biome " + getName());
|
||||
return new Color(new RandomColor(getName().hashCode()).randomColor());
|
||||
}
|
||||
@@ -688,7 +688,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
return cacheColorObjectDensity.aquire(() -> {
|
||||
double density = 0;
|
||||
|
||||
for (IrisObjectPlacement i : getObjects()) {
|
||||
for(IrisObjectPlacement i : getObjects()) {
|
||||
density += i.getDensity() * i.getChance();
|
||||
}
|
||||
|
||||
@@ -699,7 +699,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
return cacheColorDecoratorLoad.aquire(() -> {
|
||||
double density = 0;
|
||||
|
||||
for (IrisDecorator i : getDecorators()) {
|
||||
for(IrisDecorator i : getDecorators()) {
|
||||
density += i.getChance() * Math.min(1, i.getStackMax()) * 256;
|
||||
}
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ public class IrisBiomeCustom {
|
||||
effects.put("water_color", parseColor(getWaterColor()));
|
||||
effects.put("water_fog_color", parseColor(getWaterFogColor()));
|
||||
|
||||
if (ambientParticle != null) {
|
||||
if(ambientParticle != null) {
|
||||
JSONObject particle = new JSONObject();
|
||||
JSONObject po = new JSONObject();
|
||||
po.put("type", ambientParticle.getParticle().name().toLowerCase());
|
||||
@@ -111,11 +111,11 @@ public class IrisBiomeCustom {
|
||||
effects.put("particle", particle);
|
||||
}
|
||||
|
||||
if (!getGrassColor().isEmpty()) {
|
||||
if(!getGrassColor().isEmpty()) {
|
||||
effects.put("grass_color", parseColor(getGrassColor()));
|
||||
}
|
||||
|
||||
if (!getFoliageColor().isEmpty()) {
|
||||
if(!getFoliageColor().isEmpty()) {
|
||||
effects.put("foliage_color", parseColor(getFoliageColor()));
|
||||
}
|
||||
|
||||
@@ -135,15 +135,15 @@ public class IrisBiomeCustom {
|
||||
j.put("carvers", new JSONObject());
|
||||
j.put("features", new JSONArray());
|
||||
|
||||
if (spawnRarity > 0) {
|
||||
if(spawnRarity > 0) {
|
||||
j.put("creature_spawn_probability", spawnRarity);
|
||||
}
|
||||
|
||||
if (getSpawns() != null && getSpawns().isNotEmpty()) {
|
||||
if(getSpawns() != null && getSpawns().isNotEmpty()) {
|
||||
JSONObject spawners = new JSONObject();
|
||||
KMap<IrisBiomeCustomSpawnType, JSONArray> groups = new KMap<>();
|
||||
|
||||
for (IrisBiomeCustomSpawn i : getSpawns()) {
|
||||
for(IrisBiomeCustomSpawn i : getSpawns()) {
|
||||
JSONArray g = groups.computeIfAbsent(i.getGroup(), (k) -> new JSONArray());
|
||||
JSONObject o = new JSONObject();
|
||||
o.put("type", "minecraft:" + i.getType().name().toLowerCase());
|
||||
@@ -153,7 +153,7 @@ public class IrisBiomeCustom {
|
||||
g.put(o);
|
||||
}
|
||||
|
||||
for (IrisBiomeCustomSpawnType i : groups.k()) {
|
||||
for(IrisBiomeCustomSpawnType i : groups.k()) {
|
||||
spawners.put(i.name().toLowerCase(Locale.ROOT), groups.get(i));
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ public class IrisBiomeCustom {
|
||||
String v = (c.startsWith("#") ? c : "#" + c).trim();
|
||||
try {
|
||||
return Color.decode(v).getRGB();
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
Iris.error("Error Parsing '''color''', (" + c + ")");
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ public class IrisBiomeGeneratorLink {
|
||||
{
|
||||
IrisGenerator gen = g.getData().getGeneratorLoader().load(getGenerator());
|
||||
|
||||
if (gen == null) {
|
||||
if(gen == null) {
|
||||
gen = new IrisGenerator();
|
||||
}
|
||||
|
||||
|
||||
@@ -75,11 +75,11 @@ public class IrisBiomePaletteLayer {
|
||||
}
|
||||
|
||||
public BlockData get(RNG rng, double x, double y, double z, IrisData data) {
|
||||
if (getBlockData(data).isEmpty()) {
|
||||
if(getBlockData(data).isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (getBlockData(data).size() == 1) {
|
||||
if(getBlockData(data).size() == 1) {
|
||||
return getBlockData(data).get(0);
|
||||
}
|
||||
|
||||
@@ -104,10 +104,10 @@ public class IrisBiomePaletteLayer {
|
||||
return blockData.aquire(() ->
|
||||
{
|
||||
KList<BlockData> blockData = new KList<>();
|
||||
for (IrisBlockData ix : palette) {
|
||||
for(IrisBlockData ix : palette) {
|
||||
BlockData bx = ix.getBlockData(data);
|
||||
if (bx != null) {
|
||||
for (int i = 0; i < ix.getWeight(); i++) {
|
||||
if(bx != null) {
|
||||
for(int i = 0; i < ix.getWeight(); i++) {
|
||||
blockData.add(bx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,18 +74,18 @@ public class IrisBlockData extends IrisRegistrant {
|
||||
IrisBlockData b = new IrisBlockData();
|
||||
String v = j.toLowerCase().trim();
|
||||
|
||||
if (v.contains("[")) {
|
||||
if(v.contains("[")) {
|
||||
KList<String> props = new KList<>();
|
||||
String rp = v.split("\\Q[\\E")[1].replaceAll("\\Q]\\E", "");
|
||||
b.setBlock(v.split("\\Q[\\E")[0]);
|
||||
|
||||
if (rp.contains(",")) {
|
||||
if(rp.contains(",")) {
|
||||
props.add(rp.split("\\Q,\\E"));
|
||||
} else {
|
||||
props.add(rp);
|
||||
}
|
||||
|
||||
for (String i : props) {
|
||||
for(String i : props) {
|
||||
Object kg = filter(i.split("\\Q=\\E")[1]);
|
||||
b.data.put(i.split("\\Q=\\E")[0], kg);
|
||||
}
|
||||
@@ -97,23 +97,23 @@ public class IrisBlockData extends IrisRegistrant {
|
||||
}
|
||||
|
||||
private static Object filter(String string) {
|
||||
if (string.equals("true")) {
|
||||
if(string.equals("true")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (string.equals("false")) {
|
||||
if(string.equals("false")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
try {
|
||||
return Integer.parseInt(string);
|
||||
} catch (Throwable ignored) {
|
||||
} catch(Throwable ignored) {
|
||||
// Checks
|
||||
}
|
||||
|
||||
try {
|
||||
return Double.valueOf(string).intValue();
|
||||
} catch (Throwable ignored) {
|
||||
} catch(Throwable ignored) {
|
||||
// Checks
|
||||
}
|
||||
|
||||
@@ -121,13 +121,13 @@ public class IrisBlockData extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public String computeProperties(KMap<String, Object> data) {
|
||||
if (data.isEmpty()) {
|
||||
if(data.isEmpty()) {
|
||||
return "";
|
||||
}
|
||||
|
||||
KList<String> r = new KList<>();
|
||||
|
||||
for (Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
for(Map.Entry<String, Object> entry : data.entrySet()) {
|
||||
r.add(entry.getKey() + "=" + filter(entry.getValue().toString()));
|
||||
}
|
||||
|
||||
@@ -145,37 +145,37 @@ public class IrisBlockData extends IrisRegistrant {
|
||||
|
||||
IrisBlockData customData = data.getBlockLoader().load(getBlock(), false);
|
||||
|
||||
if (customData != null) {
|
||||
if(customData != null) {
|
||||
b = customData.getBlockData(data);
|
||||
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
b = b.clone();
|
||||
|
||||
String st = b.getAsString(true);
|
||||
|
||||
if (st.contains("[")) {
|
||||
if(st.contains("[")) {
|
||||
st = st.split("\\Q[\\E")[0];
|
||||
}
|
||||
|
||||
KMap<String, Object> cdata = customData.getData().copy();
|
||||
|
||||
for (String i : getData().keySet()) {
|
||||
for(String i : getData().keySet()) {
|
||||
cdata.put(i, getData().get(i));
|
||||
}
|
||||
|
||||
String sx = keyify(st) + computeProperties(cdata);
|
||||
|
||||
if (debug) {
|
||||
if(debug) {
|
||||
Iris.debug("Block Data used " + sx + " (CUSTOM)");
|
||||
}
|
||||
|
||||
BlockData bx = B.get(sx);
|
||||
|
||||
if (bx != null) {
|
||||
if(bx != null) {
|
||||
return bx;
|
||||
}
|
||||
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
@@ -184,15 +184,15 @@ public class IrisBlockData extends IrisRegistrant {
|
||||
String ss = keyify(getBlock()) + computeProperties();
|
||||
b = B.get(ss);
|
||||
|
||||
if (debug) {
|
||||
if(debug) {
|
||||
Iris.debug("Block Data used " + ss);
|
||||
}
|
||||
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
return b;
|
||||
}
|
||||
|
||||
if (backup != null) {
|
||||
if(backup != null) {
|
||||
return backup.getBlockData(data);
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ public class IrisBlockData extends IrisRegistrant {
|
||||
}
|
||||
|
||||
private String keyify(String dat) {
|
||||
if (dat.contains(":")) {
|
||||
if(dat.contains(":")) {
|
||||
return dat;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,10 +60,10 @@ public class IrisBlockDrops {
|
||||
{
|
||||
KList<BlockData> b = new KList<>();
|
||||
|
||||
for (IrisBlockData i : getBlocks()) {
|
||||
for(IrisBlockData i : getBlocks()) {
|
||||
BlockData dd = i.getBlockData(rdata);
|
||||
|
||||
if (dd != null) {
|
||||
if(dd != null) {
|
||||
b.add(dd);
|
||||
}
|
||||
}
|
||||
@@ -71,8 +71,8 @@ public class IrisBlockDrops {
|
||||
return b.removeDuplicates();
|
||||
});
|
||||
|
||||
for (BlockData i : list) {
|
||||
if (exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial())) {
|
||||
for(BlockData i : list) {
|
||||
if(exactBlocks ? i.equals(data) : i.getMaterial().equals(data.getMaterial())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -81,8 +81,8 @@ public class IrisBlockDrops {
|
||||
}
|
||||
|
||||
public void fillDrops(boolean debug, KList<ItemStack> d) {
|
||||
for (IrisLoot i : getDrops()) {
|
||||
if (RNG.r.i(1, i.getRarity()) == i.getRarity()) {
|
||||
for(IrisLoot i : getDrops()) {
|
||||
if(RNG.r.i(1, i.getRarity()) == i.getRarity()) {
|
||||
d.add(i.get(debug, RNG.r));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,37 +67,37 @@ public class IrisCarving {
|
||||
|
||||
@BlockCoordinates
|
||||
public void doCarving(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
|
||||
if (caves.isNotEmpty()) {
|
||||
for (IrisCavePlacer i : caves) {
|
||||
if(caves.isNotEmpty()) {
|
||||
for(IrisCavePlacer i : caves) {
|
||||
i.generateCave(writer, rng, engine, x, y, z, waterHint);
|
||||
}
|
||||
}
|
||||
|
||||
if (ravines.isNotEmpty()) {
|
||||
for (IrisRavinePlacer i : ravines) {
|
||||
if(ravines.isNotEmpty()) {
|
||||
for(IrisRavinePlacer i : ravines) {
|
||||
i.generateRavine(writer, rng, engine, x, y, z, waterHint);
|
||||
}
|
||||
}
|
||||
|
||||
if (spheres.isNotEmpty()) {
|
||||
for (IrisSphere i : spheres) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
if(spheres.isNotEmpty()) {
|
||||
for(IrisSphere i : spheres) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
i.generate(rng, engine, writer, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (elipsoids.isNotEmpty()) {
|
||||
for (IrisElipsoid i : elipsoids) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
if(elipsoids.isNotEmpty()) {
|
||||
for(IrisElipsoid i : elipsoids) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
i.generate(rng, engine, writer, x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pyramids.isNotEmpty()) {
|
||||
for (IrisPyramid i : pyramids) {
|
||||
if (rng.nextInt(i.getRarity()) == 0) {
|
||||
if(pyramids.isNotEmpty()) {
|
||||
for(IrisPyramid i : pyramids) {
|
||||
if(rng.nextInt(i.getRarity()) == 0) {
|
||||
i.generate(rng, engine, writer, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -107,23 +107,23 @@ public class IrisCarving {
|
||||
public int getMaxRange(IrisData data) {
|
||||
int max = 0;
|
||||
|
||||
for (IrisCavePlacer i : caves) {
|
||||
for(IrisCavePlacer i : caves) {
|
||||
max = Math.max(max, i.getSize(data));
|
||||
}
|
||||
|
||||
for (IrisRavinePlacer i : ravines) {
|
||||
for(IrisRavinePlacer i : ravines) {
|
||||
max = Math.max(max, i.getSize(data));
|
||||
}
|
||||
|
||||
if (elipsoids.isNotEmpty()) {
|
||||
if(elipsoids.isNotEmpty()) {
|
||||
max = (int) Math.max(elipsoids.stream().mapToDouble(IrisElipsoid::maxSize).max().getAsDouble(), max);
|
||||
}
|
||||
|
||||
if (spheres.isNotEmpty()) {
|
||||
if(spheres.isNotEmpty()) {
|
||||
max = (int) Math.max(spheres.stream().mapToDouble(IrisSphere::maxSize).max().getAsDouble(), max);
|
||||
}
|
||||
|
||||
if (pyramids.isNotEmpty()) {
|
||||
if(pyramids.isNotEmpty()) {
|
||||
max = (int) Math.max(pyramids.stream().mapToDouble(IrisPyramid::maxSize).max().getAsDouble(), max);
|
||||
}
|
||||
|
||||
|
||||
@@ -76,12 +76,12 @@ public class IrisCave extends IrisRegistrant {
|
||||
});
|
||||
int highestWater = Math.max(waterHint, -1);
|
||||
|
||||
if (highestWater == -1) {
|
||||
for (IrisPosition i : points) {
|
||||
if(highestWater == -1) {
|
||||
for(IrisPosition i : points) {
|
||||
double yy = i.getY() + girth;
|
||||
int th = engine.getHeight(x, z, true);
|
||||
|
||||
if (yy > th && th < engine.getDimension().getFluidHeight()) {
|
||||
if(yy > th && th < engine.getDimension().getFluidHeight()) {
|
||||
highestWater = Math.max(highestWater, (int) yy);
|
||||
break;
|
||||
}
|
||||
@@ -91,7 +91,7 @@ public class IrisCave extends IrisRegistrant {
|
||||
|
||||
int h = Math.min(Math.max(highestWater, waterHint), engine.getDimension().getFluidHeight());
|
||||
|
||||
for (IrisPosition i : points) {
|
||||
for(IrisPosition i : points) {
|
||||
fork.doCarving(writer, rng, engine, i.getX(), i.getY(), i.getZ(), h);
|
||||
}
|
||||
|
||||
@@ -99,8 +99,8 @@ public class IrisCave extends IrisRegistrant {
|
||||
MatterCavern w = new MatterCavern(true, customBiome, (byte) 1);
|
||||
|
||||
writer.setLineConsumer(points,
|
||||
girth, true,
|
||||
(xf, yf, zf) -> yf <= h ? w : c);
|
||||
girth, true,
|
||||
(xf, yf, zf) -> yf <= h ? w : c);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -68,24 +68,24 @@ public class IrisCavePlacer implements IRare {
|
||||
}
|
||||
|
||||
public void generateCave(MantleWriter mantle, RNG rng, Engine engine, int x, int y, int z, int waterHint) {
|
||||
if (fail.get()) {
|
||||
if(fail.get()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (rng.nextInt(rarity) != 0) {
|
||||
if(rng.nextInt(rarity) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisData data = engine.getData();
|
||||
IrisCave cave = getRealCave(data);
|
||||
|
||||
if (cave == null) {
|
||||
if(cave == null) {
|
||||
Iris.warn("Unable to locate cave for generation!");
|
||||
fail.set(true);
|
||||
return;
|
||||
}
|
||||
|
||||
if (y == -1) {
|
||||
if(y == -1) {
|
||||
int h = (int) caveStartHeight.get(rng, x, z, data);
|
||||
int ma = breakSurface ? h : (int) (engine.getComplex().getHeightStream().get(x, z) - 9);
|
||||
y = Math.min(h, ma);
|
||||
@@ -93,7 +93,7 @@ public class IrisCavePlacer implements IRare {
|
||||
|
||||
try {
|
||||
cave.generate(mantle, rng, engine, x + rng.nextInt(15), y, z + rng.nextInt(15), waterHint);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
fail.set(true);
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class IrisCavePlacer implements IRare {
|
||||
public int getSize(IrisData data) {
|
||||
IrisCave cave = getRealCave(data);
|
||||
|
||||
if (cave != null) {
|
||||
if(cave != null) {
|
||||
return cave.getMaxSize(data);
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,7 @@ public class IrisColor {
|
||||
private int blue = 0;
|
||||
|
||||
public static Color blend(Color... c) {
|
||||
if (c == null || c.length <= 0) {
|
||||
if(c == null || c.length <= 0) {
|
||||
return null;
|
||||
}
|
||||
float ratio = 1f / ((float) c.length);
|
||||
@@ -65,7 +65,7 @@ public class IrisColor {
|
||||
int g = 0;
|
||||
int b = 0;
|
||||
|
||||
for (Color value : c) {
|
||||
for(Color value : c) {
|
||||
int rgb = value.getRGB();
|
||||
int a1 = (rgb >> 24 & 0xff);
|
||||
int r1 = ((rgb & 0xff0000) >> 16);
|
||||
@@ -82,11 +82,11 @@ public class IrisColor {
|
||||
|
||||
public Color getColor() {
|
||||
return color.aquire(() -> {
|
||||
if (hex != null) {
|
||||
if(hex != null) {
|
||||
String v = (hex.startsWith("#") ? hex : "#" + hex).trim();
|
||||
try {
|
||||
return Color.decode(v);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -101,11 +101,11 @@ public class IrisColor {
|
||||
}
|
||||
|
||||
public int getAsRGB() {
|
||||
if (hex != null) {
|
||||
if(hex != null) {
|
||||
try {
|
||||
if (hex.startsWith("#")) hex = hex.substring(1);
|
||||
if(hex.startsWith("#")) hex = hex.substring(1);
|
||||
return Integer.parseInt(hex, 16);
|
||||
} catch (NumberFormatException e) {
|
||||
} catch(NumberFormatException e) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,17 +61,17 @@ public class IrisCommand {
|
||||
}
|
||||
|
||||
public void run(Location at) {
|
||||
if (!isValid(at.getWorld())) {
|
||||
if(!isValid(at.getWorld())) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (String command : commands) {
|
||||
for(String command : commands) {
|
||||
command = (command.startsWith("/") ? command.replaceFirst("/", "") : command)
|
||||
.replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX()))
|
||||
.replaceAll("\\Q{y}\\E", String.valueOf(at.getBlockY()))
|
||||
.replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ()));
|
||||
.replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX()))
|
||||
.replaceAll("\\Q{y}\\E", String.valueOf(at.getBlockY()))
|
||||
.replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ()));
|
||||
final String finalCommand = command;
|
||||
if (repeat) {
|
||||
if(repeat) {
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay, repeatDelay);
|
||||
} else {
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), finalCommand), delay);
|
||||
|
||||
@@ -70,18 +70,18 @@ public class IrisCommandRegistry {
|
||||
private boolean commandAllRandomLocations = true;
|
||||
|
||||
public void run(Player p) {
|
||||
if (rawCommands.isNotEmpty()) {
|
||||
if(rawCommands.isNotEmpty()) {
|
||||
Location part = p.getLocation().clone().add(
|
||||
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
|
||||
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
|
||||
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
|
||||
for (IrisCommand rawCommand : rawCommands) {
|
||||
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
|
||||
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
|
||||
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
|
||||
for(IrisCommand rawCommand : rawCommands) {
|
||||
rawCommand.run(part);
|
||||
if (commandAllRandomLocations) {
|
||||
if(commandAllRandomLocations) {
|
||||
part = p.getLocation().clone().add(
|
||||
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
|
||||
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
|
||||
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
|
||||
commandRandomAltX ? RNG.r.d(-commandOffsetX, commandOffsetX) : commandOffsetX,
|
||||
commandRandomAltY ? RNG.r.d(-commandOffsetY, commandOffsetY) : commandOffsetY,
|
||||
commandRandomAltZ ? RNG.r.d(-commandOffsetZ, commandOffsetZ) : commandOffsetZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -48,11 +48,11 @@ public class IrisCompat {
|
||||
J.attemptAsync(() -> IO.writeAll(new File(f.getParentFile(), "compat.default.json"), defa));
|
||||
|
||||
|
||||
if (!f.exists()) {
|
||||
if(!f.exists()) {
|
||||
J.a(() -> {
|
||||
try {
|
||||
IO.writeAll(f, defa);
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Iris.error("Failed to writeNodeData to compat file");
|
||||
Iris.reportError(e);
|
||||
}
|
||||
@@ -63,14 +63,14 @@ public class IrisCompat {
|
||||
try {
|
||||
IrisCompat rea = new Gson().fromJson(IO.readAll(f), IrisCompat.class);
|
||||
|
||||
for (IrisCompatabilityBlockFilter i : rea.getBlockFilters()) {
|
||||
for(IrisCompatabilityBlockFilter i : rea.getBlockFilters()) {
|
||||
def.getBlockFilters().add(i);
|
||||
}
|
||||
|
||||
for (IrisCompatabilityItemFilter i : rea.getItemFilters()) {
|
||||
for(IrisCompatabilityItemFilter i : rea.getItemFilters()) {
|
||||
def.getItemFilters().add(i);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
@@ -264,21 +264,21 @@ public class IrisCompat {
|
||||
|
||||
BlockData tx = B.getOrNull(buf);
|
||||
|
||||
if (tx != null) {
|
||||
if(tx != null) {
|
||||
return tx;
|
||||
}
|
||||
|
||||
searching:
|
||||
while (true) {
|
||||
if (err-- <= 0) {
|
||||
while(true) {
|
||||
if(err-- <= 0) {
|
||||
return B.get("STONE");
|
||||
}
|
||||
|
||||
for (IrisCompatabilityBlockFilter i : blockFilters) {
|
||||
if (i.getWhen().equalsIgnoreCase(buf)) {
|
||||
for(IrisCompatabilityBlockFilter i : blockFilters) {
|
||||
if(i.getWhen().equalsIgnoreCase(buf)) {
|
||||
BlockData b = i.getReplace();
|
||||
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -296,28 +296,28 @@ public class IrisCompat {
|
||||
int err = 16;
|
||||
Material txf = B.getMaterialOrNull(buf);
|
||||
|
||||
if (txf != null) {
|
||||
if(txf != null) {
|
||||
return txf;
|
||||
}
|
||||
|
||||
int nomore = 64;
|
||||
|
||||
searching:
|
||||
while (true) {
|
||||
if (nomore < 0) {
|
||||
while(true) {
|
||||
if(nomore < 0) {
|
||||
return B.getMaterial("STONE");
|
||||
}
|
||||
|
||||
nomore--;
|
||||
if (err-- <= 0) {
|
||||
if(err-- <= 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
for (IrisCompatabilityItemFilter i : itemFilters) {
|
||||
if (i.getWhen().equalsIgnoreCase(buf)) {
|
||||
for(IrisCompatabilityItemFilter i : itemFilters) {
|
||||
if(i.getWhen().equalsIgnoreCase(buf)) {
|
||||
Material b = i.getReplace();
|
||||
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
return b;
|
||||
}
|
||||
|
||||
@@ -332,28 +332,28 @@ public class IrisCompat {
|
||||
buf = n;
|
||||
BlockData tx = B.getOrNull(buf);
|
||||
|
||||
if (tx != null) {
|
||||
if(tx != null) {
|
||||
return tx.getMaterial();
|
||||
}
|
||||
nomore = 64;
|
||||
|
||||
searching:
|
||||
while (true) {
|
||||
if (nomore < 0) {
|
||||
while(true) {
|
||||
if(nomore < 0) {
|
||||
return B.getMaterial("STONE");
|
||||
}
|
||||
|
||||
nomore--;
|
||||
|
||||
if (err-- <= 0) {
|
||||
if(err-- <= 0) {
|
||||
return B.getMaterial("STONE");
|
||||
}
|
||||
|
||||
for (IrisCompatabilityBlockFilter i : blockFilters) {
|
||||
if (i.getWhen().equalsIgnoreCase(buf)) {
|
||||
for(IrisCompatabilityBlockFilter i : blockFilters) {
|
||||
if(i.getWhen().equalsIgnoreCase(buf)) {
|
||||
BlockData b = i.getReplace();
|
||||
|
||||
if (b != null) {
|
||||
if(b != null) {
|
||||
return b.getMaterial();
|
||||
}
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class IrisCompatabilityBlockFilter {
|
||||
{
|
||||
BlockData b = B.getOrNull(supplement);
|
||||
|
||||
if (b == null) {
|
||||
if(b == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class IrisCompatabilityItemFilter {
|
||||
{
|
||||
Material b = B.getMaterialOrNull(supplement);
|
||||
|
||||
if (b == null) {
|
||||
if(b == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -75,7 +75,7 @@ public class IrisDecorator {
|
||||
private int stackMax = 1;
|
||||
@DependsOn({"stackMin", "stackMax"})
|
||||
@Desc("Changes stackMin and stackMin from being absolute block heights and instead uses them as a percentage to scale the stack based on the cave height" +
|
||||
"\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height")
|
||||
"\n\nWithin a cave, setting them stackMin/max to 50 would make the stack 50% of the cave height")
|
||||
private boolean scaleStack = false;
|
||||
@Required
|
||||
@MinNumber(0)
|
||||
@@ -97,19 +97,19 @@ public class IrisDecorator {
|
||||
private double topThreshold = 1.0;
|
||||
|
||||
public int getHeight(RNG rng, double x, double z, IrisData data) {
|
||||
if (stackMin == stackMax) {
|
||||
if(stackMin == stackMax) {
|
||||
return stackMin;
|
||||
}
|
||||
|
||||
return getHeightGenerator(rng, data)
|
||||
.fit(stackMin, stackMax,
|
||||
x / heightVariance.getZoom(),
|
||||
z / heightVariance.getZoom()) + 1;
|
||||
.fit(stackMin, stackMax,
|
||||
x / heightVariance.getZoom(),
|
||||
z / heightVariance.getZoom()) + 1;
|
||||
}
|
||||
|
||||
public CNG getHeightGenerator(RNG rng, IrisData data) {
|
||||
return heightGenerator.aquire(() ->
|
||||
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data));
|
||||
heightVariance.create(rng.nextParallelRNG(getBlockData(data).size() + stackMax + stackMin), data));
|
||||
}
|
||||
|
||||
public CNG getGenerator(RNG rng, IrisData data) {
|
||||
@@ -118,9 +118,9 @@ public class IrisDecorator {
|
||||
|
||||
public CNG getVarianceGenerator(RNG rng, IrisData data) {
|
||||
return varianceGenerator.aquire(() ->
|
||||
variance.create(
|
||||
rng.nextParallelRNG(getBlockData(data).size()), data)
|
||||
.scale(1D / variance.getZoom()));
|
||||
variance.create(
|
||||
rng.nextParallelRNG(getBlockData(data).size()), data)
|
||||
.scale(1D / variance.getZoom()));
|
||||
}
|
||||
|
||||
public KList<IrisBlockData> add(String b) {
|
||||
@@ -129,7 +129,7 @@ public class IrisDecorator {
|
||||
}
|
||||
|
||||
public BlockData getBlockData(IrisBiome b, RNG rng, double x, double z, IrisData data) {
|
||||
if (getBlockData(data).isEmpty()) {
|
||||
if(getBlockData(data).isEmpty()) {
|
||||
Iris.warn("Empty Block Data for " + b.getName());
|
||||
return null;
|
||||
}
|
||||
@@ -137,8 +137,8 @@ public class IrisDecorator {
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
|
||||
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) {
|
||||
if (getBlockData(data).size() == 1) {
|
||||
if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) {
|
||||
if(getBlockData(data).size() == 1) {
|
||||
return getBlockData(data).get(0);
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ public class IrisDecorator {
|
||||
}
|
||||
|
||||
public BlockData getBlockData100(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
|
||||
if (getBlockData(data).isEmpty()) {
|
||||
if(getBlockData(data).isEmpty()) {
|
||||
Iris.warn("Empty Block Data for " + b.getName());
|
||||
return null;
|
||||
}
|
||||
@@ -158,13 +158,13 @@ public class IrisDecorator {
|
||||
double yy = y;
|
||||
double zz = z;
|
||||
|
||||
if (!getVarianceGenerator(rng, data).isStatic()) {
|
||||
if(!getVarianceGenerator(rng, data).isStatic()) {
|
||||
xx = x / style.getZoom();
|
||||
yy = y / style.getZoom();
|
||||
zz = z / style.getZoom();
|
||||
}
|
||||
|
||||
if (getBlockData(data).size() == 1) {
|
||||
if(getBlockData(data).size() == 1) {
|
||||
return getBlockData(data).get(0);
|
||||
}
|
||||
|
||||
@@ -172,15 +172,15 @@ public class IrisDecorator {
|
||||
}
|
||||
|
||||
public BlockData getBlockDataForTop(IrisBiome b, RNG rng, double x, double y, double z, IrisData data) {
|
||||
if (getBlockDataTops(data).isEmpty()) {
|
||||
if(getBlockDataTops(data).isEmpty()) {
|
||||
return getBlockData100(b, rng, x, y, z, data);
|
||||
}
|
||||
|
||||
double xx = x / style.getZoom();
|
||||
double zz = z / style.getZoom();
|
||||
|
||||
if (getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||
if (getBlockData(data).size() == 1) {
|
||||
if(getGenerator(rng, data).fitDouble(0D, 1D, xx, zz) <= chance) { //Exclude y from here
|
||||
if(getBlockData(data).size() == 1) {
|
||||
return getBlockDataTops(data).get(0);
|
||||
}
|
||||
|
||||
@@ -194,10 +194,10 @@ public class IrisDecorator {
|
||||
return blockData.aquire(() ->
|
||||
{
|
||||
KList<BlockData> blockData = new KList<>();
|
||||
for (IrisBlockData i : palette) {
|
||||
for(IrisBlockData i : palette) {
|
||||
BlockData bx = i.getBlockData(data);
|
||||
if (bx != null) {
|
||||
for (int n = 0; n < i.getWeight(); n++) {
|
||||
if(bx != null) {
|
||||
for(int n = 0; n < i.getWeight(); n++) {
|
||||
blockData.add(bx);
|
||||
}
|
||||
}
|
||||
@@ -211,10 +211,10 @@ public class IrisDecorator {
|
||||
return blockDataTops.aquire(() ->
|
||||
{
|
||||
KList<BlockData> blockDataTops = new KList<>();
|
||||
for (IrisBlockData i : topPalette) {
|
||||
for(IrisBlockData i : topPalette) {
|
||||
BlockData bx = i.getBlockData(data);
|
||||
if (bx != null) {
|
||||
for (int n = 0; n < i.getWeight(); n++) {
|
||||
if(bx != null) {
|
||||
for(int n = 0; n < i.getWeight(); n++) {
|
||||
blockDataTops.add(bx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ public class IrisDepositGenerator {
|
||||
RNG rngv = rng.nextParallelRNG(3957778);
|
||||
KList<IrisObject> objectsf = new KList<>();
|
||||
|
||||
for (int i = 0; i < varience; i++) {
|
||||
for(int i = 0; i < varience; i++) {
|
||||
objectsf.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598), rdata));
|
||||
}
|
||||
|
||||
@@ -108,10 +108,10 @@ public class IrisDepositGenerator {
|
||||
int w = dim / 2;
|
||||
IrisObject o = new IrisObject(dim, dim, dim);
|
||||
|
||||
if (s == 1) {
|
||||
if(s == 1) {
|
||||
o.getBlocks().put(o.getCenter(), nextBlock(rngv, rdata));
|
||||
} else {
|
||||
while (s > 0) {
|
||||
while(s > 0) {
|
||||
s--;
|
||||
BlockVector ang = new BlockVector(rngv.i(-w, w), rngv.i(-w, w), rngv.i(-w, w));
|
||||
BlockVector pos = o.getCenter().clone().add(ang).toBlockVector();
|
||||
@@ -131,10 +131,10 @@ public class IrisDepositGenerator {
|
||||
{
|
||||
KList<BlockData> blockData = new KList<>();
|
||||
|
||||
for (IrisBlockData ix : palette) {
|
||||
for(IrisBlockData ix : palette) {
|
||||
BlockData bx = ix.getBlockData(rdata);
|
||||
|
||||
if (bx != null) {
|
||||
if(bx != null) {
|
||||
blockData.add(bx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.loader.IrisRegistrant;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
@@ -230,14 +229,14 @@ public class IrisDimension extends IrisRegistrant {
|
||||
private KList<IrisOreGenerator> ores = new KList<>();
|
||||
|
||||
public BlockData generateOres(int x, int y, int z, RNG rng, IrisData data) {
|
||||
if (ores.isEmpty()) {
|
||||
if(ores.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
BlockData b = null;
|
||||
for (IrisOreGenerator i : ores) {
|
||||
for(IrisOreGenerator i : ores) {
|
||||
|
||||
b = i.generate(x,y,z,rng,data);
|
||||
if(b != null ){
|
||||
b = i.generate(x, y, z, rng, data);
|
||||
if(b != null) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
@@ -250,11 +249,11 @@ public class IrisDimension extends IrisRegistrant {
|
||||
int jump = strongholdJumpDistance;
|
||||
RNG rng = new RNG((seed * 223) + 12945);
|
||||
|
||||
for (int i = 0; i < maxStrongholds + 1; i++) {
|
||||
for(int i = 0; i < maxStrongholds + 1; i++) {
|
||||
int m = i + 1;
|
||||
pos.add(new Position2(
|
||||
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)),
|
||||
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D))
|
||||
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D)),
|
||||
(int) ((rng.i(jump * i) + (jump * i)) * (rng.b() ? -1D : 1D))
|
||||
));
|
||||
}
|
||||
|
||||
@@ -300,7 +299,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
public KList<IrisRegion> getAllRegions(DataProvider g) {
|
||||
KList<IrisRegion> r = new KList<>();
|
||||
|
||||
for (String i : getRegions()) {
|
||||
for(String i : getRegions()) {
|
||||
r.add(g.getData().getRegionLoader().load(i));
|
||||
}
|
||||
|
||||
@@ -310,7 +309,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
public KList<IrisRegion> getAllAnyRegions() {
|
||||
KList<IrisRegion> r = new KList<>();
|
||||
|
||||
for (String i : getRegions()) {
|
||||
for(String i : getRegions()) {
|
||||
r.add(IrisData.loadAnyRegion(i));
|
||||
}
|
||||
|
||||
@@ -324,8 +323,8 @@ public class IrisDimension extends IrisRegistrant {
|
||||
public KList<IrisBiome> getAllAnyBiomes() {
|
||||
KList<IrisBiome> r = new KList<>();
|
||||
|
||||
for (IrisRegion i : getAllAnyRegions()) {
|
||||
if (i == null) {
|
||||
for(IrisRegion i : getAllAnyRegions()) {
|
||||
if(i == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -336,7 +335,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public IrisGeneratorStyle getBiomeStyle(InferredType type) {
|
||||
switch (type) {
|
||||
switch(type) {
|
||||
case CAVE:
|
||||
return caveBiomeStyle;
|
||||
case LAND:
|
||||
@@ -358,14 +357,14 @@ public class IrisDimension extends IrisRegistrant {
|
||||
|
||||
IO.delete(new File(datapacks, "iris/data/" + getLoadKey().toLowerCase()));
|
||||
|
||||
for (IrisBiome i : getAllBiomes(data)) {
|
||||
if (i.isCustom()) {
|
||||
for(IrisBiome i : getAllBiomes(data)) {
|
||||
if(i.isCustom()) {
|
||||
write = true;
|
||||
|
||||
for (IrisBiomeCustom j : i.getCustomDerivitives()) {
|
||||
for(IrisBiomeCustom j : i.getCustomDerivitives()) {
|
||||
File output = new File(datapacks, "iris/data/" + getLoadKey().toLowerCase() + "/worldgen/biome/" + j.getId() + ".json");
|
||||
|
||||
if (!output.exists()) {
|
||||
if(!output.exists()) {
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@@ -373,7 +372,7 @@ public class IrisDimension extends IrisRegistrant {
|
||||
output.getParentFile().mkdirs();
|
||||
try {
|
||||
IO.writeAll(output, j.generateJson());
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -381,18 +380,18 @@ public class IrisDimension extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
if (write) {
|
||||
if(write) {
|
||||
File mcm = new File(datapacks, "iris/pack.mcmeta");
|
||||
try {
|
||||
IO.writeAll(mcm, """
|
||||
{
|
||||
"pack": {
|
||||
"description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.",
|
||||
"pack_format": 7
|
||||
}
|
||||
{
|
||||
"pack": {
|
||||
"description": "Iris Data Pack. This pack contains all installed Iris Packs' resources.",
|
||||
"pack_format": 7
|
||||
}
|
||||
""");
|
||||
} catch (IOException e) {
|
||||
}
|
||||
""");
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public static IrisDirection getDirection(BlockFace f) {
|
||||
return switch (f) {
|
||||
return switch(f) {
|
||||
case DOWN -> DOWN_NEGATIVE_Y;
|
||||
case EAST, EAST_NORTH_EAST, EAST_SOUTH_EAST -> EAST_POSITIVE_X;
|
||||
case NORTH, NORTH_NORTH_WEST, NORTH_EAST, NORTH_NORTH_EAST, NORTH_WEST -> NORTH_NEGATIVE_Z;
|
||||
@@ -79,9 +79,9 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public static IrisDirection fromJigsawBlock(String direction) {
|
||||
for (IrisDirection i : IrisDirection.values()) {
|
||||
if (i.name().toLowerCase().split("\\Q_\\E")[0]
|
||||
.equals(direction.split("\\Q_\\E")[0])) {
|
||||
for(IrisDirection i : IrisDirection.values()) {
|
||||
if(i.name().toLowerCase().split("\\Q_\\E")[0]
|
||||
.equals(direction.split("\\Q_\\E")[0])) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public static IrisDirection getDirection(Jigsaw.Orientation orientation) {
|
||||
return switch (orientation) {
|
||||
return switch(orientation) {
|
||||
case DOWN_EAST, UP_EAST, EAST_UP -> EAST_POSITIVE_X;
|
||||
case DOWN_NORTH, UP_NORTH, NORTH_UP -> NORTH_NEGATIVE_Z;
|
||||
case DOWN_SOUTH, UP_SOUTH, SOUTH_UP -> SOUTH_POSITIVE_Z;
|
||||
@@ -103,11 +103,11 @@ public enum IrisDirection {
|
||||
double m = Double.MAX_VALUE;
|
||||
IrisDirection s = null;
|
||||
|
||||
for (IrisDirection i : values()) {
|
||||
for(IrisDirection i : values()) {
|
||||
Vector x = i.toVector();
|
||||
double g = x.distance(v);
|
||||
|
||||
if (g < m) {
|
||||
if(g < m) {
|
||||
m = g;
|
||||
s = i;
|
||||
}
|
||||
@@ -120,11 +120,11 @@ public enum IrisDirection {
|
||||
double m = Double.MAX_VALUE;
|
||||
IrisDirection s = null;
|
||||
|
||||
for (IrisDirection i : d) {
|
||||
for(IrisDirection i : d) {
|
||||
Vector x = i.toVector();
|
||||
double g = x.distance(v);
|
||||
|
||||
if (g < m) {
|
||||
if(g < m) {
|
||||
m = g;
|
||||
s = i;
|
||||
}
|
||||
@@ -137,11 +137,11 @@ public enum IrisDirection {
|
||||
double m = Double.MAX_VALUE;
|
||||
IrisDirection s = null;
|
||||
|
||||
for (IrisDirection i : d) {
|
||||
for(IrisDirection i : d) {
|
||||
Vector x = i.toVector();
|
||||
double g = x.distance(v);
|
||||
|
||||
if (g < m) {
|
||||
if(g < m) {
|
||||
m = g;
|
||||
s = i;
|
||||
}
|
||||
@@ -157,8 +157,8 @@ public enum IrisDirection {
|
||||
public static IrisDirection getDirection(Vector v) {
|
||||
Vector k = VectorMath.triNormalize(v.clone().normalize());
|
||||
|
||||
for (IrisDirection i : udnews()) {
|
||||
if (i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) {
|
||||
for(IrisDirection i : udnews()) {
|
||||
if(i.x == k.getBlockX() && i.y == k.getBlockY() && i.z == k.getBlockZ()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -174,24 +174,25 @@ public enum IrisDirection {
|
||||
* Get the directional value from the given byte from common directional blocks
|
||||
* (MUST BE BETWEEN 0 and 5 INCLUSIVE)
|
||||
*
|
||||
* @param b the byte
|
||||
* @param b
|
||||
* the byte
|
||||
* @return the direction or null if the byte is outside of the inclusive range
|
||||
* 0-5
|
||||
*/
|
||||
public static IrisDirection fromByte(byte b) {
|
||||
if (b > 5 || b < 0) {
|
||||
if(b > 5 || b < 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (b == 0) {
|
||||
if(b == 0) {
|
||||
return DOWN_NEGATIVE_Y;
|
||||
} else if (b == 1) {
|
||||
} else if(b == 1) {
|
||||
return UP_POSITIVE_Y;
|
||||
} else if (b == 2) {
|
||||
} else if(b == 2) {
|
||||
return NORTH_NEGATIVE_Z;
|
||||
} else if (b == 3) {
|
||||
} else if(b == 3) {
|
||||
return SOUTH_POSITIVE_Z;
|
||||
} else if (b == 4) {
|
||||
} else if(b == 4) {
|
||||
return WEST_NEGATIVE_X;
|
||||
} else {
|
||||
return EAST_POSITIVE_X;
|
||||
@@ -199,25 +200,25 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public static void calculatePermutations() {
|
||||
if (permute != null) {
|
||||
if(permute != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
permute = new KMap<>();
|
||||
|
||||
for (IrisDirection i : udnews()) {
|
||||
for (IrisDirection j : udnews()) {
|
||||
for(IrisDirection i : udnews()) {
|
||||
for(IrisDirection j : udnews()) {
|
||||
GBiset<IrisDirection, IrisDirection> b = new GBiset<>(i, j);
|
||||
|
||||
if (i.equals(j)) {
|
||||
if(i.equals(j)) {
|
||||
permute.put(b, new DOP("DIRECT") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return v;
|
||||
}
|
||||
});
|
||||
} else if (i.reverse().equals(j)) {
|
||||
if (i.isVertical()) {
|
||||
} else if(i.reverse().equals(j)) {
|
||||
if(i.isVertical()) {
|
||||
permute.put(b, new DOP("R180CCZ") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
@@ -232,42 +233,42 @@ public enum IrisDirection {
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CX(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CX") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CX(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CCX(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CCX") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CCX(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CY(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CY") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CY(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CCY(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CCY") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CCY(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CZ(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CZ") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
return VectorMath.rotate90CZ(v);
|
||||
}
|
||||
});
|
||||
} else if (getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) {
|
||||
} else if(getDirection(VectorMath.rotate90CCZ(i.toVector())).equals(j)) {
|
||||
permute.put(b, new DOP("R90CCZ") {
|
||||
@Override
|
||||
public Vector op(Vector v) {
|
||||
@@ -288,7 +289,7 @@ public enum IrisDirection {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case DOWN_NEGATIVE_Y -> "Down";
|
||||
case EAST_POSITIVE_X -> "East";
|
||||
case NORTH_NEGATIVE_Z -> "North";
|
||||
@@ -308,7 +309,7 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public boolean isCrooked(IrisDirection to) {
|
||||
if (equals(to.reverse())) {
|
||||
if(equals(to.reverse())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -318,9 +319,9 @@ public enum IrisDirection {
|
||||
public Vector angle(Vector initial, IrisDirection d) {
|
||||
calculatePermutations();
|
||||
|
||||
for (Map.Entry<GBiset<IrisDirection, IrisDirection>, DOP> entry : permute.entrySet()) {
|
||||
for(Map.Entry<GBiset<IrisDirection, IrisDirection>, DOP> entry : permute.entrySet()) {
|
||||
GBiset<IrisDirection, IrisDirection> i = entry.getKey();
|
||||
if (i.getA().equals(this) && i.getB().equals(d)) {
|
||||
if(i.getA().equals(this) && i.getB().equals(d)) {
|
||||
return entry.getValue().op(initial);
|
||||
}
|
||||
}
|
||||
@@ -329,7 +330,7 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public IrisDirection reverse() {
|
||||
switch (this) {
|
||||
switch(this) {
|
||||
case DOWN_NEGATIVE_Y:
|
||||
return UP_POSITIVE_Y;
|
||||
case EAST_POSITIVE_X:
|
||||
@@ -371,7 +372,7 @@ public enum IrisDirection {
|
||||
* @return the byte value
|
||||
*/
|
||||
public byte byteValue() {
|
||||
switch (this) {
|
||||
switch(this) {
|
||||
case DOWN_NEGATIVE_Y:
|
||||
return 0;
|
||||
case EAST_POSITIVE_X:
|
||||
@@ -392,7 +393,7 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public BlockFace getFace() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case DOWN_NEGATIVE_Y -> BlockFace.DOWN;
|
||||
case EAST_POSITIVE_X -> BlockFace.EAST;
|
||||
case NORTH_NEGATIVE_Z -> BlockFace.NORTH;
|
||||
@@ -404,7 +405,7 @@ public enum IrisDirection {
|
||||
}
|
||||
|
||||
public Axis getAxis() {
|
||||
return switch (this) {
|
||||
return switch(this) {
|
||||
case DOWN_NEGATIVE_Y, UP_POSITIVE_Y -> Axis.Y;
|
||||
case EAST_POSITIVE_X, WEST_NEGATIVE_X -> Axis.X;
|
||||
case NORTH_NEGATIVE_Z, SOUTH_POSITIVE_Z -> Axis.Z;
|
||||
|
||||
@@ -65,15 +65,15 @@ public class IrisDuration {
|
||||
|
||||
public long toMilliseconds() {
|
||||
return getMilliseconds()
|
||||
+ TimeUnit.SECONDS.toMillis(getSeconds())
|
||||
+ TimeUnit.MINUTES.toMillis(getMinutes())
|
||||
+ TimeUnit.HOURS.toMillis(getHours())
|
||||
+ TimeUnit.DAYS.toMillis(getDays())
|
||||
+ (getMinecraftTicks() * 50L)
|
||||
+ (getMinecraftHours() * 50000L)
|
||||
+ (getMinecraftWeeks() * 50000L)
|
||||
+ (getMinecraftDays() * 24000L)
|
||||
+ (getMinecraftWeeks() * 168000L)
|
||||
+ (getMinecraftLunarCycles() * 192000L);
|
||||
+ TimeUnit.SECONDS.toMillis(getSeconds())
|
||||
+ TimeUnit.MINUTES.toMillis(getMinutes())
|
||||
+ TimeUnit.HOURS.toMillis(getHours())
|
||||
+ TimeUnit.DAYS.toMillis(getDays())
|
||||
+ (getMinecraftTicks() * 50L)
|
||||
+ (getMinecraftHours() * 50000L)
|
||||
+ (getMinecraftWeeks() * 50000L)
|
||||
+ (getMinecraftDays() * 24000L)
|
||||
+ (getMinecraftWeeks() * 168000L)
|
||||
+ (getMinecraftLunarCycles() * 192000L);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,19 +166,19 @@ public class IrisEffect {
|
||||
{
|
||||
PotionEffectType t = PotionEffectType.LUCK;
|
||||
|
||||
if (getPotionEffect().isEmpty()) {
|
||||
if(getPotionEffect().isEmpty()) {
|
||||
return t;
|
||||
}
|
||||
|
||||
try {
|
||||
for (PotionEffectType i : PotionEffectType.values()) {
|
||||
if (i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) {
|
||||
for(PotionEffectType i : PotionEffectType.values()) {
|
||||
if(i.getName().toUpperCase().replaceAll("\\Q \\E", "_").equals(getPotionEffect())) {
|
||||
t = i;
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -190,50 +190,50 @@ public class IrisEffect {
|
||||
}
|
||||
|
||||
public void apply(Player p, Engine g) {
|
||||
if (!canTick()) {
|
||||
if(!canTick()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (RNG.r.nextInt(chance) != 0) {
|
||||
if(RNG.r.nextInt(chance) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sound != null) {
|
||||
if(sound != null) {
|
||||
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
|
||||
|
||||
J.s(() -> p.playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch)));
|
||||
}
|
||||
|
||||
if (particleEffect != null) {
|
||||
if(particleEffect != null) {
|
||||
Location part = p.getLocation().clone().add(p.getLocation().getDirection().clone().multiply(RNG.r.i(particleDistance) + particleAway)).clone().add(p.getLocation().getDirection().clone().rotateAroundY(Math.toRadians(90)).multiply(RNG.r.d(-particleDistanceWidth, particleDistanceWidth)));
|
||||
|
||||
part.setY(Math.round(g.getHeight(part.getBlockX(), part.getBlockZ())) + 1);
|
||||
part.add(RNG.r.d(), 0, RNG.r.d());
|
||||
if (extra != 0) {
|
||||
if(extra != 0) {
|
||||
J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
|
||||
part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
|
||||
extra));
|
||||
part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
|
||||
extra));
|
||||
} else {
|
||||
J.s(() -> p.spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
|
||||
}
|
||||
}
|
||||
|
||||
if (commandRegistry != null) {
|
||||
if(commandRegistry != null) {
|
||||
commandRegistry.run(p);
|
||||
}
|
||||
|
||||
if (potionStrength > -1) {
|
||||
if (p.hasPotionEffect(getRealType())) {
|
||||
if(potionStrength > -1) {
|
||||
if(p.hasPotionEffect(getRealType())) {
|
||||
PotionEffect e = p.getPotionEffect(getRealType());
|
||||
if (e.getAmplifier() > getPotionStrength()) {
|
||||
if(e.getAmplifier() > getPotionStrength()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -241,45 +241,45 @@ public class IrisEffect {
|
||||
}
|
||||
|
||||
J.s(() -> p.addPotionEffect(new PotionEffect(getRealType(),
|
||||
RNG.r.i(Math.min(potionTicksMax, potionTicksMin),
|
||||
Math.max(potionTicksMax, potionTicksMin)),
|
||||
getPotionStrength(),
|
||||
true, false, false)));
|
||||
RNG.r.i(Math.min(potionTicksMax, potionTicksMin),
|
||||
Math.max(potionTicksMax, potionTicksMin)),
|
||||
getPotionStrength(),
|
||||
true, false, false)));
|
||||
}
|
||||
}
|
||||
|
||||
public void apply(Entity p) {
|
||||
if (!canTick()) {
|
||||
if(!canTick()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (RNG.r.nextInt(chance) != 0) {
|
||||
if(RNG.r.nextInt(chance) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (sound != null) {
|
||||
if(sound != null) {
|
||||
Location part = p.getLocation().clone().add(RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance), RNG.r.i(-soundDistance, soundDistance));
|
||||
|
||||
J.s(() -> p.getWorld().playSound(part, getSound(), (float) volume, (float) RNG.r.d(minPitch, maxPitch)));
|
||||
}
|
||||
|
||||
if (particleEffect != null) {
|
||||
if(particleEffect != null) {
|
||||
Location part = p.getLocation().clone().add(0, 0.25, 0).add(new Vector(1, 1, 1).multiply(RNG.r.d())).subtract(new Vector(1, 1, 1).multiply(RNG.r.d()));
|
||||
part.add(RNG.r.d(), 0, RNG.r.d());
|
||||
if (extra != 0) {
|
||||
if(extra != 0) {
|
||||
J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset),
|
||||
part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
|
||||
extra));
|
||||
part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ,
|
||||
extra));
|
||||
} else {
|
||||
J.s(() -> p.getWorld().spawnParticle(particleEffect, part.getX(), part.getY() + RNG.r.i(particleOffset), part.getZ(),
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
|
||||
particleCount,
|
||||
randomAltX ? RNG.r.d(-particleAltX, particleAltX) : particleAltX,
|
||||
randomAltY ? RNG.r.d(-particleAltY, particleAltY) : particleAltY,
|
||||
randomAltZ ? RNG.r.d(-particleAltZ, particleAltZ) : particleAltZ));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,9 +53,9 @@ public class IrisElipsoid implements IRare {
|
||||
@SuppressWarnings("SuspiciousNameCombination")
|
||||
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z) {
|
||||
writer.setElipsoid(x, y, z,
|
||||
xRadius.get(rng, z, y, engine.getData()),
|
||||
yRadius.get(rng, x, z, engine.getData()),
|
||||
zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0)));
|
||||
xRadius.get(rng, z, y, engine.getData()),
|
||||
yRadius.get(rng, x, z, engine.getData()),
|
||||
zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome(), 0)));
|
||||
}
|
||||
|
||||
public double maxSize() {
|
||||
|
||||
@@ -61,25 +61,25 @@ public class IrisEnchantment {
|
||||
|
||||
public void apply(RNG rng, ItemMeta meta) {
|
||||
try {
|
||||
if (rng.nextDouble() < chance) {
|
||||
if (meta instanceof EnchantmentStorageMeta) {
|
||||
if(rng.nextDouble() < chance) {
|
||||
if(meta instanceof EnchantmentStorageMeta) {
|
||||
((EnchantmentStorageMeta) meta).addStoredEnchant(getEnchant(), getLevel(rng), true);
|
||||
return;
|
||||
}
|
||||
meta.addEnchant(getEnchant(), getLevel(rng), true);
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Enchantment getEnchant() {
|
||||
for (Field i : Enchantment.class.getDeclaredFields()) {
|
||||
if (i.getType().equals(Enchantment.class) && i.getName().equals(getEnchantment())) {
|
||||
for(Field i : Enchantment.class.getDeclaredFields()) {
|
||||
if(i.getType().equals(Enchantment.class) && i.getName().equals(getEnchantment())) {
|
||||
try {
|
||||
return (Enchantment) i.get(null);
|
||||
} catch (IllegalArgumentException | IllegalAccessException e) {
|
||||
} catch(IllegalArgumentException | IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
@@ -28,10 +28,10 @@ public class IrisEngineChunkData {
|
||||
private KList<IrisEngineSpawnerCooldown> cooldowns = new KList<>();
|
||||
|
||||
public void cleanup(Engine engine) {
|
||||
for (IrisEngineSpawnerCooldown i : getCooldowns().copy()) {
|
||||
for(IrisEngineSpawnerCooldown i : getCooldowns().copy()) {
|
||||
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
|
||||
|
||||
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
|
||||
if(sp == null || i.canSpawn(sp.getMaximumRate())) {
|
||||
getCooldowns().remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,8 +38,8 @@ public class IrisEngineData {
|
||||
public IrisEngineChunkData getChunk(int x, int z) {
|
||||
long k = Cache.key(x, z);
|
||||
|
||||
for (IrisEngineChunkData i : chunks) {
|
||||
if (i.getChunk() == k) {
|
||||
for(IrisEngineChunkData i : chunks) {
|
||||
if(i.getChunk() == k) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -51,18 +51,18 @@ public class IrisEngineData {
|
||||
}
|
||||
|
||||
public void cleanup(Engine engine) {
|
||||
for (IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) {
|
||||
for(IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) {
|
||||
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
|
||||
|
||||
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
|
||||
if(sp == null || i.canSpawn(sp.getMaximumRate())) {
|
||||
getSpawnerCooldowns().remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
for (IrisEngineChunkData i : chunks.copy()) {
|
||||
for(IrisEngineChunkData i : chunks.copy()) {
|
||||
i.cleanup(engine);
|
||||
|
||||
if (i.isEmpty()) {
|
||||
if(i.isEmpty()) {
|
||||
getChunks().remove(i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,22 +186,22 @@ public class IrisEntity extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public Entity spawn(Engine gen, Location at, RNG rng) {
|
||||
if (!Chunks.isSafe(at)) {
|
||||
if(!Chunks.isSafe(at)) {
|
||||
return null;
|
||||
}
|
||||
if (isSpawnEffectRiseOutOfGround()) {
|
||||
if(isSpawnEffectRiseOutOfGround()) {
|
||||
AtomicReference<Location> f = new AtomicReference<>(at);
|
||||
try {
|
||||
J.sfut(() -> {
|
||||
if (Chunks.hasPlayersNearby(f.get())) {
|
||||
if(Chunks.hasPlayersNearby(f.get())) {
|
||||
Location b = f.get().clone();
|
||||
Location start = new Location(b.getWorld(), b.getX(), b.getY() - 5, b.getZ());
|
||||
f.set(start);
|
||||
}
|
||||
}).get();
|
||||
} catch (InterruptedException e) {
|
||||
} catch(InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
} catch (ExecutionException e) {
|
||||
} catch(ExecutionException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
at = f.get();
|
||||
@@ -209,23 +209,23 @@ public class IrisEntity extends IrisRegistrant {
|
||||
|
||||
Entity ee = doSpawn(at);
|
||||
|
||||
if (ee == null && !Chunks.isSafe(at)) {
|
||||
if(ee == null && !Chunks.isSafe(at)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!spawnerScript.isEmpty() && ee == null) {
|
||||
synchronized (this) {
|
||||
if(!spawnerScript.isEmpty() && ee == null) {
|
||||
synchronized(this) {
|
||||
gen.getExecution().getAPI().setLocation(at);
|
||||
try {
|
||||
ee = (Entity) gen.getExecution().evaluate(spawnerScript);
|
||||
} catch (Throwable ex) {
|
||||
} catch(Throwable ex) {
|
||||
Iris.error("You must return an Entity in your scripts to use entity scripts!");
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ee == null) {
|
||||
if(ee == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -239,25 +239,25 @@ public class IrisEntity extends IrisRegistrant {
|
||||
e.setPersistent(isKeepEntity() || IrisSettings.get().getWorld().isForcePersistEntities());
|
||||
|
||||
int gg = 0;
|
||||
for (IrisEntity i : passengers) {
|
||||
for(IrisEntity i : passengers) {
|
||||
Entity passenger = i.spawn(gen, at, rng.nextParallelRNG(234858 + gg++));
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
if(!Bukkit.isPrimaryThread()) {
|
||||
J.s(() -> e.addPassenger(passenger));
|
||||
}
|
||||
}
|
||||
|
||||
if (e instanceof Attributable) {
|
||||
if(e instanceof Attributable) {
|
||||
Attributable a = (Attributable) e;
|
||||
|
||||
for (IrisAttributeModifier i : getAttributes()) {
|
||||
for(IrisAttributeModifier i : getAttributes()) {
|
||||
i.apply(rng, a);
|
||||
}
|
||||
}
|
||||
|
||||
if (e instanceof Lootable) {
|
||||
if(e instanceof Lootable) {
|
||||
Lootable l = (Lootable) e;
|
||||
|
||||
if (getLoot().getTables().isNotEmpty()) {
|
||||
if(getLoot().getTables().isNotEmpty()) {
|
||||
Location finalAt = at;
|
||||
l.setLootTable(new LootTable() {
|
||||
@Override
|
||||
@@ -269,7 +269,7 @@ public class IrisEntity extends IrisRegistrant {
|
||||
public Collection<ItemStack> populateLoot(Random random, LootContext context) {
|
||||
KList<ItemStack> items = new KList<>();
|
||||
|
||||
for (String fi : getLoot().getTables()) {
|
||||
for(String fi : getLoot().getTables()) {
|
||||
IrisLootTable i = gen.getData().getLootLoader().load(fi);
|
||||
items.addAll(i.getLoot(gen.isStudio(), false, rng.nextParallelRNG(345911), InventorySlotType.STORAGE, finalAt.getBlockX(), finalAt.getBlockY(), finalAt.getBlockZ(), 8, 4));
|
||||
}
|
||||
@@ -279,7 +279,7 @@ public class IrisEntity extends IrisRegistrant {
|
||||
|
||||
@Override
|
||||
public void fillInventory(Inventory inventory, Random random, LootContext context) {
|
||||
for (ItemStack i : populateLoot(random, context)) {
|
||||
for(ItemStack i : populateLoot(random, context)) {
|
||||
inventory.addItem(i);
|
||||
}
|
||||
|
||||
@@ -289,52 +289,52 @@ public class IrisEntity extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
if (e instanceof LivingEntity) {
|
||||
if(e instanceof LivingEntity) {
|
||||
LivingEntity l = (LivingEntity) e;
|
||||
l.setAI(isAi());
|
||||
l.setCanPickupItems(isPickupItems());
|
||||
|
||||
if (getLeashHolder() != null) {
|
||||
if(getLeashHolder() != null) {
|
||||
l.setLeashHolder(getLeashHolder().spawn(gen, at, rng.nextParallelRNG(234548)));
|
||||
}
|
||||
|
||||
l.setRemoveWhenFarAway(isRemovable());
|
||||
|
||||
if (getHelmet() != null && rng.i(1, getHelmet().getRarity()) == 1) {
|
||||
if(getHelmet() != null && rng.i(1, getHelmet().getRarity()) == 1) {
|
||||
l.getEquipment().setHelmet(getHelmet().get(gen.isStudio(), rng));
|
||||
}
|
||||
|
||||
if (getChestplate() != null && rng.i(1, getChestplate().getRarity()) == 1) {
|
||||
if(getChestplate() != null && rng.i(1, getChestplate().getRarity()) == 1) {
|
||||
l.getEquipment().setChestplate(getChestplate().get(gen.isStudio(), rng));
|
||||
}
|
||||
|
||||
if (getLeggings() != null && rng.i(1, getLeggings().getRarity()) == 1) {
|
||||
if(getLeggings() != null && rng.i(1, getLeggings().getRarity()) == 1) {
|
||||
l.getEquipment().setLeggings(getLeggings().get(gen.isStudio(), rng));
|
||||
}
|
||||
|
||||
if (getBoots() != null && rng.i(1, getBoots().getRarity()) == 1) {
|
||||
if(getBoots() != null && rng.i(1, getBoots().getRarity()) == 1) {
|
||||
l.getEquipment().setBoots(getBoots().get(gen.isStudio(), rng));
|
||||
}
|
||||
|
||||
if (getMainHand() != null && rng.i(1, getMainHand().getRarity()) == 1) {
|
||||
if(getMainHand() != null && rng.i(1, getMainHand().getRarity()) == 1) {
|
||||
l.getEquipment().setItemInMainHand(getMainHand().get(gen.isStudio(), rng));
|
||||
}
|
||||
|
||||
if (getOffHand() != null && rng.i(1, getOffHand().getRarity()) == 1) {
|
||||
if(getOffHand() != null && rng.i(1, getOffHand().getRarity()) == 1) {
|
||||
l.getEquipment().setItemInOffHand(getOffHand().get(gen.isStudio(), rng));
|
||||
}
|
||||
}
|
||||
|
||||
if (e instanceof Ageable && isBaby()) {
|
||||
if(e instanceof Ageable && isBaby()) {
|
||||
((Ageable) e).setBaby();
|
||||
}
|
||||
|
||||
if (e instanceof Panda) {
|
||||
if(e instanceof Panda) {
|
||||
((Panda) e).setMainGene(getPandaMainGene());
|
||||
((Panda) e).setMainGene(getPandaHiddenGene());
|
||||
}
|
||||
|
||||
if (e instanceof Villager) {
|
||||
if(e instanceof Villager) {
|
||||
Villager villager = (Villager) e;
|
||||
villager.setRemoveWhenFarAway(false);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () -> {
|
||||
@@ -342,27 +342,27 @@ public class IrisEntity extends IrisRegistrant {
|
||||
}, 1);
|
||||
}
|
||||
|
||||
if (e instanceof Mob) {
|
||||
if(e instanceof Mob) {
|
||||
Mob m = (Mob) e;
|
||||
m.setAware(isAware());
|
||||
}
|
||||
|
||||
if (spawnEffect != null) {
|
||||
if(spawnEffect != null) {
|
||||
spawnEffect.apply(e);
|
||||
}
|
||||
|
||||
if (postSpawnScripts.isNotEmpty()) {
|
||||
synchronized (this) {
|
||||
if(postSpawnScripts.isNotEmpty()) {
|
||||
synchronized(this) {
|
||||
gen.getExecution().getAPI().setLocation(at);
|
||||
gen.getExecution().getAPI().setEntity(ee);
|
||||
|
||||
for (String i : postSpawnScripts) {
|
||||
for(String i : postSpawnScripts) {
|
||||
gen.getExecution().execute(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (rawCommands.isNotEmpty()) {
|
||||
if(rawCommands.isNotEmpty()) {
|
||||
final Location fat = at;
|
||||
rawCommands.forEach(r -> r.run(fat));
|
||||
}
|
||||
@@ -370,7 +370,7 @@ public class IrisEntity extends IrisRegistrant {
|
||||
Location finalAt1 = at;
|
||||
|
||||
J.s(() -> {
|
||||
if (isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity && Chunks.hasPlayersNearby(finalAt1)) {
|
||||
if(isSpawnEffectRiseOutOfGround() && e instanceof LivingEntity && Chunks.hasPlayersNearby(finalAt1)) {
|
||||
Location start = finalAt1.clone();
|
||||
e.setInvulnerable(true);
|
||||
((LivingEntity) e).setAI(false);
|
||||
@@ -379,17 +379,17 @@ public class IrisEntity extends IrisRegistrant {
|
||||
AtomicInteger t = new AtomicInteger(0);
|
||||
AtomicInteger v = new AtomicInteger(0);
|
||||
v.set(J.sr(() -> {
|
||||
if (t.get() > 100) {
|
||||
if(t.get() > 100) {
|
||||
J.csr(v.get());
|
||||
return;
|
||||
}
|
||||
|
||||
t.incrementAndGet();
|
||||
if (e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid()) {
|
||||
if(e.getLocation().getBlock().getType().isSolid() || ((LivingEntity) e).getEyeLocation().getBlock().getType().isSolid()) {
|
||||
e.teleport(start.add(new Vector(0, 0.1, 0)));
|
||||
ItemStack itemCrackData = new ItemStack(((LivingEntity) e).getEyeLocation().clone().subtract(0, 2, 0).getBlock().getBlockData().getMaterial());
|
||||
e.getWorld().spawnParticle(Particle.ITEM_CRACK, ((LivingEntity) e).getEyeLocation(), 6, 0.2, 0.4, 0.2, 0.06f, itemCrackData);
|
||||
if (M.r(0.2)) {
|
||||
if(M.r(0.2)) {
|
||||
e.getWorld().playSound(e.getLocation(), Sound.BLOCK_CHORUS_FLOWER_GROW, 0.8f, 0.1f);
|
||||
}
|
||||
} else {
|
||||
@@ -410,11 +410,11 @@ public class IrisEntity extends IrisRegistrant {
|
||||
private int surfaceY(Location l) {
|
||||
int m = l.getBlockY();
|
||||
|
||||
while (m-- > 0) {
|
||||
while(m-- > 0) {
|
||||
Location ll = l.clone();
|
||||
ll.setY(m);
|
||||
|
||||
if (ll.getBlock().getType().isSolid()) {
|
||||
if(ll.getBlock().getType().isSolid()) {
|
||||
return m;
|
||||
}
|
||||
}
|
||||
@@ -423,30 +423,30 @@ public class IrisEntity extends IrisRegistrant {
|
||||
}
|
||||
|
||||
private Entity doSpawn(Location at) {
|
||||
if (!Chunks.isSafe(at)) {
|
||||
if(!Chunks.isSafe(at)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (type.equals(EntityType.UNKNOWN)) {
|
||||
if(type.equals(EntityType.UNKNOWN)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!Bukkit.isPrimaryThread()) {
|
||||
if(!Bukkit.isPrimaryThread()) {
|
||||
// Someone called spawn (worldedit maybe?) on a non server thread
|
||||
// Due to the structure of iris, we will call it sync and busy wait until it's done.
|
||||
AtomicReference<Entity> ae = new AtomicReference<>();
|
||||
|
||||
try {
|
||||
J.s(() -> ae.set(doSpawn(at)));
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
return null;
|
||||
}
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
|
||||
while (ae.get() == null) {
|
||||
while(ae.get() == null) {
|
||||
J.sleep(25);
|
||||
|
||||
if (p.getMilliseconds() > 500) {
|
||||
if(p.getMilliseconds() > 500) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -454,8 +454,8 @@ public class IrisEntity extends IrisRegistrant {
|
||||
return ae.get();
|
||||
}
|
||||
|
||||
if (isSpecialType()) {
|
||||
if (specialType.toLowerCase().startsWith("mythicmobs:")) {
|
||||
if(isSpecialType()) {
|
||||
if(specialType.toLowerCase().startsWith("mythicmobs:")) {
|
||||
return Iris.linkMythicMobs.spawnMob(specialType.substring(11), at);
|
||||
} else {
|
||||
Iris.warn("Invalid mob type to spawn: '" + specialType + "'!");
|
||||
|
||||
@@ -70,28 +70,28 @@ public class IrisEntitySpawn implements IRare {
|
||||
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
|
||||
int s = 0;
|
||||
|
||||
if (spawns > 0) {
|
||||
for (int id = 0; id < spawns; id++) {
|
||||
if(spawns > 0) {
|
||||
for(int id = 0; id < spawns; id++) {
|
||||
int x = (c.getX() * 16) + rng.i(15);
|
||||
int z = (c.getZ() * 16) + rng.i(15);
|
||||
int h = gen.getHeight(x, z, true);
|
||||
int hf = gen.getHeight(x, z, false);
|
||||
Location l = switch (getReferenceSpawner().getGroup()) {
|
||||
Location l = switch(getReferenceSpawner().getGroup()) {
|
||||
case NORMAL -> new Location(c.getWorld(), x, hf + 1, z);
|
||||
case CAVE -> gen.getMantle().findMarkers(c.getX(), c.getZ(), MarkerMatter.CAVE_FLOOR)
|
||||
.convert((i) -> i.toLocation(c.getWorld()).add(0, 1, 0)).getRandom(rng);
|
||||
.convert((i) -> i.toLocation(c.getWorld()).add(0, 1, 0)).getRandom(rng);
|
||||
case UNDERWATER, BEACH -> new Location(c.getWorld(), x, rng.i(h + 1, hf), z);
|
||||
};
|
||||
|
||||
if (l != null) {
|
||||
if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
|
||||
if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
|
||||
if (spawn100(gen, l) != null) {
|
||||
if(l != null) {
|
||||
if(referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
|
||||
if(referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
|
||||
if(spawn100(gen, l) != null) {
|
||||
s++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (spawn100(gen, l) != null) {
|
||||
if(spawn100(gen, l) != null) {
|
||||
s++;
|
||||
}
|
||||
}
|
||||
@@ -106,28 +106,28 @@ public class IrisEntitySpawn implements IRare {
|
||||
int spawns = minSpawns == maxSpawns ? minSpawns : rng.i(Math.min(minSpawns, maxSpawns), Math.max(minSpawns, maxSpawns));
|
||||
int s = 0;
|
||||
|
||||
if (!gen.getWorld().tryGetRealWorld()) {
|
||||
if(!gen.getWorld().tryGetRealWorld()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
World world = gen.getWorld().realWorld();
|
||||
if (spawns > 0) {
|
||||
if(spawns > 0) {
|
||||
|
||||
if (referenceMarker != null) {
|
||||
if(referenceMarker != null) {
|
||||
gen.getMantle().getMantle().remove(c.getX(), c.getY(), c.getZ(), MatterMarker.class);
|
||||
}
|
||||
|
||||
for (int id = 0; id < spawns; id++) {
|
||||
for(int id = 0; id < spawns; id++) {
|
||||
Location l = c.toLocation(world).add(0, 1, 0);
|
||||
|
||||
if (referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
|
||||
if (referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
|
||||
if (spawn100(gen, l, true) != null) {
|
||||
if(referenceSpawner.getAllowedLightLevels().getMin() > 0 || referenceSpawner.getAllowedLightLevels().getMax() < 15) {
|
||||
if(referenceSpawner.getAllowedLightLevels().contains(l.getBlock().getLightLevel())) {
|
||||
if(spawn100(gen, l, true) != null) {
|
||||
s++;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (spawn100(gen, l, true) != null) {
|
||||
if(spawn100(gen, l, true) != null) {
|
||||
s++;
|
||||
}
|
||||
}
|
||||
@@ -142,11 +142,11 @@ public class IrisEntitySpawn implements IRare {
|
||||
}
|
||||
|
||||
public Entity spawn(Engine g, Location at) {
|
||||
if (getRealEntity(g) == null) {
|
||||
if(getRealEntity(g) == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (rng.aquire(() -> new RNG(g.getSeedManager().getEntity())).i(1, getRarity()) == 1) {
|
||||
if(rng.aquire(() -> new RNG(g.getSeedManager().getEntity())).i(1, getRarity()) == 1) {
|
||||
return spawn100(g, at);
|
||||
}
|
||||
|
||||
@@ -160,23 +160,23 @@ public class IrisEntitySpawn implements IRare {
|
||||
private Entity spawn100(Engine g, Location at, boolean ignoreSurfaces) {
|
||||
try {
|
||||
IrisEntity irisEntity = getRealEntity(g);
|
||||
if(irisEntity == null){ // No entity
|
||||
if(irisEntity == null) { // No entity
|
||||
Iris.debug(" You are trying to spawn an entity that does not exist!");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!ignoreSurfaces && !irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock())) {
|
||||
if(!ignoreSurfaces && !irisEntity.getSurface().matches(at.clone().subtract(0, 1, 0).getBlock())) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Entity e = irisEntity.spawn(g, at.add(0.5, 0, 0.5), rng.aquire(() -> new RNG(g.getSeedManager().getEntity())));
|
||||
if (e != null) {
|
||||
if(e != null) {
|
||||
Iris.debug("Spawned " + C.DARK_AQUA + "Entity<" + getEntity() + "> " + C.GREEN + e.getType() + C.LIGHT_PURPLE + " @ " + C.GRAY + e.getLocation().getX() + ", " + e.getLocation().getY() + ", " + e.getLocation().getZ());
|
||||
}
|
||||
|
||||
|
||||
return e;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
Iris.error(" Failed to retrieve real entity @ " + at + " (entity: " + getEntity() + ")");
|
||||
|
||||
@@ -65,21 +65,21 @@ public class IrisExpression extends IrisRegistrant {
|
||||
Scope scope = new Scope(); // Create variable scope. This scope can hold both constants and invocation variables.
|
||||
|
||||
try {
|
||||
for (IrisExpressionLoad i : variables) {
|
||||
for(IrisExpressionLoad i : variables) {
|
||||
scope.addInvocationVariable(i.getName());
|
||||
}
|
||||
|
||||
scope.addInvocationVariable("x");
|
||||
scope.addInvocationVariable("y");
|
||||
scope.addInvocationVariable("z");
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
Iris.error("Script Variable load error in " + getLoadFile().getPath());
|
||||
}
|
||||
|
||||
try {
|
||||
return parser.parse(getExpression(), scope);
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
e.printStackTrace();
|
||||
Iris.error("Script load error in " + getLoadFile().getPath());
|
||||
}
|
||||
@@ -90,13 +90,13 @@ public class IrisExpression extends IrisRegistrant {
|
||||
|
||||
public ProceduralStream<Double> stream(RNG rng) {
|
||||
return streamCache.aquire(() -> ProceduralStream.of((x, z) -> evaluate(rng, x, z),
|
||||
(x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE));
|
||||
(x, y, z) -> evaluate(rng, x, y, z), Interpolated.DOUBLE));
|
||||
}
|
||||
|
||||
public double evaluate(RNG rng, double x, double z) {
|
||||
double[] g = new double[3 + getVariables().size()];
|
||||
int m = 0;
|
||||
for (IrisExpressionLoad i : getVariables()) {
|
||||
for(IrisExpressionLoad i : getVariables()) {
|
||||
g[m++] = i.getValue(rng, getLoader(), x, z);
|
||||
}
|
||||
|
||||
@@ -110,7 +110,7 @@ public class IrisExpression extends IrisRegistrant {
|
||||
public double evaluate(RNG rng, double x, double y, double z) {
|
||||
double[] g = new double[3 + getVariables().size()];
|
||||
int m = 0;
|
||||
for (IrisExpressionLoad i : getVariables()) {
|
||||
for(IrisExpressionLoad i : getVariables()) {
|
||||
g[m++] = i.getValue(rng, getLoader(), x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -60,15 +60,15 @@ public class IrisExpressionLoad {
|
||||
private transient AtomicCache<Double> valueCache = new AtomicCache<>();
|
||||
|
||||
public double getValue(RNG rng, IrisData data, double x, double z) {
|
||||
if (engineValue != null) {
|
||||
if(engineValue != null) {
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
|
||||
}
|
||||
|
||||
if (engineStreamValue != null) {
|
||||
if(engineStreamValue != null) {
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
if(styleValue != null) {
|
||||
return styleValue.create(rng, data).noise(x, z);
|
||||
}
|
||||
|
||||
@@ -76,15 +76,15 @@ public class IrisExpressionLoad {
|
||||
}
|
||||
|
||||
public double getValue(RNG rng, IrisData data, double x, double y, double z) {
|
||||
if (engineValue != null) {
|
||||
if(engineValue != null) {
|
||||
return valueCache.aquire(() -> engineValue.get(data.getEngine()));
|
||||
}
|
||||
|
||||
if (engineStreamValue != null) {
|
||||
if(engineStreamValue != null) {
|
||||
return streamCache.aquire(() -> engineStreamValue.get(data.getEngine())).get(x, z);
|
||||
}
|
||||
|
||||
if (styleValue != null) {
|
||||
if(styleValue != null) {
|
||||
return styleValue.create(rng, data).noise(x, y, z);
|
||||
}
|
||||
|
||||
|
||||
@@ -49,14 +49,14 @@ public class IrisFluidBodies {
|
||||
|
||||
@BlockCoordinates
|
||||
public void generate(MantleWriter writer, RNG rng, Engine engine, int x, int y, int z) {
|
||||
if (rivers.isNotEmpty()) {
|
||||
for (IrisRiver i : rivers) {
|
||||
if(rivers.isNotEmpty()) {
|
||||
for(IrisRiver i : rivers) {
|
||||
i.generate(writer, rng, engine, x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
if (lakes.isNotEmpty()) {
|
||||
for (IrisLake i : lakes) {
|
||||
if(lakes.isNotEmpty()) {
|
||||
for(IrisLake i : lakes) {
|
||||
i.generate(writer, rng, engine, x, y, z);
|
||||
}
|
||||
}
|
||||
@@ -65,11 +65,11 @@ public class IrisFluidBodies {
|
||||
public int getMaxRange(IrisData data) {
|
||||
int max = 0;
|
||||
|
||||
for (IrisRiver i : rivers) {
|
||||
for(IrisRiver i : rivers) {
|
||||
max = Math.max(max, i.getSize(data));
|
||||
}
|
||||
|
||||
for (IrisLake i : lakes) {
|
||||
for(IrisLake i : lakes) {
|
||||
max = Math.max(max, i.getSize(data));
|
||||
}
|
||||
|
||||
|
||||
@@ -105,28 +105,28 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public <T extends IRare> T fitRarity(KList<T> b, long superSeed, double rx, double rz) {
|
||||
if (b.size() == 0) {
|
||||
if(b.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (b.size() == 1) {
|
||||
if(b.size() == 1) {
|
||||
return b.get(0);
|
||||
}
|
||||
|
||||
KList<T> rarityMapped = new KList<>();
|
||||
boolean o = false;
|
||||
int max = 1;
|
||||
for (T i : b) {
|
||||
if (i.getRarity() > max) {
|
||||
for(T i : b) {
|
||||
if(i.getRarity() > max) {
|
||||
max = i.getRarity();
|
||||
}
|
||||
}
|
||||
|
||||
max++;
|
||||
|
||||
for (T i : b) {
|
||||
for (int j = 0; j < max - i.getRarity(); j++) {
|
||||
if (o = !o) {
|
||||
for(T i : b) {
|
||||
for(int j = 0; j < max - i.getRarity(); j++) {
|
||||
if(o = !o) {
|
||||
rarityMapped.add(i);
|
||||
} else {
|
||||
rarityMapped.add(0, i);
|
||||
@@ -134,11 +134,11 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
if (rarityMapped.size() == 1) {
|
||||
if(rarityMapped.size() == 1) {
|
||||
return rarityMapped.get(0);
|
||||
}
|
||||
|
||||
if (rarityMapped.isEmpty()) {
|
||||
if(rarityMapped.isEmpty()) {
|
||||
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
|
||||
}
|
||||
|
||||
@@ -146,11 +146,11 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public <T> T fit(T[] v, long superSeed, double rx, double rz) {
|
||||
if (v.length == 0) {
|
||||
if(v.length == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (v.length == 1) {
|
||||
if(v.length == 1) {
|
||||
return v[0];
|
||||
}
|
||||
|
||||
@@ -158,11 +158,11 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public <T> T fit(List<T> v, long superSeed, double rx, double rz) {
|
||||
if (v.size() == 0) {
|
||||
if(v.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (v.size() == 1) {
|
||||
if(v.size() == 1) {
|
||||
return v.get(0);
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public int fit(int min, int max, long superSeed, double rx, double rz) {
|
||||
if (min == max) {
|
||||
if(min == max) {
|
||||
return min;
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public int fit(double min, double max, long superSeed, double rx, double rz) {
|
||||
if (min == max) {
|
||||
if(min == max) {
|
||||
return (int) Math.round(min);
|
||||
}
|
||||
|
||||
@@ -190,7 +190,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public double fitDouble(double min, double max, long superSeed, double rx, double rz) {
|
||||
if (min == max) {
|
||||
if(min == max) {
|
||||
return min;
|
||||
}
|
||||
|
||||
@@ -209,7 +209,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
}
|
||||
|
||||
public double getHeight(double rx, double ry, double rz, long superSeed, boolean no3d) {
|
||||
if (composite.isEmpty()) {
|
||||
if(composite.isEmpty()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -217,16 +217,16 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
double h = multiplicitive ? 1 : 0;
|
||||
double tp = 0;
|
||||
|
||||
if (composite.size() == 1) {
|
||||
if (multiplicitive) {
|
||||
if(composite.size() == 1) {
|
||||
if(multiplicitive) {
|
||||
h *= composite.get(0).getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
|
||||
} else {
|
||||
tp += composite.get(0).getOpacity();
|
||||
h += composite.get(0).getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
|
||||
}
|
||||
} else {
|
||||
for (IrisNoiseGenerator i : composite) {
|
||||
if (multiplicitive) {
|
||||
for(IrisNoiseGenerator i : composite) {
|
||||
if(multiplicitive) {
|
||||
h *= i.getNoise(seed + superSeed + hc, (rx + offsetX) / zoom, (rz + offsetZ) / zoom, getLoader());
|
||||
} else {
|
||||
tp += i.getOpacity();
|
||||
@@ -237,7 +237,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
|
||||
double v = multiplicitive ? h * opacity : (h / tp) * opacity;
|
||||
|
||||
if (Double.isNaN(v)) {
|
||||
if(Double.isNaN(v)) {
|
||||
v = 0;
|
||||
}
|
||||
|
||||
@@ -275,7 +275,7 @@ public class IrisGenerator extends IrisRegistrant {
|
||||
public KList<IrisNoiseGenerator> getAllComposites() {
|
||||
KList<IrisNoiseGenerator> g = new KList<>();
|
||||
|
||||
for (IrisNoiseGenerator i : composite) {
|
||||
for(IrisNoiseGenerator i : composite) {
|
||||
g.addAll(i.getAllComposites());
|
||||
}
|
||||
|
||||
|
||||
@@ -29,14 +29,11 @@ import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import com.volmit.iris.util.noise.ExpressionNoise;
|
||||
import com.volmit.iris.util.noise.ImageNoise;
|
||||
import com.volmit.iris.util.stream.ProceduralStream;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Snippet("style")
|
||||
@Accessors(chain = true)
|
||||
@NoArgsConstructor
|
||||
@@ -84,39 +81,34 @@ public class IrisGeneratorStyle {
|
||||
}
|
||||
|
||||
public CNG createNoCache(RNG rng, IrisData data) {
|
||||
if (getExpression() != null) {
|
||||
if(getExpression() != null) {
|
||||
IrisExpression e = data.getExpressionLoader().load(getExpression());
|
||||
|
||||
if (e != null) {
|
||||
if(e != null) {
|
||||
CNG cng = new CNG(rng, new ExpressionNoise(rng, e), 1D, 1)
|
||||
.bake().scale(1D / zoom).pow(exponent).bake();
|
||||
.bake().scale(1D / zoom).pow(exponent).bake();
|
||||
cng.setTrueFracturing(axialFracturing);
|
||||
|
||||
if (fracture != null) {
|
||||
if(fracture != null) {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
if(cellularFrequency > 0)
|
||||
{
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
|
||||
if(cellularFrequency > 0) {
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
|
||||
}
|
||||
|
||||
return cng;
|
||||
}
|
||||
}
|
||||
|
||||
else if(getImageMap() != null)
|
||||
{
|
||||
CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D/zoom).pow(exponent).bake();
|
||||
} else if(getImageMap() != null) {
|
||||
CNG cng = new CNG(rng, new ImageNoise(data, getImageMap()), 1D, 1).bake().scale(1D / zoom).pow(exponent).bake();
|
||||
cng.setTrueFracturing(axialFracturing);
|
||||
|
||||
if (fracture != null) {
|
||||
if(fracture != null) {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
if(cellularFrequency > 0)
|
||||
{
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
|
||||
if(cellularFrequency > 0) {
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
|
||||
}
|
||||
|
||||
return cng;
|
||||
@@ -125,13 +117,12 @@ public class IrisGeneratorStyle {
|
||||
CNG cng = style.create(rng).bake().scale(1D / zoom).pow(exponent).bake();
|
||||
cng.setTrueFracturing(axialFracturing);
|
||||
|
||||
if (fracture != null) {
|
||||
if(fracture != null) {
|
||||
cng.fractureWith(fracture.create(rng.nextParallelRNG(2934), data), fracture.getMultiplier());
|
||||
}
|
||||
|
||||
if(cellularFrequency > 0)
|
||||
{
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D/cellularZoom).bake();
|
||||
if(cellularFrequency > 0) {
|
||||
return cng.cellularize(rng.nextParallelRNG(884466), cellularFrequency).scale(1D / cellularZoom).bake();
|
||||
}
|
||||
|
||||
return cng;
|
||||
|
||||
@@ -30,34 +30,28 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class IrisImage extends IrisRegistrant {
|
||||
private BufferedImage image;
|
||||
private final BufferedImage image;
|
||||
|
||||
public int getWidth()
|
||||
{
|
||||
public int getWidth() {
|
||||
return image.getWidth();
|
||||
}
|
||||
|
||||
public int getHeight()
|
||||
{
|
||||
public int getHeight() {
|
||||
return image.getHeight();
|
||||
}
|
||||
|
||||
public int getRawValue(int x, int z)
|
||||
{
|
||||
if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0)
|
||||
{
|
||||
public int getRawValue(int x, int z) {
|
||||
if(x >= getWidth() || z >= getHeight() || x < 0 || z < 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return image.getRGB(x, z);
|
||||
}
|
||||
|
||||
public double getValue(IrisImageChannel channel, int x, int z)
|
||||
{
|
||||
public double getValue(IrisImageChannel channel, int x, int z) {
|
||||
int color = getRawValue(x, z);
|
||||
|
||||
switch(channel)
|
||||
{
|
||||
switch(channel) {
|
||||
case RED -> {
|
||||
return ((color >> 16) & 0xFF) / 255D;
|
||||
}
|
||||
@@ -105,13 +99,11 @@ public class IrisImage extends IrisRegistrant {
|
||||
return color;
|
||||
}
|
||||
|
||||
public IrisImage()
|
||||
{
|
||||
public IrisImage() {
|
||||
this(new BufferedImage(4, 4, BufferedImage.TYPE_INT_RGB));
|
||||
}
|
||||
|
||||
public IrisImage(BufferedImage image)
|
||||
{
|
||||
public IrisImage(BufferedImage image) {
|
||||
this.image = image;
|
||||
}
|
||||
|
||||
@@ -136,10 +128,8 @@ public class IrisImage extends IrisRegistrant {
|
||||
try {
|
||||
File at = new File(getLoadFile().getParentFile(), "debug-see-" + getLoadFile().getName());
|
||||
BufferedImage b = new BufferedImage(getWidth(), getHeight(), BufferedImage.TYPE_INT_RGB);
|
||||
for(int i = 0; i < getWidth(); i++)
|
||||
{
|
||||
for(int j = 0; j < getHeight(); j++)
|
||||
{
|
||||
for(int i = 0; i < getWidth(); i++) {
|
||||
for(int j = 0; j < getHeight(); j++) {
|
||||
b.setRGB(i, j, Color.getHSBColor(0, 0, (float) getValue(channel, i, j)).getRGB());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,21 +20,13 @@ package com.volmit.iris.engine.object;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.core.loader.IrisData;
|
||||
import com.volmit.iris.core.project.SchemaBuilder;
|
||||
import com.volmit.iris.engine.data.cache.AtomicCache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.annotations.ArrayType;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MaxNumber;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Snippet;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.documentation.BlockCoordinates;
|
||||
import com.volmit.iris.util.interpolation.InterpolationMethod;
|
||||
import com.volmit.iris.util.interpolation.IrisInterpolation;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -72,26 +64,23 @@ public class IrisImageMap {
|
||||
|
||||
private transient AtomicCache<IrisImage> imageCache = new AtomicCache<IrisImage>();
|
||||
|
||||
public double getNoise(IrisData data, int x, int z)
|
||||
{
|
||||
public double getNoise(IrisData data, int x, int z) {
|
||||
IrisImage i = imageCache.aquire(() -> data.getImageLoader().load(image));
|
||||
if(i == null)
|
||||
{
|
||||
if(i == null) {
|
||||
Iris.error("NULL IMAGE FOR " + image);
|
||||
}
|
||||
|
||||
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx,zz) -> rawNoise(i, xx, zz));
|
||||
return IrisInterpolation.getNoise(interpolationMethod, x, z, coordinateScale, (xx, zz) -> rawNoise(i, xx, zz));
|
||||
}
|
||||
|
||||
private double rawNoise(IrisImage i, double x, double z)
|
||||
{
|
||||
private double rawNoise(IrisImage i, double x, double z) {
|
||||
x /= coordinateScale;
|
||||
z /= coordinateScale;
|
||||
x = isCentered() ? x + ((i.getWidth() / 2D) * coordinateScale) : x;
|
||||
z = isCentered() ? z + ((i.getHeight() / 2D) * coordinateScale) : z;
|
||||
x = isTiled() ? x % i.getWidth() : x;
|
||||
z = isTiled() ? z % i.getHeight() : z;
|
||||
double v = i.getValue(getChannel(), (int)x, (int)z);
|
||||
double v = i.getValue(getChannel(), (int) x, (int) z);
|
||||
return isInverted() ? 1D - v : v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class IrisInterpolator {
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof IrisInterpolator i) {
|
||||
if(o instanceof IrisInterpolator i) {
|
||||
return i.getFunction().equals(function) && i.getHorizontalScale() == horizontalScale;
|
||||
}
|
||||
|
||||
|
||||
@@ -67,7 +67,7 @@ public class IrisJigsawPiece extends IrisRegistrant {
|
||||
try {
|
||||
BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject()));
|
||||
return Math.max(v.getBlockX(), v.getBlockZ());
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -81,7 +81,7 @@ public class IrisJigsawPiece extends IrisRegistrant {
|
||||
try {
|
||||
BlockVector v = IrisObject.sampleSize(getLoader().getObjectLoader().findFile(getObject()));
|
||||
return Math.max(Math.max(v.getBlockX(), v.getBlockZ()), v.getBlockY());
|
||||
} catch (IOException e) {
|
||||
} catch(IOException e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -92,8 +92,8 @@ public class IrisJigsawPiece extends IrisRegistrant {
|
||||
|
||||
|
||||
public IrisJigsawPieceConnector getConnector(IrisPosition relativePosition) {
|
||||
for (IrisJigsawPieceConnector i : connectors) {
|
||||
if (i.getPosition().equals(relativePosition)) {
|
||||
for(IrisJigsawPieceConnector i : connectors) {
|
||||
if(i.getPosition().equals(relativePosition)) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@@ -110,7 +110,7 @@ public class IrisJigsawPiece extends IrisRegistrant {
|
||||
p.setConnectors(new KList<>());
|
||||
p.setPlacementOptions(getPlacementOptions());
|
||||
|
||||
for (IrisJigsawPieceConnector i : getConnectors()) {
|
||||
for(IrisJigsawPieceConnector i : getConnectors()) {
|
||||
p.getConnectors().add(i.copy());
|
||||
}
|
||||
|
||||
|
||||
@@ -71,19 +71,19 @@ public class IrisJigsawStructure extends IrisRegistrant {
|
||||
private transient AtomicCache<Integer> maxDimension = new AtomicCache<>();
|
||||
|
||||
private void loadPool(String p, KList<String> pools, KList<String> pieces) {
|
||||
if (p.isEmpty()) {
|
||||
if(p.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
IrisJigsawPool pool = getLoader().getJigsawPoolLoader().load(p);
|
||||
|
||||
if (pool == null) {
|
||||
if(pool == null) {
|
||||
Iris.warn("Can't find jigsaw pool: " + p);
|
||||
return;
|
||||
}
|
||||
|
||||
for (String i : pool.getPieces()) {
|
||||
if (pieces.addIfMissing(i)) {
|
||||
for(String i : pool.getPieces()) {
|
||||
if(pieces.addIfMissing(i)) {
|
||||
loadPiece(i, pools, pieces);
|
||||
}
|
||||
}
|
||||
@@ -92,14 +92,14 @@ public class IrisJigsawStructure extends IrisRegistrant {
|
||||
private void loadPiece(String p, KList<String> pools, KList<String> pieces) {
|
||||
IrisJigsawPiece piece = getLoader().getJigsawPieceLoader().load(p);
|
||||
|
||||
if (piece == null) {
|
||||
if(piece == null) {
|
||||
Iris.warn("Can't find jigsaw piece: " + p);
|
||||
return;
|
||||
}
|
||||
|
||||
for (IrisJigsawPieceConnector i : piece.getConnectors()) {
|
||||
for (String j : i.getPools()) {
|
||||
if (pools.addIfMissing(j)) {
|
||||
for(IrisJigsawPieceConnector i : piece.getConnectors()) {
|
||||
for(String j : i.getPools()) {
|
||||
if(pools.addIfMissing(j)) {
|
||||
loadPool(j, pools, pieces);
|
||||
}
|
||||
}
|
||||
@@ -108,16 +108,16 @@ public class IrisJigsawStructure extends IrisRegistrant {
|
||||
|
||||
public int getMaxDimension() {
|
||||
return maxDimension.aquire(() -> {
|
||||
if (useMaxPieceSizeForParallaxRadius) {
|
||||
if(useMaxPieceSizeForParallaxRadius) {
|
||||
int max = 0;
|
||||
KList<String> pools = new KList<>();
|
||||
KList<String> pieces = new KList<>();
|
||||
|
||||
for (String i : getPieces()) {
|
||||
for(String i : getPieces()) {
|
||||
loadPiece(i, pools, pieces);
|
||||
}
|
||||
|
||||
for (String i : pieces) {
|
||||
for(String i : pieces) {
|
||||
max = Math.max(max, getLoader().getJigsawPieceLoader().load(i).getMax3dDimension());
|
||||
}
|
||||
|
||||
@@ -126,13 +126,13 @@ public class IrisJigsawStructure extends IrisRegistrant {
|
||||
KList<String> pools = new KList<>();
|
||||
KList<String> pieces = new KList<>();
|
||||
|
||||
for (String i : getPieces()) {
|
||||
for(String i : getPieces()) {
|
||||
loadPiece(i, pools, pieces);
|
||||
}
|
||||
|
||||
int avg = 0;
|
||||
|
||||
for (String i : pieces) {
|
||||
for(String i : pieces) {
|
||||
avg += getLoader().getJigsawPieceLoader().load(i).getMax2dDimension();
|
||||
}
|
||||
|
||||
|
||||
@@ -112,29 +112,29 @@ public class IrisLoot {
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if (getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
if(getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
for (IrisEnchantment i : getEnchantments()) {
|
||||
for(IrisEnchantment i : getEnchantments()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for (IrisAttributeModifier i : getAttributes()) {
|
||||
for(IrisAttributeModifier i : getAttributes()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
try {
|
||||
m.setCustomModelData(getCustomModel());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
m.setLocalizedName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for (ItemFlag i : getItemFlags()) {
|
||||
for(ItemFlag i : getItemFlags()) {
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
@@ -144,8 +144,8 @@ public class IrisLoot {
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if (mf.length() > 24) {
|
||||
for (String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
|
||||
if(mf.length() > 24) {
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
|
||||
lore.add(g.trim());
|
||||
}
|
||||
} else {
|
||||
@@ -153,8 +153,8 @@ public class IrisLoot {
|
||||
}
|
||||
});
|
||||
|
||||
if (debug) {
|
||||
if (lore.isNotEmpty()) {
|
||||
if(debug) {
|
||||
if(lore.isNotEmpty()) {
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
@@ -163,18 +163,18 @@ public class IrisLoot {
|
||||
|
||||
m.setLore(lore);
|
||||
|
||||
if (getLeatherColor() != null && m instanceof LeatherArmorMeta) {
|
||||
if(getLeatherColor() != null && m instanceof LeatherArmorMeta) {
|
||||
Color c = Color.decode(getLeatherColor());
|
||||
((LeatherArmorMeta) m).setColor(org.bukkit.Color.fromRGB(c.getRed(), c.getGreen(), c.getBlue()));
|
||||
}
|
||||
|
||||
if (getDyeColor() != null && m instanceof Colorable) {
|
||||
if(getDyeColor() != null && m instanceof Colorable) {
|
||||
((Colorable) m).setColor(getDyeColor());
|
||||
}
|
||||
|
||||
is.setItemMeta(m);
|
||||
return is;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
@@ -183,12 +183,12 @@ public class IrisLoot {
|
||||
}
|
||||
|
||||
public ItemStack get(boolean debug, boolean giveSomething, IrisLootTable table, RNG rng, int x, int y, int z) {
|
||||
if (debug) {
|
||||
if(debug) {
|
||||
chance.reset();
|
||||
}
|
||||
|
||||
if (giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1) {
|
||||
if (getType() == null) {
|
||||
if(giveSomething || chance.aquire(() -> NoiseStyle.STATIC.create(rng)).fit(1, rarity * table.getRarity(), x, y, z) == 1) {
|
||||
if(getType() == null) {
|
||||
Iris.warn("Cant find item type " + type);
|
||||
return null;
|
||||
}
|
||||
@@ -197,22 +197,22 @@ public class IrisLoot {
|
||||
ItemStack is = new ItemStack(getType(), Math.max(1, rng.i(getMinAmount(), getMaxAmount())));
|
||||
ItemMeta m = is.getItemMeta();
|
||||
|
||||
if (getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
if(getType().getMaxDurability() > 0 && m instanceof Damageable d) {
|
||||
int max = getType().getMaxDurability();
|
||||
d.setDamage((int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(getMinDurability(), getMaxDurability())) * max))));
|
||||
}
|
||||
|
||||
for (IrisEnchantment i : getEnchantments()) {
|
||||
for(IrisEnchantment i : getEnchantments()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
for (IrisAttributeModifier i : getAttributes()) {
|
||||
for(IrisAttributeModifier i : getAttributes()) {
|
||||
i.apply(rng, m);
|
||||
}
|
||||
|
||||
try {
|
||||
m.setCustomModelData(getCustomModel());
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
}
|
||||
|
||||
@@ -220,7 +220,7 @@ public class IrisLoot {
|
||||
m.setDisplayName(C.translateAlternateColorCodes('&', displayName));
|
||||
m.setUnbreakable(isUnbreakable());
|
||||
|
||||
for (ItemFlag i : getItemFlags()) {
|
||||
for(ItemFlag i : getItemFlags()) {
|
||||
m.addItemFlags(i);
|
||||
}
|
||||
|
||||
@@ -230,8 +230,8 @@ public class IrisLoot {
|
||||
{
|
||||
String mf = C.translateAlternateColorCodes('&', i);
|
||||
|
||||
if (mf.length() > 24) {
|
||||
for (String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
|
||||
if(mf.length() > 24) {
|
||||
for(String g : Form.wrapWords(mf, 24).split("\\Q\n\\E")) {
|
||||
lore.add(g.trim());
|
||||
}
|
||||
} else {
|
||||
@@ -239,8 +239,8 @@ public class IrisLoot {
|
||||
}
|
||||
});
|
||||
|
||||
if (debug) {
|
||||
if (lore.isNotEmpty()) {
|
||||
if(debug) {
|
||||
if(lore.isNotEmpty()) {
|
||||
lore.add(C.GRAY + "--------------------");
|
||||
}
|
||||
|
||||
@@ -251,7 +251,7 @@ public class IrisLoot {
|
||||
m.setLore(lore);
|
||||
is.setItemMeta(m);
|
||||
return is;
|
||||
} catch (Throwable e) {
|
||||
} catch(Throwable e) {
|
||||
Iris.reportError(e);
|
||||
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class IrisLootReference {
|
||||
{
|
||||
KList<IrisLootTable> t = new KList<>();
|
||||
|
||||
for (String i : tables) {
|
||||
for(String i : tables) {
|
||||
t.add(g.getData().getLootLoader().load(i));
|
||||
}
|
||||
|
||||
|
||||
@@ -70,15 +70,15 @@ public class IrisLootTable extends IrisRegistrant {
|
||||
int m = 0;
|
||||
int mx = rng.i(getMinPicked(), getMaxPicked());
|
||||
|
||||
while (m < mx) {
|
||||
while(m < mx) {
|
||||
int num = rng.i(loot.size());
|
||||
|
||||
IrisLoot l = loot.get(num);
|
||||
|
||||
if (l.getSlotTypes() == slot) {
|
||||
if(l.getSlotTypes() == slot) {
|
||||
ItemStack item = l.get(debug, false, this, rng, x, y, z);
|
||||
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
if(item != null && item.getType() != Material.AIR) {
|
||||
lootf.add(item);
|
||||
m++;
|
||||
}
|
||||
|
||||
@@ -55,11 +55,11 @@ public class IrisMaterialPalette {
|
||||
private KList<IrisBlockData> palette = new KList<IrisBlockData>().qadd(new IrisBlockData("STONE"));
|
||||
|
||||
public BlockData get(RNG rng, double x, double y, double z, IrisData rdata) {
|
||||
if (getBlockData(rdata).isEmpty()) {
|
||||
if(getBlockData(rdata).isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (getBlockData(rdata).size() == 1) {
|
||||
if(getBlockData(rdata).size() == 1) {
|
||||
return getBlockData(rdata).get(0);
|
||||
}
|
||||
|
||||
@@ -95,10 +95,10 @@ public class IrisMaterialPalette {
|
||||
return blockData.aquire(() ->
|
||||
{
|
||||
KList<BlockData> blockData = new KList<>();
|
||||
for (IrisBlockData ix : palette) {
|
||||
for(IrisBlockData ix : palette) {
|
||||
BlockData bx = ix.getBlockData(rdata);
|
||||
if (bx != null) {
|
||||
for (int i = 0; i < ix.getWeight(); i++) {
|
||||
if(bx != null) {
|
||||
for(int i = 0; i < ix.getWeight(); i++) {
|
||||
blockData.add(bx);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public class IrisNoiseGenerator {
|
||||
}
|
||||
|
||||
public double getNoise(long superSeed, double xv, double zv, IrisData data) {
|
||||
if (!enabled) {
|
||||
if(!enabled) {
|
||||
return offsetY;
|
||||
}
|
||||
|
||||
@@ -103,8 +103,8 @@ public class IrisNoiseGenerator {
|
||||
double z = zv;
|
||||
int g = 33;
|
||||
|
||||
for (IrisNoiseGenerator i : fracture) {
|
||||
if (i.isEnabled()) {
|
||||
for(IrisNoiseGenerator i : fracture) {
|
||||
if(i.isEnabled()) {
|
||||
x += i.getNoise(superSeed + seed + g, xv, zv, data) - (opacity / 2D);
|
||||
z -= i.getNoise(superSeed + seed + g, zv, xv, data) - (opacity / 2D);
|
||||
}
|
||||
@@ -126,7 +126,7 @@ public class IrisNoiseGenerator {
|
||||
|
||||
g.add(this);
|
||||
|
||||
for (IrisNoiseGenerator i : getFracture()) {
|
||||
for(IrisNoiseGenerator i : getFracture()) {
|
||||
g.addAll(i.getAllComposites());
|
||||
}
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user