9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 19:19:07 +00:00

CAVES AND MORE

This commit is contained in:
cyberpwn
2021-08-27 09:53:25 -04:00
parent 524b63e88c
commit cf3d92d6e1
19 changed files with 431 additions and 396 deletions

View File

@@ -388,6 +388,11 @@ public class CNG {
return noise(dim);
}
public double noiseSym(double... dim)
{
return (noise(dim) * 2) - 1;
}
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;

View File

@@ -1,40 +0,0 @@
/*
* 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.util.noise;
import lombok.Data;
@Data
public class Worm {
private double position;
private double velocity;
public Worm(double startPosition, double startVelocity) {
this.position = startPosition;
this.velocity = startVelocity;
}
public void unstep() {
position -= velocity;
}
public void step() {
position += velocity;
}
}

View File

@@ -1,46 +0,0 @@
/*
* 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.util.noise;
import lombok.Data;
@Data
public class Worm2 {
private final Worm x;
private final Worm z;
public Worm2(Worm x, Worm z) {
this.x = x;
this.z = z;
}
public Worm2(int x, int z, int vx, int vz) {
this(new Worm(x, vx), new Worm(z, vz));
}
public void step() {
x.step();
z.step();
}
public void unstep() {
x.unstep();
z.unstep();
}
}

View File

@@ -1,50 +0,0 @@
/*
* 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.util.noise;
import lombok.Data;
@Data
public class Worm3 {
private final Worm x;
private final Worm y;
private final Worm z;
public Worm3(Worm x, Worm y, Worm z) {
this.x = x;
this.y = y;
this.z = z;
}
public Worm3(int x, int y, int z, int vx, int vy, int vz) {
this(new Worm(x, vx), new Worm(y, vy), new Worm(z, vz));
}
public void step() {
x.step();
y.step();
z.step();
}
public void unstep() {
x.unstep();
y.unstep();
z.unstep();
}
}

View File

@@ -1,54 +0,0 @@
/*
* 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.util.noise;
import com.volmit.iris.util.function.NoiseProvider;
import lombok.Builder;
import lombok.Data;
@Builder
@Data
public class WormIterator2 {
private transient Worm2 worm;
private transient NoiseProvider noise;
private int x;
private int z;
private int maxDistance;
private int maxIterations;
public boolean hasNext() {
double dist = maxDistance - (Math.max(Math.abs(worm.getX().getVelocity()), Math.abs(worm.getZ().getVelocity())) + 1);
return maxIterations > 0 &&
((x * x) - (worm.getX().getPosition() * worm.getX().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
}
public Worm2 next() {
if (worm == null) {
worm = new Worm2(x, z, 0, 0);
return worm;
}
worm.getX().setVelocity(noise.noise(worm.getX().getPosition(), 0));
worm.getZ().setVelocity(noise.noise(worm.getZ().getPosition(), 0));
worm.step();
return worm;
}
}

View File

@@ -1,65 +0,0 @@
/*
* 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.util.noise;
import com.volmit.iris.util.function.NoiseProvider;
import lombok.Builder;
import lombok.Data;
@Builder
@Data
public class WormIterator3 {
private transient Worm3 worm;
private int x;
private int y;
private int z;
private transient NoiseProvider noise;
private int maxDistance;
private int maxIterations;
public boolean hasNext() {
if (worm == null) {
return true;
}
double dist = maxDistance - (Math.max(Math.max(Math.abs(worm.getX().getVelocity()),
Math.abs(worm.getZ().getVelocity())),
Math.abs(worm.getY().getVelocity())) + 1);
return maxIterations > 0 &&
((x * x) - (worm.getX().getPosition() * worm.getX().getPosition()))
+ ((y * y) - (worm.getY().getPosition() * worm.getY().getPosition()))
+ ((z * z) - (worm.getZ().getPosition() * worm.getZ().getPosition())) < dist * dist;
}
public Worm3 next() {
maxIterations--;
if (worm == null) {
worm = new Worm3(x, y, z, 0, 0, 0);
return worm;
}
worm.getX().setVelocity(worm.getX().getVelocity() + noise.noise(worm.getX().getPosition() + 10000, 0));
worm.getY().setVelocity(worm.getY().getVelocity() + noise.noise(worm.getY().getPosition() + 1000, 0));
worm.getZ().setVelocity(worm.getZ().getVelocity() + noise.noise(worm.getZ().getPosition() - 10000, 0));
worm.step();
return worm;
}
}