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

Move a lot of utilities in engine to util because they are utilities

This commit is contained in:
Daniel Mills
2021-08-04 18:15:55 -04:00
parent 12b4c27468
commit 77f8f11d99
188 changed files with 366 additions and 374 deletions

View File

@@ -25,11 +25,11 @@ import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.modifier.IrisCaveModifier;
import com.volmit.iris.engine.noise.CNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.common.CaveResult;
import com.volmit.iris.engine.stream.ProceduralStream;
import com.volmit.iris.engine.stream.interpolation.Interpolated;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.math.M;
@@ -41,7 +41,6 @@ import org.bukkit.block.data.BlockData;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean;
@Data
public class IrisComplex implements DataProvider {

View File

@@ -24,7 +24,7 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.events.IrisEngineHotloadEvent;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.framework.*;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomePaletteLayer;
import com.volmit.iris.engine.object.IrisDecorator;

View File

@@ -25,12 +25,12 @@ import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineCompound;
import com.volmit.iris.engine.framework.EngineData;
import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisDimensionIndex;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.common.IrisWorld;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.atomics.AtomicRollingSequence;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;

View File

@@ -23,8 +23,8 @@ import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.engine.hunk.view.BiomeGridHunkView;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.hunk.view.BiomeGridHunkView;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisBiomeCustom;
import com.volmit.iris.util.documentation.BlockCoordinates;

View File

@@ -22,7 +22,7 @@ import com.volmit.iris.engine.decorator.*;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineAssignedActuator;
import com.volmit.iris.engine.framework.EngineDecorator;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisCaveLayer;
import com.volmit.iris.util.documentation.BlockCoordinates;

View File

@@ -20,7 +20,7 @@ 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.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates;

View File

@@ -20,9 +20,9 @@ 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.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.math.RNG;

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.engine.decorator;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.DecorationPart;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorator;

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.engine.decorator;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.DecorationPart;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorator;

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.engine.decorator;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.DecorationPart;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorator;

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.engine.decorator;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.DecorationPart;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDecorator;

View File

@@ -21,7 +21,7 @@ package com.volmit.iris.engine.decorator;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.DecorationPart;
import com.volmit.iris.engine.object.InferredType;
import com.volmit.iris.engine.object.IrisBiome;

View File

@@ -25,12 +25,12 @@ import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.data.B;
import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.common.IrisWorld;
import com.volmit.iris.engine.object.engine.IrisEngineData;
import com.volmit.iris.engine.parallax.ParallaxAccess;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.documentation.BlockCoordinates;
import com.volmit.iris.util.documentation.ChunkCoordinates;

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.documentation.BlockCoordinates;
public interface EngineActuator<O> extends EngineComponent {

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.documentation.BlockCoordinates;
public abstract class EngineAssignedActuator<T> extends EngineAssignedComponent implements EngineActuator<T> {

View File

@@ -19,7 +19,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
public abstract class EngineAssignedBiModifier<A, B> extends EngineAssignedComponent implements EngineBiModifier<A, B> {
public EngineAssignedBiModifier(Engine engine, String name) {

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.documentation.BlockCoordinates;
public abstract class EngineAssignedModifier<T> extends EngineAssignedComponent implements EngineModifier<T> {

View File

@@ -19,7 +19,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
public interface EngineBiModifier<A, B> extends EngineComponent {
void modify(int x, int z, Hunk<A> a, Hunk<B> b);

View File

@@ -31,13 +31,13 @@ import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.data.mca.NBTWorld;
import com.volmit.iris.engine.data.nbt.tag.CompoundTag;
import com.volmit.iris.engine.headless.HeadlessGenerator;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.common.IrisWorld;
import com.volmit.iris.engine.parallel.BurstExecutor;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.format.C;

View File

@@ -22,12 +22,12 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.actuator.IrisTerrainNormalActuator;
import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.IrisPosition;
import com.volmit.iris.engine.object.common.IrisWorld;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import org.bukkit.block.Biome;

View File

@@ -19,7 +19,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.data.B;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.util.documentation.BlockCoordinates;
import org.bukkit.block.data.BlockData;

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.documentation.BlockCoordinates;
public interface EngineModifier<T> extends EngineComponent {

View File

@@ -24,14 +24,14 @@ import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.data.B;
import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.engine.jigsaw.PlannedStructure;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.object.common.IObjectPlacer;
import com.volmit.iris.engine.object.tile.TileData;
import com.volmit.iris.engine.parallax.ParallaxAccess;
import com.volmit.iris.engine.parallax.ParallaxChunkMeta;
import com.volmit.iris.engine.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;

View File

@@ -23,7 +23,7 @@ import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.object.IrisDimension;
import com.volmit.iris.engine.object.common.IrisWorld;
import com.volmit.iris.engine.parallax.ParallaxWorld;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.parallel.MultiBurst;
import lombok.Data;
import java.io.File;

View File

@@ -21,16 +21,13 @@ package com.volmit.iris.engine.framework;
import com.volmit.iris.Iris;
import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.IrisComplex;
import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.data.mca.NBTWorld;
import com.volmit.iris.engine.headless.HeadlessGenerator;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisJigsawStructure;
import com.volmit.iris.engine.object.IrisJigsawStructurePlacement;
import com.volmit.iris.engine.object.IrisRegion;
import com.volmit.iris.engine.object.common.IrisWorld;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.engine.framework;
import com.volmit.iris.engine.data.B;
import com.volmit.iris.engine.data.chunk.TerrainChunk;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.hunk.Hunk;
import lombok.Data;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;

View File

@@ -23,7 +23,7 @@ import com.volmit.iris.core.pregenerator.PregenListener;
import com.volmit.iris.engine.data.mca.MCAUtil;
import com.volmit.iris.engine.data.mca.NBTWorld;
import com.volmit.iris.engine.framework.EngineCompositeGenerator;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.parallel.MultiBurst;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.Position2;
import lombok.Data;

File diff suppressed because it is too large Load Diff

View File

@@ -1,28 +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.engine.hunk;
public enum HunkFace {
TOP,
BOTTOM,
EAST,
WEST,
NORTH,
SOUTH
}

View File

@@ -1,81 +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.engine.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.function.Function3;
import java.io.*;
import java.util.concurrent.atomic.AtomicBoolean;
public abstract class BasicHunkIOAdapter<T> implements HunkIOAdapter<T> {
@Override
public void write(Hunk<T> t, OutputStream out) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
dos.writeShort(t.getWidth() + Short.MIN_VALUE);
dos.writeShort(t.getHeight() + Short.MIN_VALUE);
dos.writeShort(t.getDepth() + Short.MIN_VALUE);
dos.writeInt(t.getNonNullEntries() + Integer.MIN_VALUE);
AtomicBoolean failure = new AtomicBoolean(false);
t.iterate(0, (x, y, z, w) -> {
if (w != null) {
try {
dos.writeShort(x + Short.MIN_VALUE);
dos.writeShort(y + Short.MIN_VALUE);
dos.writeShort(z + Short.MIN_VALUE);
write(w, dos);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
failure.set(true);
}
}
});
dos.close();
}
@Override
public Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, InputStream in) throws IOException {
DataInputStream din = new DataInputStream(in);
int w = din.readShort() - Short.MIN_VALUE;
int h = din.readShort() - Short.MIN_VALUE;
int d = din.readShort() - Short.MIN_VALUE;
int e = din.readInt() - Integer.MIN_VALUE;
Hunk<T> t = factory.apply(w, h, d);
for (int i = 0; i < e; i++) {
int x = din.readShort() - Short.MIN_VALUE;
int y = din.readShort() - Short.MIN_VALUE;
int z = din.readShort() - Short.MIN_VALUE;
T v = read(din);
if (v == null) {
throw new IOException("NULL VALUE AT " + x + " " + y + " " + z);
}
t.setRaw(x, y, z, v);
}
in.close();
return t;
}
}

View File

@@ -1,39 +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.engine.hunk.io;
import com.volmit.iris.engine.data.B;
import org.bukkit.block.data.BlockData;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class BlockDataHunkIOAdapter extends PaletteHunkIOAdapter<BlockData> {
@Override
public void write(BlockData blockData, DataOutputStream dos) throws IOException {
dos.writeUTF(blockData.getAsString(true));
}
@Override
public BlockData read(DataInputStream din) throws IOException {
return B.get(din.readUTF());
}
}

View File

@@ -1,36 +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.engine.hunk.io;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class BooleanHunkIOAdapter extends PaletteHunkIOAdapter<Boolean> {
@Override
public void write(Boolean data, DataOutputStream dos) throws IOException {
dos.writeBoolean(data);
}
@Override
public Boolean read(DataInputStream din) throws IOException {
return din.readBoolean();
}
}

View File

@@ -1,56 +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.engine.hunk.io;
import com.volmit.iris.engine.data.IOAdapter;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.io.CustomOutputStream;
import com.volmit.iris.util.oldnbt.ByteArrayTag;
import java.io.*;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
public interface HunkIOAdapter<T> extends IOAdapter<T> {
void write(Hunk<T> t, OutputStream out) throws IOException;
Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, InputStream in) throws IOException;
default void write(Hunk<T> t, File f) throws IOException {
f.getParentFile().mkdirs();
FileOutputStream fos = new FileOutputStream(f);
GZIPOutputStream gzo = new CustomOutputStream(fos, 6);
write(t, gzo);
}
default Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, File f) throws IOException {
return read(factory, new GZIPInputStream(new FileInputStream(f)));
}
default Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, ByteArrayTag f) throws IOException {
return read(factory, new ByteArrayInputStream(f.getValue()));
}
default ByteArrayTag writeByteArrayTag(Hunk<T> tHunk, String name) throws IOException {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
write(tHunk, boas);
return new ByteArrayTag(name, boas.toByteArray());
}
}

View File

@@ -1,101 +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.engine.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.oldnbt.CompoundTag;
import com.volmit.iris.util.oldnbt.NBTInputStream;
import com.volmit.iris.util.oldnbt.NBTOutputStream;
import com.volmit.iris.util.oldnbt.Tag;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Map;
@SuppressWarnings("SynchronizeOnNonFinalField")
public class HunkRegion {
private final File folder;
private CompoundTag compound;
private final int x;
private final int z;
public HunkRegion(File folder, int x, int z, CompoundTag compound) {
this.compound = fix(compound);
this.folder = folder;
this.x = x;
this.z = z;
folder.mkdirs();
}
public HunkRegion(File folder, int x, int z) {
this(folder, x, z, new CompoundTag(x + "." + z, new KMap<>()));
File f = getFile();
if (f.exists()) {
try {
NBTInputStream in = new NBTInputStream(new FileInputStream(f));
compound = fix((CompoundTag) in.readTag());
in.close();
} catch (Throwable e) {
Iris.reportError(e);
}
}
}
public CompoundTag getCompound() {
return compound;
}
private CompoundTag fix(CompoundTag readTag) {
Map<String, Tag> v = readTag.getValue();
if (!(v instanceof KMap)) {
return new CompoundTag(readTag.getName(), new KMap<>(v));
}
return readTag;
}
public File getFile() {
return new File(folder, x + "." + z + ".dat");
}
public void save() throws IOException {
synchronized (compound) {
File f = getFile();
FileOutputStream fos = new FileOutputStream(f);
NBTOutputStream out = new NBTOutputStream(fos);
out.writeTag(compound);
out.close();
}
}
public int getX() {
return x;
}
public int getZ() {
return z;
}
}

View File

@@ -1,262 +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.engine.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.engine.object.tile.TileData;
import com.volmit.iris.engine.parallel.MultiBurst;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.function.Function2;
import com.volmit.iris.util.function.Function3;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.Position2;
import com.volmit.iris.util.oldnbt.ByteArrayTag;
import com.volmit.iris.util.oldnbt.CompoundTag;
import com.volmit.iris.util.oldnbt.Tag;
import org.bukkit.block.TileState;
import org.bukkit.block.data.BlockData;
import java.io.IOException;
import java.util.concurrent.atomic.AtomicReference;
public class HunkRegionSlice<T> {
public static final Function2<Integer, CompoundTag, HunkRegionSlice<BlockData>> BLOCKDATA = (h, c) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BlockDataHunkIOAdapter(), c, "blockdata");
public static final Function2<Integer, CompoundTag, HunkRegionSlice<TileData<? extends TileState>>> TILE = (h, c) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new TileDataHunkIOAdapter(), c, "tile");
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<String>> STRING = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new StringHunkIOAdapter(), c, t);
public static final Function3<Integer, CompoundTag, String, HunkRegionSlice<Boolean>> BOOLEAN = (h, c, t) -> new HunkRegionSlice<>(h, Hunk::newMappedHunk, new BooleanHunkIOAdapter(), c, t);
private final Function3<Integer, Integer, Integer, Hunk<T>> factory;
private final HunkIOAdapter<T> adapter;
private final CompoundTag compound;
private final String key;
private final KMap<Position2, Hunk<T>> loadedChunks;
private final KMap<Position2, Long> lastUse;
private final KSet<Position2> save;
private final int height;
public HunkRegionSlice(int height, Function3<Integer, Integer, Integer, Hunk<T>> factory, HunkIOAdapter<T> adapter, CompoundTag compound, String key) {
this.height = height;
this.loadedChunks = new KMap<>();
this.factory = factory;
this.adapter = adapter;
this.compound = compound;
this.save = new KSet<>();
this.key = key;
this.lastUse = new KMap<>();
}
public synchronized int cleanup(long t) {
int v = 0;
if (loadedChunks.size() != lastUse.size()) {
Iris.warn("Incorrect chunk use counts in " + key + " region slice.");
for (Position2 i : lastUse.k()) {
if (!loadedChunks.containsKey(i)) {
Iris.warn(" Missing LoadChunkKey " + i);
}
}
}
for (Position2 i : lastUse.k()) {
Long l = lastUse.get(i);
if (l == null || M.ms() - l > t) {
v++;
MultiBurst.burst.lazy(() -> {
unload(i.getX(), i.getZ());
});
}
}
return v;
}
public synchronized void clear() {
for (String i : new KList<>(compound.getValue().keySet())) {
if (i.startsWith(key + ".")) {
compound.getValue().remove(i);
}
}
}
public synchronized void save(MultiBurst burst) {
try {
for (Position2 i : save.copy()) {
if (i == null) {
continue;
}
save(i.getX(), i.getZ());
try {
save.remove(i);
} catch (Throwable eer) {
Iris.reportError(eer);
}
}
} catch (Throwable ee) {
Iris.reportError(ee);
}
}
public boolean contains(int x, int z) {
return compound.getValue().containsKey(key(x, z));
}
public void delete(int x, int z) {
compound.getValue().remove(key(x, z));
}
public Hunk<T> read(int x, int z) throws IOException {
AtomicReference<IOException> e = new AtomicReference<>();
Hunk<T> xt = null;
Tag t = compound.getValue().get(key(x, z));
if ((t instanceof ByteArrayTag)) {
try {
xt = adapter.read(factory, (ByteArrayTag) t);
} catch (IOException xe) {
Iris.reportError(xe);
e.set(xe);
}
}
if (xt != null) {
return xt;
}
if (e.get() != null) {
throw e.get();
}
return null;
}
public void write(Hunk<T> hunk, int x, int z) throws IOException {
compound.getValue().put(key(x, z), hunk.writeByteArrayTag(adapter, key(x, z)));
}
public synchronized int unloadAll() {
int v = 0;
for (Position2 i : loadedChunks.k()) {
unload(i.getX(), i.getZ());
v++;
}
save.clear();
loadedChunks.clear();
lastUse.clear();
return v;
}
public void save(Hunk<T> region, int x, int z) {
try {
write(region, x, z);
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
public boolean isLoaded(int x, int z) {
return loadedChunks.containsKey(new Position2(x, z));
}
public void save(int x, int z) {
if (isLoaded(x, z)) {
save(get(x, z), x, z);
}
}
public void unload(int x, int z) {
Position2 key = new Position2(x, z);
if (isLoaded(x, z)) {
if (save.contains(key)) {
save(x, z);
save.remove(key);
}
lastUse.remove(key);
loadedChunks.remove(key);
}
}
public Hunk<T> load(int x, int z) {
if (isLoaded(x, z)) {
return loadedChunks.get(new Position2(x, z));
}
Hunk<T> v = null;
if (contains(x, z)) {
try {
v = read(x, z);
} catch (IOException e) {
Iris.reportError(e);
e.printStackTrace();
}
}
if (v == null) {
v = factory.apply(16, height, 16);
}
loadedChunks.put(new Position2(x, z), v);
return v;
}
public Hunk<T> get(int x, int z) {
Position2 key = new Position2(x, z);
Hunk<T> c = loadedChunks.get(key);
if (c == null) {
c = load(x, z);
}
lastUse.put(new Position2(x, z), M.ms());
return c;
}
public Hunk<T> getR(int x, int z) {
return get(x, z).readOnly();
}
public Hunk<T> getRW(int x, int z) {
save.add(new Position2(x, z));
return get(x, z);
}
private String key(int x, int z) {
if (x < 0 || x >= 32 || z < 0 || z >= 32) {
throw new IndexOutOfBoundsException("The chunk " + x + " " + z + " is out of bounds max is 31x31");
}
return key + "." + x + "." + z;
}
public int getLoadCount() {
return loadedChunks.size();
}
}

View File

@@ -1,97 +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.engine.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.DataPalette;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.function.Function3;
import java.io.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicInteger;
public abstract class PaletteHunkIOAdapter<T> implements HunkIOAdapter<T> {
@Override
public void write(Hunk<T> t, OutputStream out) throws IOException {
DataOutputStream dos = new DataOutputStream(out);
dos.writeShort(t.getWidth() + Short.MIN_VALUE);
dos.writeShort(t.getHeight() + Short.MIN_VALUE);
dos.writeShort(t.getDepth() + Short.MIN_VALUE);
AtomicInteger nonNull = new AtomicInteger(0);
DataPalette<T> palette = new DataPalette<>();
t.iterateSync((x, y, z, w) -> {
if (w != null) {
palette.getIndex(w);
nonNull.getAndAdd(1);
}
});
palette.write(this, dos);
dos.writeInt(nonNull.get() + Integer.MIN_VALUE);
AtomicBoolean failure = new AtomicBoolean(false);
t.iterateSync((x, y, z, w) -> {
if (w != null) {
try {
dos.writeShort(x + Short.MIN_VALUE);
dos.writeShort(y + Short.MIN_VALUE);
dos.writeShort(z + Short.MIN_VALUE);
dos.writeShort(palette.getIndex(w) + Short.MIN_VALUE);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
failure.set(true);
}
}
});
dos.close();
}
@Override
public Hunk<T> read(Function3<Integer, Integer, Integer, Hunk<T>> factory, InputStream in) throws IOException {
DataInputStream din = new DataInputStream(in);
int w = din.readShort() - Short.MIN_VALUE;
int h = din.readShort() - Short.MIN_VALUE;
int d = din.readShort() - Short.MIN_VALUE;
DataPalette<T> palette = DataPalette.getPalette(this, din);
int e = din.readInt() - Integer.MIN_VALUE;
Hunk<T> t = factory.apply(w, h, d);
for (int i = 0; i < e; i++) {
int x = din.readShort() - Short.MIN_VALUE;
int y = din.readShort() - Short.MIN_VALUE;
int z = din.readShort() - Short.MIN_VALUE;
int vf = din.readShort() - Short.MIN_VALUE;
T v = null;
if (palette.getPalette().hasIndex(vf)) {
v = palette.getPalette().get(vf);
}
if (v != null) {
t.setRaw(x, y, z, v);
}
}
in.close();
return t;
}
}

View File

@@ -1,36 +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.engine.hunk.io;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class StringHunkIOAdapter extends PaletteHunkIOAdapter<String> {
@Override
public void write(String data, DataOutputStream dos) throws IOException {
dos.writeUTF(data);
}
@Override
public String read(DataInputStream din) throws IOException {
return din.readUTF();
}
}

View File

@@ -1,45 +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.engine.hunk.io;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.tile.TileData;
import org.bukkit.block.TileState;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class TileDataHunkIOAdapter extends PaletteHunkIOAdapter<TileData<? extends TileState>> {
@Override
public void write(TileData<? extends TileState> data, DataOutputStream dos) throws IOException {
data.toBinary(dos);
}
@Override
public TileData<? extends TileState> read(DataInputStream din) throws IOException {
try {
return TileData.read(din);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
throw new IOException();
}
}
}

View File

@@ -1,58 +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.engine.hunk.storage;
import com.volmit.iris.engine.cache.Cache;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Arrays;
@SuppressWarnings("Lombok")
@Data
@EqualsAndHashCode(callSuper = false)
public class ArrayHunk<T> extends StorageHunk<T> implements Hunk<T> {
private final T[] data;
@SuppressWarnings("unchecked")
public ArrayHunk(int w, int h, int d) {
super(w, h, d);
data = (T[]) new Object[w * h * d];
}
@Override
public void setRaw(int x, int y, int z, T t) {
data[index(x, y, z)] = t;
}
@Override
public T getRaw(int x, int y, int z) {
return data[index(x, y, z)];
}
private int index(int x, int y, int z) {
return Cache.to1D(x, y, z, getWidth(), getHeight());
}
@Override
public void fill(T t) {
Arrays.fill(data, t);
}
}

View File

@@ -1,55 +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.engine.hunk.storage;
import com.google.common.util.concurrent.AtomicDoubleArray;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Data;
import lombok.EqualsAndHashCode;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@Data
@EqualsAndHashCode(callSuper = false)
public class AtomicDoubleHunk extends StorageHunk<Double> implements Hunk<Double> {
private final AtomicDoubleArray data;
public AtomicDoubleHunk(int w, int h, int d) {
super(w, h, d);
data = new AtomicDoubleArray(w * h * d);
}
@Override
public boolean isAtomic() {
return true;
}
@Override
public void setRaw(int x, int y, int z, Double t) {
data.set(index(x, y, z), t);
}
@Override
public Double getRaw(int x, int y, int z) {
return data.get(index(x, y, z));
}
private int index(int x, int y, int z) {
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
}
}

View File

@@ -1,56 +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.engine.hunk.storage;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.concurrent.atomic.AtomicReferenceArray;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@Data
@EqualsAndHashCode(callSuper = false)
public class AtomicHunk<T> extends StorageHunk<T> implements Hunk<T> {
private final AtomicReferenceArray<T> data;
public AtomicHunk(int w, int h, int d) {
super(w, h, d);
data = new AtomicReferenceArray<>(w * h * d);
}
@Override
public boolean isAtomic() {
return true;
}
@Override
public void setRaw(int x, int y, int z, T t) {
data.set(index(x, y, z), t);
}
@Override
public T getRaw(int x, int y, int z) {
return data.get(index(x, y, z));
}
private int index(int x, int y, int z) {
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
}
}

View File

@@ -1,56 +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.engine.hunk.storage;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.concurrent.atomic.AtomicIntegerArray;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@Data
@EqualsAndHashCode(callSuper = false)
public class AtomicIntegerHunk extends StorageHunk<Integer> implements Hunk<Integer> {
private final AtomicIntegerArray data;
public AtomicIntegerHunk(int w, int h, int d) {
super(w, h, d);
data = new AtomicIntegerArray(w * h * d);
}
@Override
public boolean isAtomic() {
return true;
}
@Override
public void setRaw(int x, int y, int z, Integer t) {
data.set(index(x, y, z), t);
}
@Override
public Integer getRaw(int x, int y, int z) {
return data.get(index(x, y, z));
}
private int index(int x, int y, int z) {
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
}
}

View File

@@ -1,56 +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.engine.hunk.storage;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.concurrent.atomic.AtomicLongArray;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@Data
@EqualsAndHashCode(callSuper = false)
public class AtomicLongHunk extends StorageHunk<Long> implements Hunk<Long> {
private final AtomicLongArray data;
public AtomicLongHunk(int w, int h, int d) {
super(w, h, d);
data = new AtomicLongArray(w * h * d);
}
@Override
public boolean isAtomic() {
return true;
}
@Override
public void setRaw(int x, int y, int z, Long t) {
data.set(index(x, y, z), t);
}
@Override
public Long getRaw(int x, int y, int z) {
return data.get(index(x, y, z));
}
private int index(int x, int y, int z) {
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
}
}

View File

@@ -1,77 +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.engine.hunk.storage;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.function.Consumer4;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Map;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@Data
@EqualsAndHashCode(callSuper = false)
public class MappedHunk<T> extends StorageHunk<T> implements Hunk<T> {
private final Map<Integer, T> data;
public MappedHunk(int w, int h, int d) {
super(w, h, d);
data = new KMap<>();
}
@Override
public void setRaw(int x, int y, int z, T t) {
if (t == null) {
data.remove(index(x, y, z));
return;
}
data.put(index(x, y, z), t);
}
private Integer index(int x, int y, int z) {
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
}
@Override
public synchronized Hunk<T> iterateSync(Consumer4<Integer, Integer, Integer, T> c) {
int idx, z;
for (Map.Entry<Integer, T> g : data.entrySet()) {
idx = g.getKey();
z = idx / (getWidth() * getHeight());
idx -= (z * getWidth() * getHeight());
c.accept(idx % getWidth(), idx / getWidth(), z, g.getValue());
}
return this;
}
@Override
public void empty(T b) {
data.clear();
}
@Override
public T getRaw(int x, int y, int z) {
return data.get(index(x, y, z));
}
}

View File

@@ -1,45 +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.engine.hunk.storage;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Data;
@Data
public abstract class StorageHunk<T> implements Hunk<T> {
private final int width;
private final int height;
private final int depth;
public StorageHunk(int width, int height, int depth) {
if (width <= 0 || height <= 0 || depth <= 0) {
throw new RuntimeException("Unsupported size " + width + " " + height + " " + depth);
}
this.width = width;
this.height = height;
this.depth = depth;
}
@Override
public abstract void setRaw(int x, int y, int z, T t);
@Override
public abstract T getRaw(int x, int y, int z);
}

View File

@@ -1,63 +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.engine.hunk.storage;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.util.Arrays;
@SuppressWarnings({"DefaultAnnotationParam", "Lombok"})
@Data
@EqualsAndHashCode(callSuper = false)
public class SynchronizedArrayHunk<T> extends StorageHunk<T> implements Hunk<T> {
private final T[] data;
@SuppressWarnings("unchecked")
public SynchronizedArrayHunk(int w, int h, int d) {
super(w, h, d);
data = (T[]) new Object[w * h * d];
}
@Override
public void setRaw(int x, int y, int z, T t) {
synchronized (data) {
data[index(x, y, z)] = t;
}
}
@Override
public T getRaw(int x, int y, int z) {
synchronized (data) {
return data[index(x, y, z)];
}
}
private int index(int x, int y, int z) {
return (z * getWidth() * getHeight()) + (y * getWidth()) + x;
}
@Override
public void fill(T t) {
synchronized (data) {
Arrays.fill(data, t);
}
}
}

View File

@@ -1,70 +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.engine.hunk.view;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.data.chunk.LinkedTerrainChunk;
import com.volmit.iris.engine.hunk.Hunk;
import lombok.Getter;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
@SuppressWarnings("ClassCanBeRecord")
public class BiomeGridHunkView implements Hunk<Biome> {
@Getter
private final BiomeGrid chunk;
public BiomeGridHunkView(BiomeGrid chunk) {
this.chunk = chunk;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
// TODO: WARNING HEIGHT
return 256;
}
@Override
public void setRaw(int x, int y, int z, Biome t) {
chunk.setBiome(x, y, z, t);
}
@Override
public Biome getRaw(int x, int y, int z) {
return chunk.getBiome(x, y, z);
}
public void forceBiomeBaseInto(int x, int y, int z, Object somethingVeryDirty) {
if (chunk instanceof LinkedTerrainChunk) {
INMS.get().forceBiomeInto(x, y, z, somethingVeryDirty, ((LinkedTerrainChunk) chunk).getRawBiome());
return;
}
INMS.get().forceBiomeInto(x, y, z, somethingVeryDirty, chunk);
}
}

View File

@@ -1,62 +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.engine.hunk.view;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.hunk.Hunk;
import org.bukkit.Chunk;
import org.bukkit.block.Biome;
@SuppressWarnings("ClassCanBeRecord")
public class ChunkBiomeHunkView implements Hunk<Biome> {
private final Chunk chunk;
public ChunkBiomeHunkView(Chunk chunk) {
this.chunk = chunk;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
return chunk.getWorld().getMaxHeight();
}
@Override
public void setRaw(int x, int y, int z, Biome t) {
if (t == null) {
return;
}
Iris.edit.setBiome(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16), t);
}
@Override
public Biome getRaw(int x, int y, int z) {
return Iris.edit.getBiome(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16));
}
}

