mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-01 23:47:21 +00:00
v
This commit is contained in:
parent
98a26a40b1
commit
00d4f7640e
@ -111,6 +111,8 @@
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<skip.copy>false</skip.copy>
|
||||
<secretary.build>package</secretary.build>
|
||||
<development.location>${user.home}\Documents\development\server\plugins\${project.name}.jar</development.location>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
|
4
pom.xml
4
pom.xml
@ -7,6 +7,8 @@
|
||||
<version>1.0</version>
|
||||
<name>Iris</name>
|
||||
<properties>
|
||||
<skip.copy>false</skip.copy>
|
||||
<secretary.build>package</secretary.build>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
@ -85,7 +87,7 @@
|
||||
<dependency>
|
||||
<groupId>ninja.bytecode</groupId>
|
||||
<artifactId>Shuriken</artifactId>
|
||||
<version>1.0</version>
|
||||
<version>1.0.1</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
|
@ -14,7 +14,6 @@ import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerMoveEvent;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
@ -1,56 +1,54 @@
|
||||
package ninja.bytecode.iris;
|
||||
|
||||
import java.awt.Polygon;
|
||||
import java.awt.geom.Point2D;
|
||||
import java.awt.geom.Point2D.Double;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.logging.log4j.core.layout.GelfLayout;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.util.Vector;
|
||||
import org.bukkit.util.noise.PerlinNoiseGenerator;
|
||||
|
||||
import net.minecraft.server.v1_12_R1.GenLayer;
|
||||
import net.minecraft.server.v1_12_R1.WorldProviderNormal;
|
||||
import ninja.bytecode.iris.biome.CBI;
|
||||
import ninja.bytecode.iris.gen.GenLayerBase;
|
||||
import ninja.bytecode.iris.gen.GenLayerSuperSample;
|
||||
import ninja.bytecode.iris.gen.GenLayerBiome;
|
||||
import ninja.bytecode.iris.gen.IGenLayer;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
private MB AIR = new MB(Material.AIR);
|
||||
private MB WATER = new MB(Material.STATIONARY_WATER);
|
||||
private MB SAND = new MB(Material.SAND);
|
||||
private MB BEDROCK = new MB(Material.BEDROCK);
|
||||
private GList<IGenLayer> genLayers;
|
||||
private GenLayerBase glBase;
|
||||
private GenLayerSuperSample glSuperSample;
|
||||
private int waterLevel = 127;
|
||||
private GList<Vector> updates = new GList<>();
|
||||
private String wf;
|
||||
private GenLayerBiome glBiome;
|
||||
private GMap<Location, TreeType> trees;
|
||||
private RNG rng;
|
||||
private World world;
|
||||
private PolygonGenerator g;
|
||||
|
||||
@Override
|
||||
public void onInit(World world, Random random)
|
||||
{
|
||||
wf = world.getName();
|
||||
updates = new GList<>();
|
||||
this.world = world;
|
||||
trees = new GMap<>();
|
||||
genLayers = new GList<>();
|
||||
RNG rng = new RNG(world.getSeed());
|
||||
rng = new RNG(world.getSeed());
|
||||
genLayers.add(glBase = new GenLayerBase(this, world, random, rng.nextRNG()));
|
||||
genLayers.add(glSuperSample = new GenLayerSuperSample(this, world, random, rng.nextRNG()));
|
||||
genLayers.add(glBiome = new GenLayerBiome(this, world, random, rng.nextRNG()));
|
||||
g = new PolygonGenerator(rng, 16, 0.01, 1, (c) -> c);
|
||||
}
|
||||
|
||||
public int getHeight(double dx, double dz)
|
||||
{
|
||||
double height = M.clip(glSuperSample.getSuperSampledHeight(dx, dz), 0D, 1D);
|
||||
double height = M.clip(getRawHeight(dx, dz), 0D, 1D);
|
||||
|
||||
return (int) (height * 253);
|
||||
}
|
||||
@ -70,18 +68,84 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
@Override
|
||||
public Biome genColumn(int wxx, int wzx, int x, int z)
|
||||
{
|
||||
if(true)
|
||||
{
|
||||
for(int i = 0; i < 1; i++)
|
||||
{
|
||||
setBlock(x, i, z, Material.CONCRETE, (byte) g.getIndex(wxx, wzx));
|
||||
}
|
||||
|
||||
return Biome.PLAINS;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
return genBaseColumn(wxx, wzx, x, z);
|
||||
}
|
||||
}
|
||||
|
||||
private Biome genBaseColumn(int wxx, int wzx, int x, int z)
|
||||
{
|
||||
int seaLevel = Iris.settings.gen.seaLevel;
|
||||
int wx = (int) Math.round((double) wxx * Iris.settings.gen.horizontalZoom);
|
||||
int wz = (int) Math.round((double) wzx * Iris.settings.gen.horizontalZoom);
|
||||
int height = getHeight(wx, wz);
|
||||
|
||||
for(int i = 0; i < height; i++)
|
||||
CBI biome = glBiome.getBiome(wx * Iris.settings.gen.biomeScale, wz * Iris.settings.gen.biomeScale);
|
||||
int height = getHeight(wx, wz) + 25;
|
||||
|
||||
for(int i = 0; i < Math.max(height, seaLevel); i++)
|
||||
{
|
||||
MB mb = new MB(Material.STONE);
|
||||
boolean underwater = i >= height && i < seaLevel;
|
||||
boolean underground = i < height;
|
||||
|
||||
if(underwater)
|
||||
{
|
||||
mb = WATER;
|
||||
}
|
||||
|
||||
if(underground && (height - 1) - i < glBase.scatterInt(x, i, z, 4) + 2)
|
||||
{
|
||||
mb = biome.getDirt(wx, wz);
|
||||
}
|
||||
|
||||
if(i == height - 1)
|
||||
{
|
||||
mb = biome.getSurface(wx, wz, rng);
|
||||
|
||||
if(height < 254 && height >= seaLevel)
|
||||
{
|
||||
MB place = biome.getScatterChanceSingle();
|
||||
|
||||
if(!place.material.equals(Material.AIR))
|
||||
{
|
||||
if(mb.material.equals(Material.GRASS) || mb.material.equals(Material.SAND) || mb.material.equals(Material.DIRT))
|
||||
{
|
||||
setBlock(x, i + 1, z, place.material, place.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(height < 240 && height >= seaLevel)
|
||||
{
|
||||
TreeType s = biome.getTreeChanceSingle();
|
||||
|
||||
if(s != null)
|
||||
{
|
||||
setBlock(x, i + 1, z, Material.AIR);
|
||||
trees.put(new Location(world, x, i + 1, z), s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(Iris.settings.gen.flatBedrock ? i == 0 : i < glBase.scatterInt(x, i, z, 3))
|
||||
{
|
||||
mb = BEDROCK;
|
||||
}
|
||||
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
return Biome.PLAINS;
|
||||
return biome.getRealBiome();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -105,6 +169,17 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
@Override
|
||||
public void onInitChunk(World world, int x, int z, Random random)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostChunk(World world, int x, int z, Random random)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public double getBiomeBorder(double dx, double dz)
|
||||
{
|
||||
return glBiome.getCenterPercent(dx, dz);
|
||||
}
|
||||
}
|
@ -17,4 +17,14 @@ public class MB
|
||||
{
|
||||
this(material, 0);
|
||||
}
|
||||
|
||||
public static MB of(Material f)
|
||||
{
|
||||
return new MB(f);
|
||||
}
|
||||
|
||||
public static MB of(Material f, int a)
|
||||
{
|
||||
return new MB(f, a);
|
||||
}
|
||||
}
|
||||
|
@ -59,6 +59,8 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
|
||||
onInitChunk(world, x, z, random);
|
||||
TaskResult r = tg.execute();
|
||||
onPostChunk(world, x, z, random);
|
||||
|
||||
rs.put(r.timeElapsed);
|
||||
Shuriken.profiler.stop("chunkgen-" + world.getName());
|
||||
|
||||
@ -70,6 +72,11 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
if(cl.flip())
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
@ -83,9 +90,11 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
}
|
||||
|
||||
public abstract void onInit(World world, Random random);
|
||||
|
||||
|
||||
public abstract void onInitChunk(World world, int x, int z, Random random);
|
||||
|
||||
public abstract void onPostChunk(World world, int x, int z, Random random);
|
||||
|
||||
public abstract Biome genColumn(int wx, int wz, int x, int z);
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@ -109,4 +118,14 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
|
||||
{
|
||||
data.setBlock(x, y, z, b, d);
|
||||
}
|
||||
|
||||
protected Material getType(int x, int y, int z)
|
||||
{
|
||||
return data.getType(x, y, z);
|
||||
}
|
||||
|
||||
protected byte getData(int x, int y, int z)
|
||||
{
|
||||
return data.getData(x, y, z);
|
||||
}
|
||||
}
|
@ -7,41 +7,31 @@ public class Settings
|
||||
|
||||
public static class PerformanceSettings
|
||||
{
|
||||
public PerformanceMode performanceMode = PerformanceMode.UNLIMITED;
|
||||
public PerformanceMode performanceMode = PerformanceMode.HALF_CPU;
|
||||
public int threadCount = 4;
|
||||
public int threadPriority = Thread.MAX_PRIORITY;
|
||||
}
|
||||
|
||||
public static class GeneratorSettings
|
||||
{
|
||||
public double horizontalZoom = 2.125; // 1.856 2.556
|
||||
{
|
||||
public double horizontalZoom = 1.325; // 1.856 2.556
|
||||
public double heightFracture = 155;
|
||||
public double heightMultiplier = 1.154;
|
||||
public double heightExponentBase = 1;
|
||||
public double heightExponentMultiplier = 1.41;
|
||||
public double humidityByHeightInfluence = 0.1;
|
||||
public double temperatureByHeightInfluence = 0.19;
|
||||
public double temperatureByHeightOffset = 0.25;
|
||||
public double biomeSoftFracture = 66;
|
||||
public double biomeSharpFracture = 2;
|
||||
public double temperatureScale = 1.65;
|
||||
public double humidityScale = 1.4;
|
||||
public double heightScale = 1;
|
||||
public double superHeightScale = 0.65;
|
||||
public double altBiomeScale = 1;
|
||||
public double baseHeight = 0.3415;
|
||||
public double temperatureIgnorance = 1.55;
|
||||
public double humidityIgnorance = 1.55;
|
||||
public double heightIgnorance = 1;
|
||||
public double mountainMultiplier = 1.65;
|
||||
public double mountainHorizontalZoom = 3.15;
|
||||
public double mountainSink = 0.0445;
|
||||
public double superSamplerRadius = 32;
|
||||
public int superSamplerIterations = 14;
|
||||
public int superSamples = 12;
|
||||
public double superSamplerMultiplier = 1;
|
||||
public double superSampleThreshold = 0.00984;
|
||||
public double superSampleOpacity = 1;
|
||||
public int superSamplerIterations = 9;
|
||||
public double caveSpread = 3.466;
|
||||
public double caveChance = 0.03;
|
||||
public int seaLevel = 63;
|
||||
public double biomeScale = 1.31;
|
||||
public double landChance = 0.75;
|
||||
|
||||
public boolean flatBedrock = false;
|
||||
}
|
||||
|
254
src/main/java/ninja/bytecode/iris/biome/CBI.java
Normal file
254
src/main/java/ninja/bytecode/iris/biome/CBI.java
Normal file
@ -0,0 +1,254 @@
|
||||
package ninja.bytecode.iris.biome;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.TreeSpecies;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import ninja.bytecode.iris.MB;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class CBI
|
||||
{
|
||||
//@builder
|
||||
public static final CBI OCEAN = new CBI("Ocean", Biome.OCEAN)
|
||||
.surface(MB.of(Material.SAND));
|
||||
public static final CBI DEEP_OCEAN = new CBI("Deep Ocean", Biome.DEEP_OCEAN)
|
||||
.surface(MB.of(Material.SAND));
|
||||
public static final CBI DESERT = new CBI("Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.08)
|
||||
.dirt(MB.of(Material.SANDSTONE));
|
||||
public static final CBI DESERT_RED = new CBI("Red Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND, 1))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.08)
|
||||
.dirt(MB.of(Material.RED_SANDSTONE));
|
||||
public static final CBI DESERT_COMBINED = new CBI("Combined Desert", Biome.DESERT)
|
||||
.surface(MB.of(Material.SAND), MB.of(Material.SAND, 1))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.08)
|
||||
.dirt(MB.of(Material.SANDSTONE), MB.of(Material.RED_SANDSTONE))
|
||||
.simplexSurface();
|
||||
public static final CBI DESERT_HILLS = new CBI("Desert Hills", Biome.DESERT_HILLS)
|
||||
.surface(MB.of(Material.SAND))
|
||||
.scatter(MB.of(Material.DEAD_BUSH, 0), 0.08)
|
||||
.dirt(MB.of(Material.SANDSTONE));
|
||||
public static final CBI MESA = new CBI("Mesa", Biome.MESA)
|
||||
.surface(MB.of(Material.HARD_CLAY), MB.of(Material.STAINED_CLAY, 1), MB.of(Material.STAINED_CLAY, 8), MB.of(Material.STAINED_CLAY, 12))
|
||||
.dirt(MB.of(Material.CLAY), MB.of(Material.SAND), MB.of(Material.SAND, 1))
|
||||
.simplexSurface();
|
||||
public static final CBI SAVANNA = new CBI("Savanna", Biome.SAVANNA)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18)
|
||||
.tree(TreeType.ACACIA, 0.2);
|
||||
public static final CBI SAVANNA_HILLS = new CBI("Savanna Hills", Biome.SAVANNA_ROCK)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.18)
|
||||
.tree(TreeType.ACACIA, 0.2);
|
||||
public static final CBI JUNGLE = new CBI("Jungle", Biome.JUNGLE)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.58)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI JUNGLE_HILLS = new CBI("Jungle Hills", Biome.JUNGLE_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.58)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI SWAMP = new CBI("Swamp", Biome.SWAMPLAND)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
|
||||
public static final CBI PLAINS = new CBI("Plains", Biome.PLAINS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.38)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.03);
|
||||
public static final CBI DECAYING_PLAINS = new CBI("Decaying Plains", Biome.PLAINS)
|
||||
.surface(MB.of(Material.GRASS_PATH), MB.of(Material.GRASS))
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.04)
|
||||
.simplexSurface();
|
||||
public static final CBI FOREST = new CBI("Forest", Biome.FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI FOREST_HILLS = new CBI("Forest Hills", Biome.FOREST_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI BIRCH_FOREST = new CBI("Birch Forest", Biome.BIRCH_FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI BIRCH_FOREST_HILLS = new CBI("Birch Forest Hills", Biome.BIRCH_FOREST_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI ROOFED_FOREST = new CBI("Roofed Forest", Biome.ROOFED_FOREST)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 1), 0.23)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.13);
|
||||
public static final CBI TAIGA = new CBI("Taiga", Biome.TAIGA)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.07);
|
||||
public static final CBI EXTREME_HILLS = new CBI("Extreme Hills", Biome.EXTREME_HILLS)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04);
|
||||
public static final CBI EXTREME_HILLS_TREES = new CBI("Extreme Hills +", Biome.EXTREME_HILLS_WITH_TREES)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.09);
|
||||
public static final CBI TAIGA_COLD = new CBI("Taiga Cold", Biome.TAIGA_COLD)
|
||||
.scatter(MB.of(Material.LONG_GRASS, 2), 0.04);
|
||||
public static final CBI TAIGA_COLD_HILLS = new CBI("Taiga Cold Hills", Biome.TAIGA_COLD_HILLS);
|
||||
public static final CBI ICE_FLATS = new CBI("Ice Flats", Biome.ICE_FLATS);
|
||||
public static final CBI ICE_MOUNTAINS = new CBI("Ice Mountains", Biome.ICE_MOUNTAINS);
|
||||
public static final CBI REDWOOD_TAIGA = new CBI("Redwood Taiga", Biome.REDWOOD_TAIGA)
|
||||
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
.simplexSurface();
|
||||
public static final CBI REDWOOD_TAIGA_HILLS = new CBI("Redwood Taiga Hills", Biome.REDWOOD_TAIGA_HILLS)
|
||||
.surface(MB.of(Material.DIRT, 2), MB.of(Material.DIRT, 1))
|
||||
.simplexSurface();
|
||||
|
||||
//@done
|
||||
|
||||
private String name;
|
||||
private Biome realBiome;
|
||||
private double height;
|
||||
private double amp;
|
||||
private GMap<TreeType, Double> treeChance;
|
||||
private GList<MB> surface;
|
||||
private GList<MB> dirt;
|
||||
private GMap<MB, Double> scatterChance;
|
||||
private boolean simplexScatter;
|
||||
private PolygonGenerator.EnumPolygonGenerator<MB> poly;
|
||||
|
||||
public CBI(String name, Biome realBiome)
|
||||
{
|
||||
this.name = name;
|
||||
this.realBiome = realBiome;
|
||||
this.height = 0.125;
|
||||
this.amp = 0;
|
||||
scatterChance = new GMap<>();
|
||||
treeChance = new GMap<>();
|
||||
surface(new MB(Material.GRASS)).dirt(new MB(Material.DIRT), new MB(Material.DIRT, 1));
|
||||
}
|
||||
|
||||
public CBI scatter(MB mb, Double chance)
|
||||
{
|
||||
scatterChance.put(mb, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI tree(TreeType t, Double chance)
|
||||
{
|
||||
treeChance.put(t, chance);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI simplexSurface()
|
||||
{
|
||||
simplexScatter = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI surface(MB... mbs)
|
||||
{
|
||||
surface = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI dirt(MB... mbs)
|
||||
{
|
||||
dirt = new GList<>(mbs);
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI height(double height)
|
||||
{
|
||||
this.height = height;
|
||||
return this;
|
||||
}
|
||||
|
||||
public CBI amp(double amp)
|
||||
{
|
||||
this.amp = amp;
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public Biome getRealBiome()
|
||||
{
|
||||
return realBiome;
|
||||
}
|
||||
|
||||
public double getHeight()
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
public double getAmp()
|
||||
{
|
||||
return amp;
|
||||
}
|
||||
|
||||
public GList<MB> getSurface()
|
||||
{
|
||||
return surface;
|
||||
}
|
||||
|
||||
public GList<MB> getDirt()
|
||||
{
|
||||
return dirt;
|
||||
}
|
||||
|
||||
public MB getSurface(int wx, int wz, RNG rng)
|
||||
{
|
||||
if(simplexScatter)
|
||||
{
|
||||
if(poly == null)
|
||||
{
|
||||
poly = new PolygonGenerator.EnumPolygonGenerator<MB>(rng, 0.05, 12, getSurface().toArray(new MB[getSurface().size()]), (g) -> {
|
||||
return g.fractureWith(new CNG(rng.nextRNG(), 1D, 2).scale(0.155), 24);
|
||||
});
|
||||
}
|
||||
|
||||
return poly.getChoice(wx, wz);
|
||||
}
|
||||
|
||||
return getSurface().getRandom();
|
||||
}
|
||||
|
||||
public MB getDirt(int wx, int wz)
|
||||
{
|
||||
return getDirt().getRandom();
|
||||
}
|
||||
|
||||
public GMap<MB, Double> getScatterChance()
|
||||
{
|
||||
return scatterChance;
|
||||
}
|
||||
|
||||
public MB getScatterChanceSingle()
|
||||
{
|
||||
for(MB i : getScatterChance().keySet())
|
||||
{
|
||||
if(M.r(getScatterChance().get(i)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return MB.of(Material.AIR);
|
||||
}
|
||||
|
||||
public GMap<TreeType, Double> getTreeChance()
|
||||
{
|
||||
return treeChance;
|
||||
}
|
||||
|
||||
public TreeType getTreeChanceSingle()
|
||||
{
|
||||
for(TreeType i : getTreeChance().keySet())
|
||||
{
|
||||
if(M.r(getTreeChance().get(i)))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package ninja.bytecode.iris.gen;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
@ -13,6 +14,7 @@ public class GenLayer implements IGenLayer
|
||||
protected World world;
|
||||
protected Random random;
|
||||
protected IrisGenerator iris;
|
||||
protected Biome biome = Biome.OCEAN;
|
||||
|
||||
public GenLayer(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
|
100
src/main/java/ninja/bytecode/iris/gen/GenLayerBiome.java
Normal file
100
src/main/java/ninja/bytecode/iris/gen/GenLayerBiome.java
Normal file
@ -0,0 +1,100 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.iris.biome.CBI;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator.EnumPolygonGenerator;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerBiome extends GenLayer
|
||||
{
|
||||
private CNG fractures2;
|
||||
private CNG fractures4;
|
||||
private PolygonGenerator.EnumPolygonGenerator<CBI> biomeGenerator;
|
||||
private Function<CNG, CNG> factory;
|
||||
private double closest;
|
||||
|
||||
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
double scale = 1.25D;
|
||||
factory = (g) -> g
|
||||
.fractureWith(new CNG(g.nextRNG().nextRNG(), 1D, 32)
|
||||
.scale(0.2112)
|
||||
.fractureWith(new CNG(g.nextRNG(), 1D, 16)
|
||||
.scale(0.132),
|
||||
333), 588);
|
||||
fractures2 = new CNG(rng.nextRNG(), 1, 32).scale(0.02);
|
||||
fractures4 = new CNG(rng.nextRNG(), 1, 16).scale(0.12);
|
||||
|
||||
biomeGenerator = new PolygonGenerator.EnumPolygonGenerator<CBI>(rng.nextRNG(), 0.00755 * Iris.settings.gen.biomeScale, 1,
|
||||
new CBI[] {
|
||||
CBI.DESERT,
|
||||
CBI.DESERT_HILLS,
|
||||
CBI.MESA,
|
||||
CBI.DESERT_COMBINED,
|
||||
CBI.SAVANNA,
|
||||
CBI.SAVANNA_HILLS,
|
||||
CBI.DESERT_RED,
|
||||
CBI.JUNGLE,
|
||||
CBI.JUNGLE_HILLS,
|
||||
CBI.SWAMP,
|
||||
CBI.OCEAN,
|
||||
CBI.PLAINS,
|
||||
CBI.DECAYING_PLAINS,
|
||||
CBI.FOREST,
|
||||
CBI.FOREST_HILLS,
|
||||
CBI.BIRCH_FOREST,
|
||||
CBI.BIRCH_FOREST_HILLS,
|
||||
CBI.ROOFED_FOREST,
|
||||
CBI.TAIGA,
|
||||
CBI.EXTREME_HILLS,
|
||||
CBI.EXTREME_HILLS_TREES,
|
||||
CBI.TAIGA_COLD,
|
||||
CBI.TAIGA_COLD_HILLS,
|
||||
CBI.ICE_FLATS,
|
||||
CBI.ICE_MOUNTAINS,
|
||||
CBI.REDWOOD_TAIGA,
|
||||
CBI.REDWOOD_TAIGA_HILLS,
|
||||
}, factory);
|
||||
//@done
|
||||
}
|
||||
|
||||
public CBI getBiome(double x, double z)
|
||||
{
|
||||
double scram2 = fractures2.noise(x, z) * 188.35;
|
||||
double scram4 = fractures4.noise(x, z) * 47;
|
||||
double a = x - scram2 - scram4;
|
||||
double b = z + scram2 + scram4;
|
||||
a += Math.sin(b) * 12;
|
||||
b += Math.cos(a) * 12;
|
||||
return biomeGenerator.getChoice(a, b);
|
||||
}
|
||||
|
||||
public double getCenterPercent(double x, double z)
|
||||
{
|
||||
double scram2 = fractures2.noise(x, z) * 188.35;
|
||||
double scram4 = fractures4.noise(x, z) * 47;
|
||||
double a = x - scram2 - scram4;
|
||||
double b = z + scram2 + scram4;
|
||||
a += Math.sin(b) * 12;
|
||||
b += Math.cos(a) * 12;
|
||||
return biomeGenerator.getClosestNeighbor(a, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
CBI biome = getBiome(dx, dz);
|
||||
return ((1D + (biome.getAmp())) * noise) + (biome.getHeight() / 3D);
|
||||
}
|
||||
}
|
26
src/main/java/ninja/bytecode/iris/gen/GenLayerCaves.java
Normal file
26
src/main/java/ninja/bytecode/iris/gen/GenLayerCaves.java
Normal file
@ -0,0 +1,26 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerCaves extends GenLayer
|
||||
{
|
||||
public GenLayerCaves(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class GenLayerDeepOcean extends GenLayer
|
||||
private double deepHeight = 0.493;
|
||||
|
||||
public GenLayerDeepOcean(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
gen = new CNG(rng.nextRNG(), 1D, 4)
|
||||
|
@ -12,9 +12,9 @@ import ninja.bytecode.shuriken.math.RNG;
|
||||
public class GenLayerFracture extends GenLayer
|
||||
{
|
||||
private CNG gen;
|
||||
private CNG cond;
|
||||
private CNG cond;
|
||||
private double shootHeight = 0.563;
|
||||
|
||||
|
||||
public GenLayerFracture(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
|
@ -1,36 +0,0 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerMountains extends GenLayer
|
||||
{
|
||||
private CNG gen;
|
||||
|
||||
public GenLayerMountains(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
gen = new CNG(rng.nextRNG(), 1D, 2)
|
||||
.scale(0.0011 * Iris.settings.gen.mountainHorizontalZoom)
|
||||
.child(new CNG(rng.nextRNG(), 1D, 3).scale(0.00012 * Iris.settings.gen.mountainHorizontalZoom))
|
||||
.child(new CNG(rng.nextRNG(), 1D, 4).scale(0.00014 * Iris.settings.gen.mountainHorizontalZoom))
|
||||
.child(new CNG(rng.nextRNG(), 1D, 5).scale(0.00015 * Iris.settings.gen.mountainHorizontalZoom))
|
||||
.injectWith(CNG.MULTIPLY)
|
||||
.fractureWith(new CNG(rng.nextRNG(), 1D, 1)
|
||||
.scale(0.05), 25);
|
||||
//@done
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise + (gen.noise(dx, dz) - Iris.settings.gen.mountainSink) * Iris.settings.gen.mountainMultiplier;
|
||||
}
|
||||
}
|
@ -1,81 +0,0 @@
|
||||
package ninja.bytecode.iris.gen;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.IrisGenerator;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerSuperSample extends GenLayer
|
||||
{
|
||||
private CNG gen;
|
||||
private CNG radius;
|
||||
|
||||
public GenLayerSuperSample(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
gen = new CNG(rng.nextRNG(), 1D, 4)
|
||||
.scale(0.02 * Iris.settings.gen.superSamplerMultiplier);
|
||||
radius = new CNG(rng.nextRNG(), 1D, 2)
|
||||
.scale(0.01);
|
||||
//@done
|
||||
}
|
||||
|
||||
public double getSuperSampledHeight(double dx, double dz)
|
||||
{
|
||||
double ssf = 0;
|
||||
double height = iris.getRawHeight(dx, dz);
|
||||
|
||||
if(Iris.settings.gen.superSamplerIterations == 0)
|
||||
{
|
||||
return height;
|
||||
}
|
||||
|
||||
double t = 0;
|
||||
double sig = Iris.settings.gen.superSampleOpacity * radius.noise(dx, dz);
|
||||
|
||||
for(int i = 0; i < Iris.settings.gen.superSamplerIterations; i++)
|
||||
{
|
||||
//@builder
|
||||
double ss = 0;
|
||||
double mul = Iris.settings.gen.superSamplerRadius;
|
||||
double[] ssv = new double[] {
|
||||
getRawHeight(dx, dz, Math.toRadians(getAngle(dx, dz)), mul / (double)(i + 1), true),
|
||||
getRawHeight(dx, dz, Math.toRadians(getAngle(dx, dz)), mul / (double)(i + 1), false)
|
||||
};
|
||||
//@done
|
||||
for(double j : ssv)
|
||||
{
|
||||
ss += j;
|
||||
}
|
||||
|
||||
t += (double) (1D / (i + 1));
|
||||
ssf += (ss / 2D) / (double) (i + 1);
|
||||
}
|
||||
|
||||
return (height * (1D - sig)) + ((ssf / t) * sig);
|
||||
}
|
||||
|
||||
public double getRawHeight(double dx, double dz, double rad, double mult, boolean a)
|
||||
{
|
||||
double dax = dx + ((Math.sin(rad) * mult) * (a ? 1 : 1));
|
||||
double daz = dz + ((Math.cos(rad) * mult) * (a ? -1 : -1));
|
||||
return iris.getRawHeight(dax, daz);
|
||||
}
|
||||
|
||||
public double getAngle(double x, double z)
|
||||
{
|
||||
return M.percentRange(gen.noise(x, z), 0, 365);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
85
src/main/java/ninja/bytecode/iris/util/PolygonGenerator.java
Normal file
85
src/main/java/ninja/bytecode/iris/util/PolygonGenerator.java
Normal file
@ -0,0 +1,85 @@
|
||||
package ninja.bytecode.iris.util;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class PolygonGenerator
|
||||
{
|
||||
private CNG[] gen;
|
||||
private int bits;
|
||||
private int possibilities;
|
||||
|
||||
public PolygonGenerator(RNG rng, int possibilities, double scale, int octaves, Function<CNG, CNG> factory)
|
||||
{
|
||||
bits = 1;
|
||||
this.possibilities = possibilities;
|
||||
|
||||
while(Math.pow(2, bits) <= possibilities)
|
||||
{
|
||||
bits++;
|
||||
}
|
||||
|
||||
bits++;
|
||||
bits = bits > 32 ? 32 : bits;
|
||||
gen = new CNG[bits];
|
||||
|
||||
for(int i = 0; i < bits; i++)
|
||||
{
|
||||
gen[i] = new CNG(rng.nextRNG(), 1D, 1).scale(scale);
|
||||
gen[i] = factory.apply(gen[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 0.0 to 1.0 where 0.0 is directly on the border of another region and 1.0 is perfectly in the center of a region
|
||||
* @param x the x
|
||||
* @param z the z
|
||||
* @return the closest neighbor threshold.
|
||||
*/
|
||||
public double getClosestNeighbor(double... dim)
|
||||
{
|
||||
double closest = 0.5;
|
||||
|
||||
for(int i = 0; i < gen.length; i++)
|
||||
{
|
||||
double distance = Math.abs(gen[i].noise(dim) - 0.5);
|
||||
|
||||
if(distance < closest)
|
||||
{
|
||||
closest = distance;
|
||||
}
|
||||
}
|
||||
|
||||
return (closest * 2);
|
||||
}
|
||||
|
||||
public int getIndex(double... dim)
|
||||
{
|
||||
int data = 0;
|
||||
|
||||
for(int i = 0; i < gen.length; i++)
|
||||
{
|
||||
data |= gen[i].noise(dim) > 0.5 ? i == 0 ? 1 : 1 << i : 0;
|
||||
}
|
||||
|
||||
return data % possibilities;
|
||||
}
|
||||
|
||||
public static class EnumPolygonGenerator<T> extends PolygonGenerator
|
||||
{
|
||||
private T[] choices;
|
||||
|
||||
public EnumPolygonGenerator(RNG rng, double scale, int octaves, T[] choices, Function<CNG, CNG> factory)
|
||||
{
|
||||
super(rng, choices.length, scale / (double) choices.length, octaves, factory);
|
||||
this.choices = choices;
|
||||
}
|
||||
|
||||
public T getChoice(double... dim)
|
||||
{
|
||||
return choices[super.getIndex(dim)];
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user