Cave zones & force main world

This commit is contained in:
Daniel Mills 2021-08-01 16:20:46 -04:00
parent 6728703473
commit ba88f837fe
7 changed files with 300 additions and 0 deletions

View File

@ -139,6 +139,11 @@ public class Iris extends VolmitPlugin implements Listener {
}
public File getDatapacksFolder() {
if(!IrisSettings.get().getGeneral().forceMainWorld.isEmpty())
{
return new File(IrisSettings.get().getGeneral().forceMainWorld + "/datapacks");
}
File props = new File("server.properties");
if (props.exists()) {

View File

@ -106,6 +106,7 @@ public class IrisSettings {
public boolean disableNMS = false;
public boolean pluginMetrics = true;
public boolean splashLogoStartup = true;
public String forceMainWorld = "";
}
@Data

View File

@ -0,0 +1,80 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.modifier;
import com.volmit.iris.engine.data.B;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedModifier;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.engine.noise.FastNoiseDouble;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisCaveLayer;
import com.volmit.iris.engine.object.common.CaveResult;
import com.volmit.iris.engine.parallel.BurstExecutor;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import java.util.function.Function;
public class IrisCaveModifier2 extends EngineAssignedModifier<BlockData> {
public static final BlockData CAVE_AIR = B.get("CAVE_AIR");
public static final BlockData AIR = B.get("AIR");
private static final KList<CaveResult> EMPTY = new KList<>();
private final FastNoiseDouble gg;
private final RNG rng;
public IrisCaveModifier2(Engine engine) {
super(engine, "Cave");
rng = new RNG(engine.getWorld().seed() + 28934555);
gg = new FastNoiseDouble(324895L * rng.nextParallelRNG(49678).imax());
}
@Override
public void onModify(int x, int z, Hunk<BlockData> a, boolean multicore) {
if (!getDimension().isCaves()) {
return;
}
PrecisionStopwatch p = PrecisionStopwatch.start();
if (multicore) {
BurstExecutor e = getEngine().burst().burst(a.getWidth());
for (int i = 0; i < a.getWidth(); i++) {
int finalI = i;
e.queue(() -> modifySliver(x, z, finalI, a));
}
e.complete();
} else {
for (int i = 0; i < a.getWidth(); i++) {
modifySliver(x, z, i, a);
}
}
getEngine().getMetrics().getCave().put(p.getMilliseconds());
}
public void modifySliver(int x, int z, int finalI, Hunk<BlockData> a) {
for (int j = 0; j < a.getDepth(); j++) {
}
}
}

View File

@ -0,0 +1,59 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object;
import com.volmit.iris.engine.hunk.Hunk;
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.common.IRare;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.util.function.Consumer;
import java.util.function.Supplier;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Represents a cavern zone")
@Data
public class IrisCavernZone implements IRare {
@Desc("Use carving in this zone if defined")
private IrisCarveLayer carver = null;
@Desc("Use worley styled caves if defined")
private IrisGeneratorStyle worley = null;
@MinNumber(1)
@MaxNumber(100)
private int rarity = 1;
public boolean isCarved(RNG rng, double xx, double yy, double zz) {
if(carver != null)
{
return carver.isCarved(rng, xx,yy,zz);
}
return false;
}
}

View File

@ -0,0 +1,97 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.engine.interpolation.IrisInterpolation;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.engine.stream.ProceduralStream;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Represents a cavern system")
@Data
public class IrisCaverns {
@ArrayType(type = IrisCavernZone.class, min = 1)
@Desc("Define different cavern zones")
private KList<IrisCavernZone> zones = new KList<>();
@Desc("The 3D interpolator to connect caverns")
private IrisInterpolator3D interpolator = new IrisInterpolator3D();
@Desc("Defines how cavern zones are placed in the world")
private IrisGeneratorStyle zoneStyle = new IrisGeneratorStyle(NoiseStyle.CELLULAR);
@Desc("Threshold defined")
private double bottomBleed = 16;
@Desc("Threshold defined")
private double topBleed = 16;
private transient AtomicCache<ProceduralStream<IrisCavernZone>> zonesRarity = new AtomicCache<>();
public IrisCavernZone getZone(double x, double y, double z, RNG rng)
{
return zonesRarity.aquire(() -> zoneStyle.create(rng)
.stream().selectRarity(getZones())).get(x,y,z);
}
private double threshold(double y, double th)
{
double m = 0;
double a = 0;
double top = th - topBleed;
double bot = 0 + bottomBleed;
if(y >= top && y <= th)
{
m++;
a+= IrisInterpolation.lerpBezier(1, 0, M.lerpInverse(top, th, y));
}
if(y <= bottomBleed && y >= 0)
{
m++;
a+= IrisInterpolation.lerpBezier(1, 0, M.lerpInverse(top, th, y));
}
return m==0 ? 1 : (a/m);
}
public <T> void apply(double ox, double oy, double oz, Hunk<T> hunk, T cave, RNG rng, ProceduralStream<Double> height)
{
hunk.iterateSync((x,y,z) -> {
if(getInterpolator().interpolate(ox+x,oy+y,oz+z,(xx,yy,zz)
-> getZone(xx,yy,zz, rng).isCarved(rng, xx,yy,zz) ? 1 : 0) > threshold(y + oy, height.get(ox + x, oz + z)))
{
hunk.set(x,y,z,cave);
}
});
}
}

View File

@ -73,6 +73,8 @@ public class IrisDimension extends IrisRegistrant {
@Desc("Tree growth override settings")
private IrisTreeSettings treeSettings = new IrisTreeSettings();
@Desc("Define iris cavern zones")
private IrisCaverns caverns = new IrisCaverns();
@Desc("Instead of a flat bottom, applies a clamp (using this noise style) to the bottom instead of a flat bottom. Useful for carving out center-dimensions in a dimension composite world.")
private IrisShapedGeneratorStyle undercarriage = null;

View File

@ -0,0 +1,56 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.engine.object;
import com.volmit.iris.engine.interpolation.InterpolationMethod3D;
import com.volmit.iris.engine.interpolation.IrisInterpolation;
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.Required;
import com.volmit.iris.util.function.NoiseProvider3;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("Configures interpolatin in 3D")
@Data
public class IrisInterpolator3D {
@Required
@Desc("The interpolation method when two biomes use different heights but this same generator")
private InterpolationMethod3D function = InterpolationMethod3D.TRILINEAR;
@Required
@MinNumber(1)
@MaxNumber(8192)
@Desc("The range checked in all dimensions. Smaller ranges yeild more detail but are not as smooth.")
private double scale = 4;
public double interpolate(double x, double y, double z, NoiseProvider3 provider) {
return interpolate((int) Math.round(x), (int) Math.round(y), (int) Math.round(z), provider);
}
public double interpolate(int x, int y, int z, NoiseProvider3 provider) {
return IrisInterpolation.getNoise3D(getFunction(), x,y, z, getScale(), provider);
}
}