View File

@@ -1,70 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.ChunkData;
@SuppressWarnings("ClassCanBeRecord")
public class ChunkDataHunkView implements Hunk<BlockData> {
private final ChunkData chunk;
public ChunkDataHunkView(ChunkData chunk) {
this.chunk = chunk;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
return chunk.getMaxHeight();
}
@Override
public void set(int x1, int y1, int z1, int x2, int y2, int z2, BlockData t) {
if (t == null) {
return;
}
chunk.setRegion(x1, y1, z1, x2, y2, z2, t);
}
@Override
public void setRaw(int x, int y, int z, BlockData t) {
if (t == null) {
return;
}
chunk.setBlock(x, y, z, t);
}
@Override
public BlockData getRaw(int x, int y, int z) {
return chunk.getBlockData(x, y, z);
}
}

View File

@@ -1,62 +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.engine.hunk.view;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.hunk.Hunk;
import org.bukkit.Chunk;
import org.bukkit.block.data.BlockData;
@SuppressWarnings("ClassCanBeRecord")
public class ChunkHunkView implements Hunk<BlockData> {
private final Chunk chunk;
public ChunkHunkView(Chunk chunk) {
this.chunk = chunk;
}
@Override
public int getWidth() {
return 16;
}
@Override
public int getDepth() {
return 16;
}
@Override
public int getHeight() {
return chunk.getWorld().getMaxHeight();
}
@Override
public void setRaw(int x, int y, int z, BlockData t) {
if (t == null) {
return;
}
Iris.edit.set(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16), t);
}
@Override
public BlockData getRaw(int x, int y, int z) {
return Iris.edit.get(chunk.getWorld(), x + (chunk.getX() * 16), y, z + (chunk.getZ() * 16));
}
}

