Restructure Packages (read commit description)

There are now three root packages
- Engine: Generator & JSON Scaffolding
- Core: Managers, Commands, NMS
- Util: Random utility packages
This commit is contained in:
Daniel Mills
2021-07-16 01:46:22 -04:00
parent eef548f6a1
commit c984eb9b8c
423 changed files with 1001 additions and 1977 deletions

View File

@@ -0,0 +1,410 @@
/*
* 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.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.stream.ProceduralStream;
import com.volmit.iris.engine.stream.arithmetic.FittedStream;
import com.volmit.iris.engine.stream.sources.CNGStream;
import com.volmit.iris.util.*;
import lombok.Data;
import java.util.List;
@Data
public class CNG {
public static long hits = 0;
public static long creates = 0;
public static final NoiseInjector ADD = (s, v) -> new double[]{s + v, 1};
public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[]{s - v < 0 ? 0 : s - v, -1};
public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[]{v - s < 0 ? 0 : s - v, -1};
public static final NoiseInjector MULTIPLY = (s, v) -> new double[]{s * v, 0};
public static final NoiseInjector MAX = (s, v) -> new double[]{Math.max(s, v), 0};
public static final NoiseInjector MIN = (s, v) -> new double[]{Math.min(s, v), 0};
public static final NoiseInjector SRC_MOD = (s, v) -> new double[]{s % v, 0};
public static final NoiseInjector SRC_POW = (s, v) -> new double[]{Math.pow(s, v), 0};
public static final NoiseInjector DST_MOD = (s, v) -> new double[]{v % s, 0};
public static final NoiseInjector DST_POW = (s, v) -> new double[]{Math.pow(v, s), 0};
private double scale;
private double bakedScale;
private double fscale;
private boolean trueFracturing = false;
private KList<CNG> children;
private CNG fracture;
private NoiseGenerator generator;
private final double opacity;
private NoiseInjector injector;
private RNG rng;
private boolean noscale;
private int oct;
private double patch;
private double up;
private double down;
private double power;
public NoiseGenerator getGen() {
return generator;
}
public ProceduralStream<Double> stream() {
return new CNGStream(this);
}
public ProceduralStream<Double> stream(double min, double max) {
return new FittedStream<>(stream(), min, max);
}
public static CNG signature(RNG rng) {
return signature(rng, NoiseType.SIMPLEX);
}
public static CNG signatureHalf(RNG rng) {
return signatureHalf(rng, NoiseType.SIMPLEX);
}
public static CNG signatureThick(RNG rng) {
return signatureThick(rng, NoiseType.SIMPLEX);
}
public static CNG signatureDouble(RNG rng) {
return signatureDouble(rng, NoiseType.SIMPLEX);
}
public static CNG signatureDouble(RNG rng, NoiseType t) {
return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93);
}
public static CNG signatureDoubleFast(RNG rng, NoiseType t, NoiseType f) {
return signatureThickFast(rng, t, f)
.fractureWith(signatureFast(rng.nextParallelRNG(4956), t, f), 93);
}
public static CNG signature(RNG rng, NoiseType t) {
// @NoArgsConstructor
return new CNG(rng.nextParallelRNG(17), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 620), 145), 44).bake();
// @done
}
public static CNG signaturePerlin(RNG rng) {
return signaturePerlin(rng, NoiseType.PERLIN);
}
public static CNG signaturePerlin(RNG rng, NoiseType t) {
// @NoArgsConstructor
return new CNG(rng.nextParallelRNG(124996), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), NoiseType.PERLIN, 1, 1).scale(1.25), 250)
.bake();
// @done
}
public static CNG signatureFast(RNG rng, NoiseType t, NoiseType f) {
// @NoArgsConstructor
return new CNG(rng.nextParallelRNG(17), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1)
.scale(0.9)
.fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1)
.scale(0.21)
.fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.9), 620), 145), 44)
.bake();
// @done
}
public static CNG signatureThick(RNG rng, NoiseType t) {
// @NoArgsConstructor
return new CNG(rng.nextParallelRNG(133), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.5).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.11).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.4), 620), 145), 44).bake();
// @done
}
public static CNG signatureThickFast(RNG rng, NoiseType t, NoiseType f) {
// @NoArgsConstructor
return new CNG(rng.nextParallelRNG(133), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1)
.scale(0.5).fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1)
.scale(0.11).fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1)
.scale(0.4), 620), 145), 44).bake();
// @done
}
public static CNG signatureHalf(RNG rng, NoiseType t) {
// @NoArgsConstructor
return new CNG(rng.nextParallelRNG(127), t, 1D, 1).fractureWith(new CNG(rng.nextParallelRNG(18), 1, 1).scale(0.9).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.21).fractureWith(new CNG(rng.nextParallelRNG(20), 1, 1).scale(0.9), 420), 99), 22).bake();
// @done
}
public static CNG signatureHalfFast(RNG rng, NoiseType t, NoiseType f) {
// @NoArgsConstructor
return new CNG(rng.nextParallelRNG(127), t, 1D, 1)
.fractureWith(new CNG(rng.nextParallelRNG(18), f, 1, 1).scale(0.9)
.fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.21)
.fractureWith(new CNG(rng.nextParallelRNG(20), f, 1, 1).scale(0.9), 420), 99), 22).bake();
// @done
}
public CNG(RNG random) {
this(random, 1);
}
public CNG(RNG random, int octaves) {
this(random, 1D, octaves);
}
public CNG(RNG random, double opacity, int octaves) {
this(random, NoiseType.SIMPLEX, opacity, octaves);
}
public CNG(RNG random, NoiseType t, double opacity, int octaves) {
creates++;
noscale = t.equals(NoiseType.WHITE);
this.oct = octaves;
this.rng = random;
power = 1;
scale = 1;
patch = 1;
bakedScale = 1;
fscale = 1;
down = 0;
up = 0;
fracture = null;
generator = t.create(random.nextParallelRNG(33).lmax());
this.opacity = opacity;
this.injector = ADD;
if (generator instanceof OctaveNoise) {
((OctaveNoise) generator).setOctaves(octaves);
}
}
public CNG bake() {
bakedScale *= scale;
scale = 1;
return this;
}
public CNG child(CNG c) {
if (children == null) {
children = new KList<>();
}
children.add(c);
return this;
}
public RNG getRNG() {
return rng;
}
public CNG fractureWith(CNG c, double scale) {
fracture = c;
fscale = scale;
return this;
}
public CNG scale(double c) {
scale = c;
return this;
}
public CNG patch(double c) {
patch = c;
return this;
}
public CNG up(double c) {
up = c;
return this;
}
public CNG down(double c) {
down = c;
return this;
}
public CNG injectWith(NoiseInjector i) {
injector = i;
return this;
}
public <T extends IRare> T fitRarity(KList<T> b, double... dim) {
if (b.size() == 0) {
return null;
}
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) {
max = i.getRarity();
}
}
max++;
for (T i : b) {
for (int j = 0; j < max - i.getRarity(); j++) {
if (o = !o) {
rarityMapped.add(i);
} else {
rarityMapped.add(0, i);
}
}
}
if (rarityMapped.size() == 1) {
return rarityMapped.get(0);
}
if (rarityMapped.isEmpty()) {
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
}
return fit(rarityMapped, dim);
}
public <T> T fit(T[] v, double... dim) {
if (v.length == 0) {
return null;
}
if (v.length == 1) {
return v[0];
}
return v[fit(0, v.length - 1, dim)];
}
public <T> T fit(List<T> v, double... dim) {
if (v.size() == 0) {
return null;
}
if (v.size() == 1) {
return v.get(0);
}
try {
return v.get(fit(0, v.size() - 1, dim));
} catch (Throwable e) {
Iris.reportError(e);
}
return v.get(0);
}
public int fit(int min, int max, double... dim) {
if (min == max) {
return min;
}
double noise = noise(dim);
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
}
public int fit(double min, double max, double... dim) {
if (min == max) {
return (int) Math.round(min);
}
double noise = noise(dim);
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
}
public double fitDouble(double min, double max, double... dim) {
if (min == max) {
return min;
}
double noise = noise(dim);
return IrisInterpolation.lerp(min, max, noise);
}
private double getNoise(double... dim) {
if (isTrueFracturing()) {
if (dim.length == 2) {
double scale = noscale ? 1 : this.bakedScale * this.scale;
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[1]) - 0.5) * fscale : 0D);
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0]) - 0.5) * fscale : 0D);
double x = dim[0] + f1;
double y = dim[1] + -f1;
double z = 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
} else if (dim.length == 3) {
double scale = noscale ? 1 : this.bakedScale * this.scale;
double f1 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[0], dim[2], dim[1]) - 0.5) * fscale : 0D);
double f2 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[1], dim[0], dim[2]) - 0.5) * fscale : 0D);
double f3 = noscale ? 0 : (fracture != null ? (fracture.noise(dim[2], dim[1], dim[0]) - 0.5) * fscale : 0D);
double x = dim[0] + f1;
double y = dim[1] + f3;
double z = dim[2] + f2;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
}
}
double scale = noscale ? 1 : this.bakedScale * this.scale;
double f = noscale ? 0 : (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
double x = dim.length > 0 ? dim[0] + f : 0D;
double y = dim.length > 1 ? dim[1] + -f : 0D;
double z = dim.length > 2 ? dim[2] + -f : 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
}
public double noise(double... dim) {
double n = getNoise(dim);
n = power != 1D ? (n < 0 ? -Math.pow(Math.abs(n), power) : Math.pow(n, power)) : n;
double m = 1;
hits += oct;
if (children == null) {
return (n - down + up) * patch;
}
for (CNG i : children) {
double[] r = injector.combine(n, i.noise(dim));
n = r[0];
m += r[1];
}
return ((n / m) - down + up) * patch;
}
public CNG pow(double power) {
this.power = power;
return this;
}
public CNG oct(int octaves) {
oct = octaves;
return this;
}
public double getScale() {
return scale;
}
public boolean isStatic() {
return generator != null && generator.isStatic();
}
}

View File

@@ -0,0 +1,26 @@
/*
* 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.noise;
import com.volmit.iris.util.RNG;
@FunctionalInterface
public interface CNGFactory {
CNG create(RNG seed);
}

View File

@@ -0,0 +1,93 @@
/*
* 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.generator.noise;
import com.volmit.iris.util.RNG;
import lombok.Getter;
import lombok.Setter;
public class CellGenerator {
private final FastNoiseDouble fn;
private final FastNoiseDouble fd;
private final CNG cng;
@Getter
@Setter
private double cellScale;
@Getter
@Setter
private double shuffle;
public CellGenerator(RNG rng) {
shuffle = 128;
cellScale = 0.73;
cng = CNG.signature(rng.nextParallelRNG(3204));
RNG rx = rng.nextParallelRNG(8735652);
long s = rx.lmax();
fn = new FastNoiseDouble(s);
fn.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
fn.setCellularReturnType(FastNoiseDouble.CellularReturnType.CellValue);
fn.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
fd = new FastNoiseDouble(s);
fd.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
fd.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
fd.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
}
public double getDistance(double x, double z) {
return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle)))) + 1f) / 2f;
}
public double getDistance(double x, double y, double z) {
return ((fd.GetCellular(((x * cellScale) + (cng.noise(x, y, z) * shuffle)), ((y * cellScale) + (cng.noise(x, y, z) * shuffle)), ((z * cellScale) + (cng.noise(z, y, x) * shuffle)))) + 1f) / 2f;
}
public double getValue(double x, double z, int possibilities) {
if (possibilities == 1) {
return 0;
}
return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1);
}
public double getValue(double x, double y, double z, int possibilities) {
if (possibilities == 1) {
return 0;
}
return ((fn.GetCellular(((x * cellScale) + (cng.noise(x, z) * shuffle)), ((y * 8 * cellScale) + (cng.noise(x, y * 8) * shuffle)), ((z * cellScale) + (cng.noise(z, x) * shuffle))) + 1f) / 2f) * (possibilities - 1);
}
public int getIndex(double x, double z, int possibilities) {
if (possibilities == 1) {
return 0;
}
return (int) Math.round(getValue(x, z, possibilities));
}
public int getIndex(double x, double y, double z, int possibilities) {
if (possibilities == 1) {
return 0;
}
return (int) Math.round(getValue(x, y, z, possibilities));
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.generator.noise;
import com.volmit.iris.util.M;
import com.volmit.iris.util.RNG;
public class CellHeightNoise implements NoiseGenerator {
private final FastNoiseDouble n;
public CellHeightNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
}
private double filter(double noise) {
return M.clip(1D - ((noise / 2D) + 0.5D), 0D, 1D);
}
@Override
public double noise(double x) {
return filter(n.GetCellular(x, 0));
}
@Override
public double noise(double x, double z) {
return filter(n.GetCellular(x, z));
}
@Override
public double noise(double x, double y, double z) {
return filter(n.GetCellular(x, y, z));
}
}

View File

@@ -0,0 +1,47 @@
/*
* 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.generator.noise;
import com.volmit.iris.util.RNG;
public class CellularNoise implements NoiseGenerator {
private final FastNoise n;
public CellularNoise(long seed) {
this.n = new FastNoise(new RNG(seed).imax());
n.SetNoiseType(FastNoise.NoiseType.Cellular);
n.SetCellularReturnType(FastNoise.CellularReturnType.CellValue);
n.SetCellularDistanceFunction(FastNoise.CellularDistanceFunction.Natural);
}
@Override
public double noise(double x) {
return (n.GetCellular((float) x, 0) / 2D) + 0.5D;
}
@Override
public double noise(double x, double z) {
return (n.GetCellular((float) x, (float) z) / 2D) + 0.5D;
}
@Override
public double noise(double x, double y, double z) {
return (n.GetCellular((float) x, (float) y, (float) z) / 2D) + 0.5D;
}
}

View File

@@ -0,0 +1,48 @@
/*
* 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.noise;
import com.volmit.iris.util.RNG;
public class CubicNoise implements NoiseGenerator {
private final FastNoiseDouble n;
public CubicNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
}
private double f(double n) {
return (n / 2D) + 0.5D;
}
@Override
public double noise(double x) {
return f(n.GetCubic(x, 0));
}
@Override
public double noise(double x, double z) {
return f(n.GetCubic(x, z));
}
@Override
public double noise(double x, double y, double z) {
return f(n.GetCubic(x, y, z));
}
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,40 @@
/*
* 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.noise;
public class FlatNoise implements NoiseGenerator {
public FlatNoise(long seed) {
}
@Override
public double noise(double x) {
return 1D;
}
@Override
public double noise(double x, double z) {
return 1D;
}
@Override
public double noise(double x, double y, double z) {
return 1D;
}
}

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.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG;
public class FractalBillowPerlinNoise implements NoiseGenerator, OctaveNoise {
private final FastNoiseDouble n;
public FractalBillowPerlinNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1);
n.setFractalType(FractalType.Billow);
}
public double f(double v) {
return (v / 2D) + 0.5D;
}
@Override
public double noise(double x) {
return f(n.GetPerlinFractal(x, 0f));
}
@Override
public double noise(double x, double z) {
return f(n.GetPerlinFractal(x, z));
}
@Override
public double noise(double x, double y, double z) {
return f(n.GetPerlinFractal(x, y, z));
}
@Override
public void setOctaves(int o) {
n.setFractalOctaves(o);
}
}

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.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG;
public class FractalBillowSimplexNoise implements NoiseGenerator, OctaveNoise {
private final FastNoiseDouble n;
public FractalBillowSimplexNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1);
n.setFractalType(FractalType.Billow);
}
public double f(double v) {
return (v / 2D) + 0.5D;
}
@Override
public double noise(double x) {
return f(n.GetSimplexFractal(x, 0d));
}
@Override
public double noise(double x, double z) {
return f(n.GetSimplexFractal(x, z));
}
@Override
public double noise(double x, double y, double z) {
return f(n.GetSimplexFractal(x, y, z));
}
@Override
public void setOctaves(int o) {
n.setFractalOctaves(o);
}
}

View File

@@ -0,0 +1,50 @@
/*
* 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.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG;
public class FractalCubicNoise implements NoiseGenerator {
private final FastNoiseDouble n;
public FractalCubicNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalType(FractalType.Billow);
}
private double f(double n) {
return (n / 2D) + 0.5D;
}
@Override
public double noise(double x) {
return f(n.GetCubicFractal(x, 0));
}
@Override
public double noise(double x, double z) {
return f(n.GetCubicFractal(x, z));
}
@Override
public double noise(double x, double y, double z) {
return f(n.GetCubicFractal(x, y, z));
}
}

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.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG;
public class FractalFBMSimplexNoise implements NoiseGenerator, OctaveNoise {
private final FastNoiseDouble n;
public FractalFBMSimplexNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1);
n.setFractalType(FractalType.FBM);
}
public double f(double v) {
return (v / 2D) + 0.5D;
}
@Override
public double noise(double x) {
return f(n.GetSimplexFractal(x, 0d));
}
@Override
public double noise(double x, double z) {
return f(n.GetSimplexFractal(x, z));
}
@Override
public double noise(double x, double y, double z) {
return f(n.GetSimplexFractal(x, y, z));
}
@Override
public void setOctaves(int o) {
n.setFractalOctaves(o);
}
}

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.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.RNG;
public class FractalRigidMultiSimplexNoise implements NoiseGenerator, OctaveNoise {
private final FastNoiseDouble n;
public FractalRigidMultiSimplexNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setFractalOctaves(1);
n.setFractalType(FractalType.RigidMulti);
}
public double f(double v) {
return (v / 2D) + 0.5D;
}
@Override
public double noise(double x) {
return f(n.GetSimplexFractal(x, 0d));
}
@Override
public double noise(double x, double z) {
return f(n.GetSimplexFractal(x, z));
}
@Override
public double noise(double x, double y, double z) {
return f(n.GetSimplexFractal(x, y, z));
}
@Override
public void setOctaves(int o) {
n.setFractalOctaves(o);
}
}

View File

@@ -0,0 +1,51 @@
/*
* 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.noise;
import com.volmit.iris.util.RNG;
public class GlobNoise implements NoiseGenerator {
private final FastNoiseDouble n;
public GlobNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Div);
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
}
private double f(double n) {
return n + 1D;
}
@Override
public double noise(double x) {
return f(n.GetCellular(x, 0));
}
@Override
public double noise(double x, double z) {
return f(n.GetCellular(x, z));
}
@Override
public double noise(double x, double y, double z) {
return f(n.GetCellular(x, y, z));
}
}

View File

@@ -0,0 +1,24 @@
/*
* 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.noise;
@FunctionalInterface
public interface NoiseFactory {
NoiseGenerator create(long seed);
}

View File

@@ -0,0 +1,31 @@
/*
* 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.noise;
public interface NoiseGenerator {
double noise(double x);
double noise(double x, double z);
double noise(double x, double y, double z);
default boolean isStatic() {
return false;
}
}

View File

@@ -0,0 +1,46 @@
/*
* 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.noise;
public enum NoiseType {
WHITE(WhiteNoise::new),
SIMPLEX(SimplexNoise::new),
PERLIN(seed -> new PerlinNoise(seed).hermite()),
FRACTAL_BILLOW_SIMPLEX(FractalBillowSimplexNoise::new),
FRACTAL_BILLOW_PERLIN(FractalBillowPerlinNoise::new),
FRACTAL_FBM_SIMPLEX(FractalFBMSimplexNoise::new),
FRACTAL_RIGID_MULTI_SIMPLEX(FractalRigidMultiSimplexNoise::new),
FLAT(FlatNoise::new),
CELLULAR(CellularNoise::new),
GLOB(GlobNoise::new),
CUBIC(CubicNoise::new),
FRACTAL_CUBIC(FractalCubicNoise::new),
CELLULAR_HEIGHT(CellHeightNoise::new),
VASCULAR(VascularNoise::new);
private final NoiseFactory f;
NoiseType(NoiseFactory f) {
this.f = f;
}
public NoiseGenerator create(long seed) {
return f.create(seed);
}
}

View File

@@ -0,0 +1,23 @@
/*
* 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.noise;
public interface OctaveNoise {
void setOctaves(int o);
}

View File

@@ -0,0 +1,104 @@
/*
* 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.noise;
import com.volmit.iris.util.RNG;
public class PerlinNoise implements NoiseGenerator, OctaveNoise {
private final FastNoiseDouble n;
private int octaves;
public PerlinNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
octaves = 1;
}
public double f(double v) {
return (v / 2D) + 0.5D;
}
@Override
public double noise(double x) {
if (octaves <= 1) {
return f(n.GetPerlin(x, 0));
}
double f = 1;
double m = 0;
double v = 0;
for (int i = 0; i < octaves; i++) {
v += n.GetPerlin((x * (f == 1 ? f++ : (f *= 2))), 0) * f;
m += f;
}
return f(v / m);
}
@Override
public double noise(double x, double z) {
if (octaves <= 1) {
return f(n.GetPerlin(x, z));
}
double f = 1;
double m = 0;
double v = 0;
for (int i = 0; i < octaves; i++) {
f = f == 1 ? f + 1 : f * 2;
v += n.GetPerlin((x * f), (z * f)) * f;
m += f;
}
return f(v / m);
}
@Override
public double noise(double x, double y, double z) {
if (octaves <= 1) {
return f(n.GetPerlin(x, y, z));
}
double f = 1;
double m = 0;
double v = 0;
for (int i = 0; i < octaves; i++) {
f = f == 1 ? f + 1 : f * 2;
v += n.GetPerlin((x * f), (y * f), (z * f)) * f;
m += f;
}
return f(v / m);
}
@Override
public void setOctaves(int o) {
octaves = o;
}
public NoiseGenerator hermite() {
n.m_longerp = FastNoiseDouble.Longerp.Hermite;
return this;
}
public NoiseGenerator quad() {
n.m_longerp = FastNoiseDouble.Longerp.Qulongic;
return this;
}
}

View File

@@ -0,0 +1,70 @@
/*
* 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.noise;
import com.volmit.iris.util.IRare;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.RNG;
public class RarityCellGenerator<T extends IRare> extends CellGenerator {
public RarityCellGenerator(RNG rng) {
super(rng);
}
public T get(double x, double z, KList<T> b) {
if (b.size() == 0) {
return null;
}
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) {
max = i.getRarity();
}
}
max++;
for (T i : b) {
for (int j = 0; j < max - i.getRarity(); j++) {
if (o = !o) {
rarityMapped.add(i);
} else {
rarityMapped.add(0, i);
}
}
}
if (rarityMapped.size() == 1) {
return rarityMapped.get(0);
}
if (rarityMapped.isEmpty()) {
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
}
return rarityMapped.get(getIndex(x, z, rarityMapped.size()));
}
}

View File

@@ -0,0 +1,94 @@
/*
* 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.noise;
import com.volmit.iris.util.RNG;
public class SimplexNoise implements NoiseGenerator, OctaveNoise {
private final FastNoiseDouble n;
private int octaves;
public SimplexNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
octaves = 1;
}
public double f(double v) {
return (v / 2D) + 0.5D;
}
@Override
public double noise(double x) {
if (octaves <= 1) {
return f(n.GetSimplex(x, 0d));
}
double f = 1;
double m = 0;
double v = 0;
for (int i = 0; i < octaves; i++) {
v += n.GetSimplex((x * (f == 1 ? f++ : (f *= 2))), 0d) * f;
m += f;
}
return f(v / m);
}
@Override
public double noise(double x, double z) {
if (octaves <= 1) {
return f(n.GetSimplex(x, z));
}
double f = 1;
double m = 0;
double v = 0;
for (int i = 0; i < octaves; i++) {
f = f == 1 ? f + 1 : f * 2;
v += n.GetSimplex((x * f), (z * f)) * f;
m += f;
}
return f(v / m);
}
@Override
public double noise(double x, double y, double z) {
if (octaves <= 1) {
return f(n.GetSimplex(x, y, z));
}
double f = 1;
double m = 0;
double v = 0;
for (int i = 0; i < octaves; i++) {
f = f == 1 ? f + 1 : f * 2;
v += n.GetSimplex((x * f), (y * f), (z * f)) * f;
m += f;
}
return f(v / m);
}
@Override
public void setOctaves(int o) {
octaves = o;
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.noise;
import com.volmit.iris.util.M;
import com.volmit.iris.util.RNG;
public class VascularNoise implements NoiseGenerator {
private final FastNoiseDouble n;
public VascularNoise(long seed) {
this.n = new FastNoiseDouble(new RNG(seed).lmax());
n.setNoiseType(FastNoiseDouble.NoiseType.Cellular);
n.setCellularReturnType(FastNoiseDouble.CellularReturnType.Distance2Sub);
n.setCellularDistanceFunction(FastNoiseDouble.CellularDistanceFunction.Natural);
}
private double filter(double noise) {
return M.clip((noise / 2D) + 0.5D, 0D, 1D);
}
@Override
public double noise(double x) {
return filter(n.GetCellular(x, 0));
}
@Override
public double noise(double x, double z) {
return filter(n.GetCellular(x, z));
}
@Override
public double noise(double x, double y, double z) {
return filter(n.GetCellular(x, y, z));
}
}

View File

@@ -0,0 +1,52 @@
/*
* 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.noise;
import com.volmit.iris.util.RNG;
public class WhiteNoise implements NoiseGenerator {
private final FastNoise n;
public WhiteNoise(long seed) {
n = new FastNoise(new RNG(seed).imax());
}
public boolean isStatic() {
return true;
}
private double f(double m) {
return (m % 8192) * 1024;
}
@Override
public double noise(double x) {
return (n.GetWhiteNoise(f(x), 0d) / 2D) + 0.5D;
}
@Override
public double noise(double x, double z) {
return (n.GetWhiteNoise(f(x), f(z)) / 2D) + 0.5D;
}
@Override
public double noise(double x, double y, double z) {
return (n.GetWhiteNoise(f(x), f(y), f(z)) / 2D) + 0.5D;
}
}