mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 18:23:06 +00:00
Auto stash before revert of "Merge pull request #561 from CocoTheOwner/DecreeCommands"
This commit is contained in:
parent
a451189d83
commit
2db34f4d49
@ -18,29 +18,30 @@
|
||||
|
||||
package com.volmit.iris.engine.modifier;
|
||||
|
||||
import com.volmit.iris.engine.IrisEngine;
|
||||
import com.volmit.iris.engine.actuator.IrisDecorantActuator;
|
||||
import com.volmit.iris.engine.data.cache.Cache;
|
||||
import com.volmit.iris.engine.framework.Engine;
|
||||
import com.volmit.iris.engine.framework.EngineAssignedModifier;
|
||||
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
|
||||
import com.volmit.iris.engine.object.objects.IrisObject;
|
||||
import com.volmit.iris.engine.object.regional.IrisRegion;
|
||||
import com.volmit.iris.engine.object.decoration.IrisDecorationPart;
|
||||
import com.volmit.iris.engine.object.decoration.IrisDecorator;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.collection.KMap;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.data.HeightMap;
|
||||
import com.volmit.iris.util.format.Form;
|
||||
import com.volmit.iris.util.hunk.Hunk;
|
||||
import com.volmit.iris.util.mantle.Mantle;
|
||||
import com.volmit.iris.util.mantle.MantleChunk;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import com.volmit.iris.util.parallel.BurstExecutor;
|
||||
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
|
||||
import lombok.Data;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
import org.bukkit.util.BlockVector;
|
||||
|
||||
import java.util.Set;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
private final RNG rng;
|
||||
@ -56,24 +57,132 @@ public class IrisCarveModifier extends EngineAssignedModifier<BlockData> {
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
Mantle mantle = getEngine().getMantle().getMantle();
|
||||
MantleChunk mc = getEngine().getMantle().getMantle().getChunk(x, z);
|
||||
KMap<Long, KList<Integer>> positions = new KMap<>();
|
||||
|
||||
mc.iterate(MatterCavern.class, (xx, yy, zz, c) -> {
|
||||
int rx = xx & 15;
|
||||
int rz = zz & 15;
|
||||
BlockData current = output.get(rx, yy, rz);
|
||||
|
||||
if(current.getMaterial().isAir())
|
||||
if(yy > 256 || yy < 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int rx = xx & 15;
|
||||
int rz = zz & 15;
|
||||
BlockData current = output.get(rx, yy, rz);
|
||||
|
||||
if(B.isFluid(current))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
positions.compute(Cache.key(rx, rz), (k,v) -> Objects.requireNonNullElseGet(v, (Supplier<KList<Integer>>) KList::new).qadd(yy));
|
||||
|
||||
if(current.getMaterial().isAir())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
output.set(rx, yy, rz, AIR);
|
||||
});
|
||||
|
||||
positions.forEach((k, v) -> {
|
||||
if(v.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int rx = Cache.keyX(k);
|
||||
int rz = Cache.keyZ(k);
|
||||
v.sort(Integer::compare);
|
||||
CaveZone zone = new CaveZone();
|
||||
zone.setFloor(v.get(0));
|
||||
int buf = v.get(0) - 1;
|
||||
for(Integer i : v) {
|
||||
if (i < 0 || i > 255) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (i == buf + 1)
|
||||
{
|
||||
buf = i;
|
||||
zone.ceiling = buf;
|
||||
}
|
||||
|
||||
else if(zone.isValid())
|
||||
{
|
||||
processZone(output, mc, zone, rx, rz, rx + (x << 4), rz + (z << 4));
|
||||
zone = new CaveZone();
|
||||
zone.setFloor(i);
|
||||
buf = i;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getEngine().getMetrics().getDeposit().put(p.getMilliseconds());
|
||||
}
|
||||
|
||||
private void processZone(Hunk<BlockData> output, MantleChunk mc, CaveZone zone, int rx, int rz, int xx, int zz) {
|
||||
boolean decFloor = B.isSolid(output.get(rx, zone.floor - 1, rz));
|
||||
boolean decCeiling = B.isSolid(output.get(rx, zone.ceiling + 1, rz));
|
||||
int center = (zone.floor + zone.ceiling) / 2;
|
||||
int thickness = zone.airThickness();
|
||||
MatterCavern cavernData = (MatterCavern) mc.getOrCreate(center >> 4).slice(MatterCavern.class)
|
||||
.get(rx, center & 15, rz);
|
||||
IrisBiome biome = cavernData.getCustomBiome().isEmpty() ? getEngine().getCaveBiome(xx, zz)
|
||||
: getEngine().getData().getBiomeLoader().load(cavernData.getCustomBiome());
|
||||
|
||||
if(biome == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
IrisDecorantActuator actuator = (IrisDecorantActuator) ((IrisEngine)getEngine()).getDecorantActuator();
|
||||
for(IrisDecorator i : biome.getDecorators()) {
|
||||
if (i.getPartOf().equals(IrisDecorationPart.NONE)) {
|
||||
actuator.getSurfaceDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getFloor() - 1, zone.getCeiling());
|
||||
} else if (i.getPartOf().equals(IrisDecorationPart.CEILING)) {
|
||||
actuator.getCeilingDecorator().decorate(rx, rz, xx, xx, xx, zz, zz, zz, output, biome, zone.getCeiling() + 1, zone.getFloor());
|
||||
}
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
output.set(rx, zone.floor - i, rz, blocks.get(i));
|
||||
}
|
||||
|
||||
// blocks = biome.generateCeilingLayers(getDimension(), xx, zz, rng, 3, zone.floor, getData(), getComplex()).reverse();
|
||||
//
|
||||
// for(int i = 0; i < zone.ceiling-1; i++)
|
||||
// {
|
||||
// if(!blocks.hasIndex(i))
|
||||
// {
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// output.set(rx, zone.ceiling + i, rz, blocks.get(i));
|
||||
// }
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class CaveZone
|
||||
{
|
||||
private int ceiling = -1;
|
||||
private int floor = -1;
|
||||
|
||||
public int airThickness()
|
||||
{
|
||||
return (ceiling - floor) - 1;
|
||||
}
|
||||
|
||||
public boolean isValid()
|
||||
{
|
||||
return floor < ceiling && ceiling - floor >= 1 && floor >= 0 && ceiling <= 255 && airThickness() > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,6 +175,11 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
|
||||
private KList<IrisBiomePaletteLayer> layers = new KList<IrisBiomePaletteLayer>().qadd(new IrisBiomePaletteLayer());
|
||||
|
||||
@Required
|
||||
@ArrayType(min = 1, type = IrisBiomePaletteLayer.class)
|
||||
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
|
||||
private KList<IrisBiomePaletteLayer> caveCeilingLayers = new KList<IrisBiomePaletteLayer>().qadd(new IrisBiomePaletteLayer());
|
||||
|
||||
@ArrayType(min = 1, type = IrisBiomePaletteLayer.class)
|
||||
@Desc("This defines the layers of materials in this biome. Each layer has a palette and min/max height and some other properties. Usually a grassy/sandy layer then a dirt layer then a stone layer. Iris will fill in the remaining blocks below your layers with stone.")
|
||||
private KList<IrisBiomePaletteLayer> seaLayers = new KList<>();
|
||||
@ -389,6 +394,52 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
||||
return data;
|
||||
}
|
||||
|
||||
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) {
|
||||
return data;
|
||||
}
|
||||
|
||||
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());
|
||||
|
||||
if (d <= 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
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) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom(), rdata));
|
||||
} catch (Throwable e) {
|
||||
Iris.reportError(e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (dim.isExplodeBiomePalettes()) {
|
||||
for (int j = 0; j < dim.getExplodeBiomePaletteSize(); j++) {
|
||||
data.add(BARRIER);
|
||||
|
||||
if (data.size() >= maxDepth) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public KList<BlockData> generateLockedLayers(double wx, double wz, RNG random, int maxDepthf, int height, IrisData rdata, IrisComplex complex) {
|
||||
KList<BlockData> data = new KList<>();
|
||||
KList<BlockData> real = new KList<>();
|
||||
|
@ -21,11 +21,14 @@ package com.volmit.iris.engine.object.carving;
|
||||
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.mantle.MantleWriter;
|
||||
import com.volmit.iris.engine.object.annotations.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.basic.IrisPosition;
|
||||
import com.volmit.iris.engine.object.basic.IrisRange;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.block.IrisBlockData;
|
||||
import com.volmit.iris.engine.object.noise.IrisWorm;
|
||||
import com.volmit.iris.engine.object.objects.IrisObjectLimit;
|
||||
@ -33,6 +36,7 @@ import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.data.B;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -57,9 +61,15 @@ public class IrisCave extends IrisRegistrant {
|
||||
@Desc("Define potential forking features")
|
||||
private IrisCarving fork = new IrisCarving();
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("Limit the worm from ever getting higher or lower than this range")
|
||||
private IrisRange verticalRange = new IrisRange(3, 255);
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "caves";
|
||||
@ -75,7 +85,7 @@ public class IrisCave extends IrisRegistrant {
|
||||
writer.setLine(getWorm().generate(rng, engine.getData(), writer, verticalRange, x, y, z,
|
||||
(at) -> fork.doCarving(writer, rng, engine, at.getX(), at.getY(), at.getZ())),
|
||||
getWorm().getGirth().get(rng, x, z, engine.getData()), true,
|
||||
CavernMatter.ON);
|
||||
matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,17 +18,21 @@
|
||||
|
||||
package com.volmit.iris.engine.object.carving;
|
||||
|
||||
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.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.block.IrisBlockData;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.noise.IrisStyledRange;
|
||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import lombok.Data;
|
||||
|
||||
@ -41,6 +45,10 @@ public class IrisElipsoid implements IRare
|
||||
@MinNumber(1)
|
||||
private int rarity = 1;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("The styled random radius for x")
|
||||
private IrisStyledRange xRadius = new IrisStyledRange(1, 5, new IrisGeneratorStyle(NoiseStyle.STATIC));
|
||||
|
||||
@ -49,13 +57,15 @@ public class IrisElipsoid implements IRare
|
||||
|
||||
@Desc("The styled random radius for z")
|
||||
private IrisStyledRange zRadius = new IrisStyledRange(1, 5, new IrisGeneratorStyle(NoiseStyle.STATIC));
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
|
||||
@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, CavernMatter.ON);
|
||||
zRadius.get(rng, y, x, engine.getData()), true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
}
|
||||
|
||||
public double maxSize() {
|
||||
|
@ -18,17 +18,21 @@
|
||||
|
||||
package com.volmit.iris.engine.object.carving;
|
||||
|
||||
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.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.block.IrisBlockData;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.noise.IrisStyledRange;
|
||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import lombok.Data;
|
||||
|
||||
@ -41,12 +45,17 @@ public class IrisPyramid implements IRare
|
||||
@MinNumber(1)
|
||||
private int rarity = 1;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("The styled random radius for x")
|
||||
private IrisStyledRange baseWidth = new IrisStyledRange(1, 5, new IrisGeneratorStyle(NoiseStyle.STATIC));
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z)
|
||||
{
|
||||
writer.setPyramid(x, y, z, CavernMatter.ON,
|
||||
writer.setPyramid(x, y, z, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())),
|
||||
(int)baseWidth.get(rng, z, y, engine.getData()), true);
|
||||
}
|
||||
|
||||
|
@ -21,19 +21,23 @@ package com.volmit.iris.engine.object.carving;
|
||||
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.mantle.MantleWriter;
|
||||
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.basic.IrisPosition;
|
||||
import com.volmit.iris.engine.object.basic.IrisRange;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.noise.IrisShapedGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.noise.IrisWorm;
|
||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||
import com.volmit.iris.util.collection.KList;
|
||||
import com.volmit.iris.util.json.JSONObject;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import com.volmit.iris.util.noise.CNG;
|
||||
import com.volmit.iris.util.plugin.VolmitSender;
|
||||
@ -53,8 +57,11 @@ public class IrisRavine extends IrisRegistrant {
|
||||
@Desc("Define the shape of this ravine (2d, ignores Y)")
|
||||
private IrisWorm worm;
|
||||
|
||||
@Desc("Define potential forking features")
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("Define potential forking features")
|
||||
private IrisCarving fork = new IrisCarving();
|
||||
|
||||
@Desc("The style used to determine the curvature of this worm's y")
|
||||
@ -81,6 +88,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
@Desc("The thickness of the ravine ribs")
|
||||
private double ribThickness = 3;
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
@Override
|
||||
public String getFolderName() {
|
||||
return "ravines";
|
||||
@ -109,7 +117,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
int width = (int) Math.round(bw.fitDouble(baseWidthStyle.getMin(), baseWidthStyle.getMax(), p.getX(), p.getZ()));
|
||||
int surface = (int) Math.round(rsurface - depth * 0.45);
|
||||
|
||||
fork.doCarving(writer, rng, engine, p.getX(), rng.r.i(surface-depth, surface), p.getZ());
|
||||
fork.doCarving(writer, rng, engine, p.getX(), rng.i(surface-depth, surface), p.getZ());
|
||||
|
||||
for(int i = surface + depth; i >= surface; i--)
|
||||
{
|
||||
@ -126,7 +134,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
break;
|
||||
}
|
||||
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, CavernMatter.ON);
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +153,7 @@ public class IrisRavine extends IrisRegistrant {
|
||||
break;
|
||||
}
|
||||
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, CavernMatter.ON);
|
||||
writer.setElipsoid(p.getX(), i, p.getZ(), v, ribThickness, v, true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,17 +18,21 @@
|
||||
|
||||
package com.volmit.iris.engine.object.carving;
|
||||
|
||||
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.Desc;
|
||||
import com.volmit.iris.engine.object.annotations.MinNumber;
|
||||
import com.volmit.iris.engine.object.annotations.RegistryListResource;
|
||||
import com.volmit.iris.engine.object.annotations.Required;
|
||||
import com.volmit.iris.engine.object.biome.IrisBiome;
|
||||
import com.volmit.iris.engine.object.block.IrisBlockData;
|
||||
import com.volmit.iris.engine.object.common.IRare;
|
||||
import com.volmit.iris.engine.object.noise.IrisGeneratorStyle;
|
||||
import com.volmit.iris.engine.object.noise.IrisStyledRange;
|
||||
import com.volmit.iris.engine.object.noise.NoiseStyle;
|
||||
import com.volmit.iris.util.math.RNG;
|
||||
import com.volmit.iris.util.matter.MatterCavern;
|
||||
import com.volmit.iris.util.matter.slices.CavernMatter;
|
||||
import lombok.Data;
|
||||
|
||||
@ -41,12 +45,17 @@ public class IrisSphere implements IRare
|
||||
@MinNumber(1)
|
||||
private int rarity = 1;
|
||||
|
||||
@RegistryListResource(IrisBiome.class)
|
||||
@Desc("Force this cave to only generate the specified custom biome")
|
||||
private String customBiome = "";
|
||||
|
||||
@Desc("The styled random radius for x")
|
||||
private IrisStyledRange radius = new IrisStyledRange(1, 5, new IrisGeneratorStyle(NoiseStyle.STATIC));
|
||||
|
||||
private transient final AtomicCache<MatterCavern> matterNodeCache = new AtomicCache<>();
|
||||
public void generate(RNG rng, Engine engine, MantleWriter writer, int x, int y, int z)
|
||||
{
|
||||
writer.setSphere(x, y, z, radius.get(rng, z, y, engine.getData()),true, CavernMatter.ON);
|
||||
writer.setSphere(x, y, z, radius.get(rng, z, y, engine.getData()),true, matterNodeCache.aquire(() -> CavernMatter.get(getCustomBiome())));
|
||||
}
|
||||
|
||||
public double maxSize() {
|
||||
|
@ -25,4 +25,5 @@ import lombok.Data;
|
||||
@AllArgsConstructor
|
||||
public class MatterCavern {
|
||||
private final boolean cavern;
|
||||
private final String customBiome;
|
||||
}
|
||||
|
@ -29,8 +29,18 @@ import java.io.IOException;
|
||||
|
||||
@Sliced
|
||||
public class CavernMatter extends RawMatter<MatterCavern> {
|
||||
public static final MatterCavern ON = new MatterCavern(true);
|
||||
public static final MatterCavern OFF = new MatterCavern(false);
|
||||
public static final MatterCavern ON = new MatterCavern(true, "");
|
||||
public static final MatterCavern OFF = new MatterCavern(false, "");
|
||||
|
||||
public static MatterCavern get(String customBiome)
|
||||
{
|
||||
if(customBiome.isEmpty())
|
||||
{
|
||||
return ON;
|
||||
}
|
||||
|
||||
return new MatterCavern(true, customBiome);
|
||||
}
|
||||
|
||||
public CavernMatter() {
|
||||
this(1, 1, 1);
|
||||
@ -43,10 +53,14 @@ public class CavernMatter extends RawMatter<MatterCavern> {
|
||||
@Override
|
||||
public void writeNode(MatterCavern b, DataOutputStream dos) throws IOException {
|
||||
dos.writeBoolean(b.isCavern());
|
||||
dos.writeUTF(b.getCustomBiome());
|
||||
}
|
||||
|
||||
@Override
|
||||
public MatterCavern readNode(DataInputStream din) throws IOException {
|
||||
return din.readBoolean() ? ON : OFF;
|
||||
boolean b = din.readBoolean();
|
||||
String v = din.readUTF();
|
||||
|
||||
return v.isEmpty() ? b ? ON : OFF : new MatterCavern(b, v);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user