View File

@@ -1,66 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
@SuppressWarnings("ClassCanBeRecord")
public class DriftHunkView<T> implements Hunk<T> {
private final int ox;
private final int oy;
private final int oz;
private final Hunk<T> src;
public DriftHunkView(Hunk<T> src, int ox, int oy, int oz) {
this.src = src;
this.ox = ox;
this.oy = oy;
this.oz = oz;
}
@Override
public void setRaw(int x, int y, int z, T t) {
src.setRaw(x + ox, y + oy, z + oz, t);
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x + ox, y + oy, z + oz);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,62 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
@SuppressWarnings("ClassCanBeRecord")
public class FringedHunkView<T> implements Hunk<T> {
private final Hunk<T> src;
private final Hunk<T> out;
public FringedHunkView(Hunk<T> src, Hunk<T> out) {
this.src = src;
this.out = out;
}
@Override
public void setRaw(int x, int y, int z, T t) {
out.setRaw(x, y, z, t);
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x, y, z);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,73 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
import java.util.function.Function;
public class FunctionalHunkView<R, T> implements Hunk<T> {
private final Hunk<R> src;
private final Function<R, T> converter;
private final Function<T, R> backConverter;
public FunctionalHunkView(Hunk<R> src, Function<R, T> converter, Function<T, R> backConverter) {
this.src = src;
this.converter = converter;
this.backConverter = backConverter;
}
@Override
public void setRaw(int x, int y, int z, T t) {
if (backConverter == null) {
throw new UnsupportedOperationException("You cannot write to this hunk (Read Only)");
}
src.setRaw(x, y, z, backConverter.apply(t));
}
@Override
public T getRaw(int x, int y, int z) {
if (converter == null) {
throw new UnsupportedOperationException("You cannot read this hunk (Write Only)");
}
return converter.apply(src.getRaw(x, y, z));
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public Hunk<T> getSource() {
throw new UnsupportedOperationException("You cannot read this hunk's source because it's a different type.");
}
}

View File

@@ -1,79 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
public class HunkView<T> implements Hunk<T> {
private final int ox;
private final int oy;
private final int oz;
private final int w;
private final int h;
private final int d;
private final Hunk<T> src;
public HunkView(Hunk<T> src) {
this(src, src.getWidth(), src.getHeight(), src.getDepth());
}
public HunkView(Hunk<T> src, int w, int h, int d) {
this(src, w, h, d, 0, 0, 0);
}
public HunkView(Hunk<T> src, int w, int h, int d, int ox, int oy, int oz) {
this.src = src;
this.w = w;
this.h = h;
this.d = d;
this.ox = ox;
this.oy = oy;
this.oz = oz;
}
@Override
public void setRaw(int x, int y, int z, T t) {
src.setRaw(x + ox, y + oy, z + oz, t);
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x + ox, y + oy, z + oz);
}
@Override
public int getWidth() {
return w;
}
@Override
public int getDepth() {
return d;
}
@Override
public int getHeight() {
return h;
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,60 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
@SuppressWarnings("ClassCanBeRecord")
public class InvertedHunkView<T> implements Hunk<T> {
private final Hunk<T> src;
public InvertedHunkView(Hunk<T> src) {
this.src = src;
}
@Override
public void setRaw(int x, int y, int z, T t) {
src.setRaw(x, (getHeight() - 1) - y, z, t);
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x, y, z);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,64 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.util.function.Consumer4;
@SuppressWarnings("ClassCanBeRecord")
public class ListeningHunk<T> implements Hunk<T> {
private final Hunk<T> src;
private final Consumer4<Integer, Integer, Integer, T> listener;
public ListeningHunk(Hunk<T> src, Consumer4<Integer, Integer, Integer, T> listener) {
this.src = src;
this.listener = listener;
}
@Override
public void setRaw(int x, int y, int z, T t) {
listener.accept(x, y, z, t);
src.setRaw(x, y, z, t);
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x, y, z);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,70 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
@SuppressWarnings("ClassCanBeRecord")
public class ReadOnlyHunk<T> implements Hunk<T> {
private final Hunk<T> src;
public ReadOnlyHunk(Hunk<T> src) {
this.src = src;
}
@Override
public void setRaw(int x, int y, int z, T t) {
throw new IllegalStateException("This hunk is read only!");
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x, y, z);
}
@Override
public void set(int x1, int y1, int z1, int x2, int y2, int z2, T t) {
throw new IllegalStateException("This hunk is read only!");
}
@Override
public void fill(T t) {
throw new IllegalStateException("This hunk is read only!");
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,73 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
public class RotatedXHunkView<T> implements Hunk<T> {
private final Hunk<T> src;
private final double sin;
private final double cos;
public RotatedXHunkView(Hunk<T> src, double deg) {
this.src = src;
this.sin = Math.sin(Math.toRadians(deg));
this.cos = Math.cos(Math.toRadians(deg));
}
@Override
public void setRaw(int x, int y, int z, T t) {
int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f));
int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f));
src.setIfExists(x,
(int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc,
(int) Math.round(sin * y - yc + cos * (z - zc)) - zc,
t);
}
@Override
public T getRaw(int x, int y, int z) {
int yc = (int) Math.round(cos * (getHeight() / 2f) - sin * (getDepth() / 2f));
int zc = (int) Math.round(sin * (getHeight() / 2f) + cos * (getDepth() / 2f));
return src.getIfExists(x,
(int) Math.round(cos * (y - yc) - sin * (z - zc)) - yc,
(int) Math.round(sin * y - yc + cos * (z - zc)) - zc
);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,74 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
public class RotatedYHunkView<T> implements Hunk<T> {
private final Hunk<T> src;
private final double sin;
private final double cos;
public RotatedYHunkView(Hunk<T> src, double deg) {
this.src = src;
this.sin = Math.sin(Math.toRadians(deg));
this.cos = Math.cos(Math.toRadians(deg));
}
@Override
public void setRaw(int x, int y, int z, T t) {
int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f));
int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f));
src.setIfExists((int)
Math.round(cos * (x - xc) + sin * (z - zc)) - xc,
y,
(int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc, t);
}
@Override
public T getRaw(int x, int y, int z) {
int xc = (int) Math.round(cos * (getWidth() / 2f) + sin * (getDepth() / 2f));
int zc = (int) Math.round(-sin * (getWidth() / 2f) + cos * (getDepth() / 2f));
return src.getIfExists(
(int) Math.round(cos * (x - xc) + sin * (z - zc)) - xc,
y,
(int) Math.round(-sin * (x - xc) + cos * (z - zc)) - zc
);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,69 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
public class RotatedZHunkView<T> implements Hunk<T> {
private final Hunk<T> src;
private final double sin;
private final double cos;
public RotatedZHunkView(Hunk<T> src, double deg) {
this.src = src;
this.sin = Math.sin(Math.toRadians(deg));
this.cos = Math.cos(Math.toRadians(deg));
}
@Override
public void setRaw(int x, int y, int z, T t) {
int xc = (int) Math.round(cos * (getWidth() / 2f) - sin * (getHeight() / 2f));
int yc = (int) Math.round(sin * (getWidth() / 2f) + cos * (getHeight() / 2f));
src.setIfExists((int) Math.round(cos * (x - xc) - sin * (y - yc)) - xc, (int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc, z, t);
}
@Override
public T getRaw(int x, int y, int z) {
int xc = (int) Math.round(cos * (getWidth() / 2f) - sin * (getHeight() / 2f));
int yc = (int) Math.round(sin * (getWidth() / 2f) + cos * (getHeight() / 2f));
return src.getIfExists((int) Math.round(cos * (x - xc) - sin * (y - yc)) - xc,
(int) Math.round(sin * (x - xc) + cos * (y - yc)) - yc
, z);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,62 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
@SuppressWarnings("ClassCanBeRecord")
public class SynchronizedHunkView<T> implements Hunk<T> {
private final Hunk<T> src;
public SynchronizedHunkView(Hunk<T> src) {
this.src = src;
}
@Override
public void setRaw(int x, int y, int z, T t) {
synchronized (src) {
src.setRaw(x, y, z, t);
}
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x, y, z);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -1,68 +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.engine.hunk.view;
import com.volmit.iris.engine.hunk.Hunk;
import java.util.concurrent.atomic.AtomicBoolean;
@SuppressWarnings("ClassCanBeRecord")
public class WriteTrackHunk<T> implements Hunk<T> {
private final Hunk<T> src;
private final AtomicBoolean b;
public WriteTrackHunk(Hunk<T> src, AtomicBoolean b) {
this.src = src;
this.b = b;
}
@Override
public void setRaw(int x, int y, int z, T t) {
if (!b.get()) {
b.set(true);
}
src.setRaw(x, y, z, t);
}
@Override
public T getRaw(int x, int y, int z) {
return src.getRaw(x, y, z);
}
@Override
public int getWidth() {
return src.getWidth();
}
@Override
public int getHeight() {
return src.getHeight();
}
@Override
public int getDepth() {
return src.getDepth();
}
@Override
public Hunk<T> getSource() {
return src;
}
}

View File

@@ -19,8 +19,8 @@
package com.volmit.iris.engine.interpolation;
import com.google.common.util.concurrent.AtomicDouble;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.engine.noise.CNG;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.function.NoiseProvider;
import com.volmit.iris.util.function.NoiseProvider3;

View File

@@ -21,12 +21,12 @@ 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.util.hunk.Hunk;
import com.volmit.iris.util.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.parallel.BurstExecutor;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;

View File

@@ -21,10 +21,10 @@ 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.util.hunk.Hunk;
import com.volmit.iris.util.noise.FastNoiseDouble;
import com.volmit.iris.engine.object.common.CaveResult;
import com.volmit.iris.engine.parallel.BurstExecutor;
import com.volmit.iris.util.parallel.BurstExecutor;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.PrecisionStopwatch;

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.engine.modifier;
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.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.IrisDepositGenerator;
import com.volmit.iris.engine.object.IrisObject;

View File

@@ -22,7 +22,7 @@ import com.volmit.iris.Iris;
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.util.hunk.Hunk;
import com.volmit.iris.engine.object.IrisBiome;
import com.volmit.iris.engine.object.common.CaveResult;
import com.volmit.iris.util.math.RNG;

View File

@@ -21,8 +21,8 @@ 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.CNG;
import com.volmit.iris.util.hunk.Hunk;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.engine.object.NoiseStyle;
import com.volmit.iris.util.math.BlockPosition;
import com.volmit.iris.util.math.MathHelper;

View File

@@ -1,426 +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.engine.noise;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.interpolation.IrisInterpolation;
import com.volmit.iris.engine.object.common.IRare;
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.collection.KList;
import com.volmit.iris.util.function.NoiseInjector;
import com.volmit.iris.util.math.RNG;
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;
private ProceduralStream<Double> customGenerator;
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 type, double opacity, int octaves) {
this(random, type.create(random.nextParallelRNG((long) ((1113334944L * opacity) + 12922 + octaves)).lmax()), opacity, octaves);
}
public CNG(RNG random, NoiseGenerator generator, double opacity, int octaves) {
customGenerator = null;
creates++;
noscale = generator.isNoScale();
this.oct = octaves;
this.rng = random;
power = 1;
scale = 1;
patch = 1;
bakedScale = 1;
fscale = 1;
down = 0;
up = 0;
fracture = null;
this.generator = generator;
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) {
double scale = noscale ? 1 : this.bakedScale * this.scale;
if (fracture == null || noscale) {
return generator.noise(
(dim.length > 0 ? dim[0] : 0D) * scale,
(dim.length > 1 ? dim[1] : 0D) * scale,
(dim.length > 2 ? dim[2] : 0D) * scale) * opacity;
}
if (fracture.isTrueFracturing()) {
double x = dim.length > 0 ? dim[0] + ((fracture.noise(dim) - 0.5) * fscale) : 0D;
double y = dim.length > 1 ? dim[1] + ((fracture.noise(dim[1], dim[0]) - 0.5) * fscale) : 0D;
double z = dim.length > 2 ? dim[2] + ((fracture.noise(dim[2], dim[0], dim[1]) - 0.5) * fscale) : 0D;
return generator.noise(x * scale, y * scale, z * scale) * opacity;
}
double f = fracture.noise(dim) * fscale;
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 invertNoise(double... dim) {
if (dim.length == 1) {
return noise(-dim[0]);
} else if (dim.length == 2) {
return noise(dim[1], dim[0]);
} else if (dim.length == 3) {
return noise(dim[1], dim[2], dim[0]);
}
return noise(dim);
}
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

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

View File

@@ -1,93 +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.engine.noise;
import com.volmit.iris.util.math.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

@@ -1,52 +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.engine.noise;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.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

@@ -1,47 +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.engine.noise;
import com.volmit.iris.util.math.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;
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,48 +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.engine.noise;
import com.volmit.iris.util.math.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));
}
}

View File

@@ -1,47 +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.engine.noise;
import com.volmit.iris.engine.object.IrisExpression;
import com.volmit.iris.util.math.RNG;
public class ExpressionNoise implements NoiseGenerator {
private final RNG rng;
private final IrisExpression expression;
public ExpressionNoise(RNG rng, IrisExpression expression) {
this.rng = rng;
this.expression = expression;
}
@Override
public double noise(double x) {
return expression.evaluate(rng, x, -1);
}
@Override
public double noise(double x, double z) {
return expression.evaluate(rng, x, z);
}
@Override
public double noise(double x, double y, double z) {
return expression.evaluate(rng, 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

@@ -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.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

@@ -1,56 +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.engine.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.math.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

@@ -1,56 +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.engine.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.math.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

@@ -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.engine.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.math.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

@@ -1,56 +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.engine.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.math.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

@@ -1,56 +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.engine.noise;
import com.volmit.iris.engine.noise.FastNoiseDouble.FractalType;
import com.volmit.iris.util.math.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

@@ -1,51 +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.engine.noise;
import com.volmit.iris.util.math.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

@@ -1,53 +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.engine.noise;
import com.volmit.iris.engine.interpolation.InterpolationMethod;
import com.volmit.iris.engine.interpolation.IrisInterpolation;
import com.volmit.iris.util.function.NoiseProvider;
public class InterpolatedNoise implements NoiseGenerator {
private final InterpolationMethod method;
private final NoiseProvider p;
public InterpolatedNoise(long seed, NoiseType type, InterpolationMethod method) {
this.method = method;
NoiseGenerator g = type.create(seed);
p = g::noise;
}
@Override
public double noise(double x) {
return noise(x, 0);
}
@Override
public double noise(double x, double z) {
return IrisInterpolation.getNoise(method, (int) x, (int) z, 32, p);
}
@Override
public double noise(double x, double y, double z) {
if (z == 0) {
return noise(x, y);
}
return IrisInterpolation.getNoise(method, (int) x, (int) z, 32, p);
}
}

View File

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

View File

@@ -1,35 +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.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;
}
default boolean isNoScale() {
return false;
}
}

View File

@@ -1,82 +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.engine.noise;
import com.volmit.iris.engine.interpolation.InterpolationMethod;
public enum NoiseType {
WHITE(WhiteNoise::new),
WHITE_BILINEAR((s) -> new InterpolatedNoise(s, WHITE, InterpolationMethod.BILINEAR)),
WHITE_BICUBIC((s) -> new InterpolatedNoise(s, WHITE, InterpolationMethod.BICUBIC)),
WHITE_HERMITE((s) -> new InterpolatedNoise(s, WHITE, InterpolationMethod.HERMITE)),
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),
CELLULAR_BILINEAR((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR)),
CELLULAR_BILINEAR_STARCAST_3((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_3)),
CELLULAR_BILINEAR_STARCAST_6((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_6)),
CELLULAR_BILINEAR_STARCAST_9((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_9)),
CELLULAR_BILINEAR_STARCAST_12((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BILINEAR_STARCAST_12)),
CELLULAR_BICUBIC((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.BICUBIC)),
CELLULAR_HERMITE((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE)),
CELLULAR_STARCAST_3((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_3)),
CELLULAR_STARCAST_6((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_6)),
CELLULAR_STARCAST_9((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_9)),
CELLULAR_STARCAST_12((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.STARCAST_12)),
CELLULAR_HERMITE_STARCAST_3((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_3)),
CELLULAR_HERMITE_STARCAST_6((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_6)),
CELLULAR_HERMITE_STARCAST_9((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_9)),
CELLULAR_HERMITE_STARCAST_12((s) -> new InterpolatedNoise(s, CELLULAR, InterpolationMethod.HERMITE_STARCAST_12)),
GLOB(GlobNoise::new),
CUBIC(CubicNoise::new),
FRACTAL_CUBIC(FractalCubicNoise::new),
CELLULAR_HEIGHT(CellHeightNoise::new),
CLOVER(CloverNoise::new),
CLOVER_BILINEAR((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR)),
CLOVER_BILINEAR_STARCAST_3((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_3)),
CLOVER_BILINEAR_STARCAST_6((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_6)),
CLOVER_BILINEAR_STARCAST_9((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_9)),
CLOVER_BILINEAR_STARCAST_12((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BILINEAR_STARCAST_12)),
CLOVER_BICUBIC((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.BICUBIC)),
CLOVER_HERMITE((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE)),
CLOVER_STARCAST_3((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_3)),
CLOVER_STARCAST_6((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_6)),
CLOVER_STARCAST_9((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_9)),
CLOVER_STARCAST_12((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.STARCAST_12)),
CLOVER_HERMITE_STARCAST_3((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_3)),
CLOVER_HERMITE_STARCAST_6((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_6)),
CLOVER_HERMITE_STARCAST_9((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_9)),
CLOVER_HERMITE_STARCAST_12((s) -> new InterpolatedNoise(s, CLOVER, InterpolationMethod.HERMITE_STARCAST_12)),
VASCULAR(VascularNoise::new);
private final NoiseFactory f;
NoiseType(NoiseFactory f) {
this.f = f;
}
public NoiseGenerator create(long seed) {
return f.create(seed);
}
}

View File

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

View File

@@ -1,104 +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.engine.noise;
import com.volmit.iris.util.math.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

@@ -1,70 +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.engine.noise;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.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

@@ -1,94 +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.engine.noise;
import com.volmit.iris.util.math.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

@@ -1,52 +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.engine.noise;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.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

@@ -1,56 +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.engine.noise;
import com.volmit.iris.util.math.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;
}
public boolean isNoScale() {
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;
}
}

View File

@@ -27,7 +27,7 @@ import com.volmit.iris.engine.data.B;
import com.volmit.iris.engine.data.DataProvider;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.IrisAccess;
import com.volmit.iris.engine.noise.CNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.common.IRare;
import com.volmit.iris.util.collection.KList;

View File

@@ -20,7 +20,7 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.noise.CNG;
import com.volmit.iris.util.noise.CNG;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;

View File

@@ -21,13 +21,13 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.interpolation.IrisInterpolation;
import com.volmit.iris.engine.noise.CNG;
import com.volmit.iris.util.noise.CNG;
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.engine.stream.ProceduralStream;
import com.volmit.iris.engine.stream.interpolation.Interpolated;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;

View File

@@ -24,7 +24,7 @@ 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.engine.stream.ProceduralStream;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;
import lombok.Data;

View File

@@ -22,8 +22,8 @@ import com.volmit.iris.core.project.loader.IrisData;
import com.volmit.iris.engine.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.ArrayType;
import com.volmit.iris.engine.object.annotations.Desc;
import com.volmit.iris.engine.stream.ProceduralStream;
import com.volmit.iris.engine.stream.interpolation.Interpolated;
import com.volmit.iris.util.stream.ProceduralStream;
import com.volmit.iris.util.stream.interpolation.Interpolated;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.RNG;
import lombok.AllArgsConstructor;

Some files were not shown because too many files have changed in this diff Show More