Adapt for 1.14

This commit is contained in:
Daniel Mills 2019-10-16 07:26:17 -04:00
parent b29ad7ed0c
commit d72518207e
15 changed files with 658 additions and 511 deletions

View File

@ -77,37 +77,33 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<artifactId>commons-lang</artifactId>
<groupId>commons-lang</groupId>
</exclusion>
<exclusion>
<artifactId>json-simple</artifactId>
<groupId>com.googlecode.json-simple</groupId>
</exclusion>
<exclusion>
<artifactId>guava</artifactId>
<groupId>com.google.guava</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
<exclusion>
<artifactId>bungeecord-chat</artifactId>
<groupId>net.md-5</groupId>
</exclusion>
<exclusion>
<artifactId>snakeyaml</artifactId>
<groupId>org.yaml</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>cb</groupId>
<artifactId>craftbukkit-1.12.2</artifactId>
<artifactId>craftbukkit-1.14.4</artifactId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.12.2.jar</systemPath>
<systemPath>${project.basedir}/lib/craftbukkit-1.14.4.jar</systemPath>
</dependency>
</dependencies>
<properties>

View File

@ -90,15 +90,15 @@
<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.12.2-R0.1-SNAPSHOT</version>
<version>1.14.4-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<artifactId>craftbukkit-1.12.2</artifactId>
<artifactId>craftbukkit-1.14.4</artifactId>
<groupId>cb</groupId>
<version>1</version>
<scope>system</scope>
<systemPath>${project.basedir}/lib/craftbukkit-1.12.2.jar</systemPath>
<systemPath>${project.basedir}/lib/craftbukkit-1.14.4.jar</systemPath>
</dependency>
</dependencies>
</project>

View File

@ -20,14 +20,20 @@ import ninja.bytecode.shuriken.execution.TaskExecutor;
public class Iris extends JavaPlugin implements Listener
{
public static TaskExecutor noisePool;
public static TaskExecutor blockPool;
public static IrisGenerator gen;
public static Settings settings;
public static Iris instance;
public void onEnable()
{
instance = this;
settings = new Settings();
gen = new IrisGenerator();
noisePool = new TaskExecutor(4, Thread.MIN_PRIORITY, "Iris Generator");
noisePool = new TaskExecutor(settings.performance.threadCount, settings.performance.threadPriority, "Iris Noise Generator");
blockPool = new TaskExecutor(1, Thread.MAX_PRIORITY, "Iris Decorator");
getServer().getPluginManager().registerEvents((Listener) this, this);
// Debug world regens
GSet<String> ws = new GSet<>();
World w = createIrisWorld();
@ -38,7 +44,7 @@ public class Iris extends JavaPlugin implements Listener
i.setFlying(true);
i.setGameMode(GameMode.CREATIVE);
}
for(String i : ws)
{
Bukkit.unloadWorld(i, false);
@ -48,6 +54,7 @@ public class Iris extends JavaPlugin implements Listener
public void onDisable()
{
noisePool.close();
blockPool.close();
}
@Override

View File

@ -5,16 +5,25 @@ import java.util.Random;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.Bisected;
import org.bukkit.block.data.Bisected.Half;
import org.bukkit.block.data.BlockData;
import ninja.bytecode.iris.gen.GenLayerBase;
import ninja.bytecode.iris.gen.GenLayerBiome;
import ninja.bytecode.iris.gen.GenLayerDeepOcean;
import ninja.bytecode.iris.gen.IGenLayer;
import ninja.bytecode.iris.util.RealBiome;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.math.M;
import ninja.bytecode.shuriken.math.RNG;
public class IrisGenerator extends ParallelChunkGenerator
{
private BlockData AIR = Material.AIR.createBlockData();
private BlockData WATER = Material.WATER.createBlockData();
private BlockData SAND = Material.SAND.createBlockData();
private BlockData BEDROCK = Material.BEDROCK.createBlockData();
private GList<IGenLayer> genLayers;
private GenLayerBiome glBiome;
private GenLayerBase glBase;
@ -23,10 +32,11 @@ public class IrisGenerator extends ParallelChunkGenerator
@Override
public void onInit(World world, Random random)
{
RNG rng = new RNG(world.getSeed());
genLayers = new GList<>();
genLayers.add(glBiome = new GenLayerBiome(world, random, rng));
genLayers.add(glBase = new GenLayerBase(world, random, rng));
RNG rng = new RNG(world.getSeed());
genLayers.add(glBiome = new GenLayerBiome(world, random, rng.nextRNG()));
genLayers.add(glBase = new GenLayerBase(world, random, rng.nextRNG()));
genLayers.add(new GenLayerDeepOcean(world, random, rng.nextRNG()));
}
public int getHeight(double dx, double dz)
@ -49,55 +59,165 @@ public class IrisGenerator extends ParallelChunkGenerator
public Biome genColumn(int wx, int wz, int x, int z)
{
int height = getHeight(wx, wz);
double temp = glBiome.getTemperature(wx, wz);
double humidity = glBiome.getHumidity(wx, wz);
RealBiome b = glBiome.getBiome(wx, wz);
boolean underwater = height < waterLevel;
for(int i = 0; i < Math.max(height, waterLevel); i++)
// Change biome to ocean / deep ocean if underwater height
if(underwater)
{
MB mb = underwater ? new MB(Material.STATIONARY_WATER) : new MB(Material.AIR);
if(i > height && underwater)
if(waterLevel - height > 20)
{
mb = new MB(Material.STATIONARY_WATER);
}
else if(i == 0 || (i == 1 && glBase.scatterChance(wx, i, wz, 0.45)))
{
mb = new MB(Material.BEDROCK);
}
else if(i == height - 1)
{
if(underwater)
if(temp <= 0.05)
{
mb = new MB(Material.SAND);
b = RealBiome.of(Biome.DEEP_FROZEN_OCEAN);
}
else if(temp <= 0.35)
{
b = RealBiome.of(Biome.DEEP_COLD_OCEAN);
}
else if(temp <= 0.55)
{
b = RealBiome.of(Biome.DEEP_OCEAN);
}
else if(temp <= 0.65)
{
b = RealBiome.of(Biome.DEEP_LUKEWARM_OCEAN);
}
else
{
b = RealBiome.of(Biome.DEEP_WARM_OCEAN);
}
}
else
{
if(temp <= 0.05)
{
b = RealBiome.of(Biome.FROZEN_OCEAN);
}
else if(temp <= 0.35)
{
b = RealBiome.of(Biome.COLD_OCEAN);
}
else if(temp <= 0.55)
{
b = RealBiome.of(Biome.OCEAN);
}
else if(temp <= 0.65)
{
b = RealBiome.of(Biome.LUKEWARM_OCEAN);
}
else
{
b = RealBiome.of(Biome.WARM_OCEAN);
}
}
}
if(height > 122 && height < 128 + (temp * 1.5) + (glBase.scatter(wx, wx * wz, wz) * 3.35))
{
b = RealBiome.of(Biome.BEACH);
}
for(int i = 0; i < Math.max(height, waterLevel); i++)
{
BlockData mb = AIR;
// Bedrockify
if(i == 0 || (!Iris.settings.gen.flatBedrock && ((i == 1 && glBase.scatterChance(wx, i, wz, 0.45)))))
{
mb = BEDROCK;
}
// Surface blocks
else if(i == height - 1)
{
if(temp > 0.6 && b.getBiome().equals(Biome.BEACH))
{
if(humidity > 0.6)
{
mb = Material.YELLOW_CONCRETE_POWDER.createBlockData();
}
else
{
mb = Material.BLACK_CONCRETE_POWDER.createBlockData();
}
}
else if(temp < 0.4 && b.getBiome().equals(Biome.BEACH))
{
if(humidity > 0.6)
{
mb = Material.WHITE_CONCRETE_POWDER.createBlockData();
}
else
{
mb = Material.LIGHT_GRAY_CONCRETE_POWDER.createBlockData();
}
}
else
{
mb = b.surface(wx, i, wz, glBase);
}
}
else if(i > height - glBase.scatterInt(wx, i, wz, 12))
// Dirt Blocks
else if(!underwater && i > height - glBase.scatterInt(wx, i, wz, 12))
{
if(underwater)
{
mb = new MB(Material.SAND);
}
else
{
mb = b.dirt(wx, i, wz, glBase);
}
mb = b.dirt(wx, i, wz, glBase);
}
// Create Water blocks
else if(i >= height && underwater)
{
mb = WATER;
}
// Below Dirt
else
{
mb = b.rock(wx, i, wz, glBase);
}
setBlock(x, i, z, mb.material, mb.data);
if(mb.getMaterial().equals(Material.AIR))
{
continue;
}
setBlock(x, i, z, mb);
}
BlockData v = b.getSurfaceDecoration();
if(v != null && underwater == b.isWater() && (underwater ? height < 125 : true))
{
if(v instanceof Bisected)
{
Bisected bs = (Bisected) v;
bs.setHalf(Half.BOTTOM);
setBlock(x, height, z, bs);
Bisected bst = (Bisected) bs.clone();
bst.setHalf(Half.TOP);
setBlock(x, height + 1, z, bst);
}
else
{
setBlock(x, height, z, v);
}
}
return b.getBiome();
@ -108,7 +228,7 @@ public class IrisGenerator extends ParallelChunkGenerator
return (int) (noise * max);
}
public MB pick(MB[] array, double noise)
public BlockData pick(BlockData[] array, double noise)
{
return array[pick(array.length, noise)];
}

View File

@ -1,20 +0,0 @@
package ninja.bytecode.iris;
import org.bukkit.Material;
public class MB
{
public final Material material;
public final byte data;
public MB(Material material, int data)
{
this.material = material;
this.data = (byte) data;
}
public MB(Material material)
{
this(material, 0);
}
}

View File

@ -5,11 +5,13 @@ import java.util.Random;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator;
import ninja.bytecode.iris.atomics.AtomicChunkData;
import ninja.bytecode.shuriken.Shuriken;
import ninja.bytecode.shuriken.execution.ChronoLatch;
import ninja.bytecode.shuriken.execution.NastyRunnable;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskGroup;
import ninja.bytecode.shuriken.execution.TaskExecutor.TaskResult;
import ninja.bytecode.shuriken.format.F;
@ -23,6 +25,7 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
private int wz;
private AtomicChunkData data;
private TaskGroup tg;
private TaskGroup tb;
private boolean ready = false;
private ChronoLatch cl = new ChronoLatch(1000);
private RollingSequence rs = new RollingSequence(512);
@ -41,6 +44,7 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
}
tg = Iris.noisePool.startWork();
tb = Iris.blockPool.startWork();
for(i = 0; i < 16; i++)
{
@ -55,16 +59,14 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
int d = j;
tg.queue(() ->
{
synchronized(biome)
{
biome.setBiome(c, d, genColumn(a, b, c, d));
}
biome.setBiome(c, d, genColumn(a, b, c, d));
});
}
}
TaskResult r = tg.execute();
rs.put(r.timeElapsed);
rs.put(r.timeElapsed + tb.execute().timeElapsed);
Shuriken.profiler.stop("chunkgen-" + world.getName());
if(cl.flip())
@ -75,6 +77,7 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
catch(Throwable e)
{
e.printStackTrace();
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < 16; j++)
@ -87,32 +90,27 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
return data.toChunkData();
}
public boolean isParallelCapable()
{
return true;
}
public abstract void onInit(World world, Random random);
public abstract Biome genColumn(int wx, int wz, int x, int z);
@SuppressWarnings("deprecation")
protected void setBlock(int x, int y, int z, Material b)
protected void queueSets(NastyRunnable r)
{
setBlock(x, y, z, b.getId(), (byte) 0);
tb.queue(r);
}
@SuppressWarnings("deprecation")
protected void setBlock(int x, int y, int z, Material b, byte d)
protected void setBlock(int x, int y, int z, BlockData b)
{
setBlock(x, y, z, b.getId(), d);
}
protected void setBlock(int x, int y, int z, int b)
{
setBlock(x, y, z, b, (byte) 0);
}
protected void setBlock(int x, int y, int z, int b, byte d)
{
synchronized(data)
if(b.getMaterial().equals(Material.AIR))
{
data.setBlock(x, y, z, b, d);
return;
}
tb.queue(() -> data.setBlock(x, y, z, b));
}
}

View File

@ -0,0 +1,9 @@
package ninja.bytecode.iris;
public enum PerformanceMode
{
SINGLE_THREADED,
UNLIMITED,
MATCH_CPU,
HALF_CPU,
}

View File

@ -0,0 +1,18 @@
package ninja.bytecode.iris;
public class Settings
{
public PerformanceSettings performance = new PerformanceSettings();
public GeneratorSettings gen = new GeneratorSettings();
public static class PerformanceSettings
{
public int threadCount = -1;
public int threadPriority = Thread.MAX_PRIORITY;
}
public static class GeneratorSettings
{
public boolean flatBedrock = false;
}
}

View File

@ -1,36 +1,46 @@
package ninja.bytecode.iris.atomics;
import java.lang.reflect.Field;
import java.util.concurrent.locks.ReentrantLock;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.craftbukkit.v1_12_R1.generator.CraftChunkData;
import org.bukkit.block.data.BlockData;
import org.bukkit.craftbukkit.v1_14_R1.block.data.CraftBlockData;
import org.bukkit.craftbukkit.v1_14_R1.generator.CraftChunkData;
import org.bukkit.craftbukkit.v1_14_R1.util.CraftMagicNumbers;
import org.bukkit.generator.ChunkGenerator;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import org.bukkit.material.MaterialData;
import net.minecraft.server.v1_14_R1.Blocks;
import net.minecraft.server.v1_14_R1.ChunkSection;
import net.minecraft.server.v1_14_R1.IBlockData;
public final class AtomicChunkData implements ChunkGenerator.ChunkData
{
private static final Field t;
private static final int h = 0x1000;
private static final Field[] f = new Field[16];
private final int maxHeight;
private volatile char[] s0;
private volatile char[] s1;
private volatile char[] s2;
private volatile char[] s3;
private volatile char[] s4;
private volatile char[] s5;
private volatile char[] s6;
private volatile char[] s7;
private volatile char[] s8;
private volatile char[] s9;
private volatile char[] sA;
private volatile char[] sB;
private volatile char[] sC;
private volatile char[] sD;
private volatile char[] sE;
private volatile char[] sF;
private volatile char[][] m;
private final ReentrantLock[] locks = makeLocks();
private ChunkSection s0;
private ChunkSection s1;
private ChunkSection s2;
private ChunkSection s3;
private ChunkSection s4;
private ChunkSection s5;
private ChunkSection s6;
private ChunkSection s7;
private ChunkSection s8;
private ChunkSection s9;
private ChunkSection s10;
private ChunkSection s11;
private ChunkSection s12;
private ChunkSection s13;
private ChunkSection s14;
private ChunkSection s15;
private ChunkSection[] m;
private World w;
public AtomicChunkData(World world)
@ -39,270 +49,42 @@ public final class AtomicChunkData implements ChunkGenerator.ChunkData
this.w = world;
}
@Override
public int getMaxHeight()
private ReentrantLock[] makeLocks()
{
return maxHeight;
}
ReentrantLock[] f = new ReentrantLock[16];
@SuppressWarnings("deprecation")
@Override
public void setBlock(int x, int y, int z, Material material)
{
setBlock(x, y, z, material.getId());
}
@SuppressWarnings("deprecation")
@Override
public void setBlock(int x, int y, int z, MaterialData material)
{
setBlock(x, y, z, material.getItemTypeId(), material.getData());
}
@SuppressWarnings("deprecation")
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material)
{
setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.getId());
}
@SuppressWarnings("deprecation")
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material)
{
setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.getItemTypeId(), material.getData());
}
@SuppressWarnings("deprecation")
@Override
public Material getType(int x, int y, int z)
{
return Material.getMaterial(getTypeId(x, y, z));
}
@SuppressWarnings("deprecation")
@Override
public MaterialData getTypeAndData(int x, int y, int z)
{
return getType(x, y, z).getNewData(getData(x, y, z));
}
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, int blockId)
{
setRegion(xMin, yMin, zMin, xMax, yMax, zMax, blockId, (byte) 0);
}
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, int blockId, int data)
{
throw new UnsupportedOperationException("AtomicChunkData does not support setting regions");
}
@Override
public void setBlock(int x, int y, int z, int blockId)
{
setBlock(x, y, z, blockId, (byte) 0);
}
@Override
public void setBlock(int x, int y, int z, int blockId, byte data)
{
setBlock(x, y, z, (char) (blockId << 4 | data));
}
@Override
public int getTypeId(int x, int y, int z)
{
if(x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf))
for(int i = 0; i < 16; i++)
{
return 0;
f[i] = new ReentrantLock();
}
char[] section = getChunkSection(y, false);
if(section == null)
{
return 0;
}
else
{
return section[(y & 0xf) << 8 | z << 4 | x] >> 4;
}
return f;
}
@Override
public byte getData(int x, int y, int z)
private ChunkSection ofSection(int y, boolean c)
{
if(x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf))
{
return (byte) 0;
}
char[] section = getChunkSection(y, false);
if(section == null)
{
return (byte) 0;
}
else
{
return (byte) (section[(y & 0xf) << 8 | z << 4 | x] & 0xf);
}
}
private void setBlock(int x, int y, int z, char type)
{
if(x != (x & 0xf) || y < 0 || y >= maxHeight || z != (z & 0xf))
{
return;
}
getChunkSection(y, true)[(y & 0xf) << 8 | z << 4 | x] = type;
}
private char[] getChunkSection(int y, boolean c)
{
//@done
int s = y >> 4;
if(s == 0)
try
{
if(c && s0 == null)
locks[s].lock();
ChunkSection v = (ChunkSection) f[s].get(this);
if(v == null)
{
s0 = new char[h];
v = new ChunkSection(y);
f[s].set(this, v);
}
return s0;
}
else if(s == 1)
{
if(c && s1 == null)
{
s1 = new char[h];
}
return s1;
}
else if(s == 2)
{
if(c && s2 == null)
{
s2 = new char[h];
}
return s2;
}
else if(s == 3)
{
if(c && s3 == null)
{
s3 = new char[h];
}
return s3;
}
else if(s == 4)
{
if(c && s4 == null)
{
s4 = new char[h];
}
return s4;
}
else if(s == 5)
{
if(c && s5 == null)
{
s5 = new char[h];
}
return s5;
}
else if(s == 6)
{
if(c && s6 == null)
{
s6 = new char[h];
}
return s6;
}
else if(s == 7)
{
if(c && s7 == null)
{
s7 = new char[h];
}
return s7;
}
else if(s == 8)
{
if(c && s8 == null)
{
s8 = new char[h];
}
return s8;
}
else if(s == 9)
{
if(c && s9 == null)
{
s9 = new char[h];
}
return s9;
}
else if(s == 10)
{
if(c && sA == null)
{
sA = new char[h];
}
return sA;
}
else if(s == 11)
{
if(c && sB == null)
{
sB = new char[h];
}
return sB;
}
else if(s == 12)
{
if(c && sC == null)
{
sC = new char[h];
}
return sC;
}
else if(s == 13)
{
if(c && sD == null)
{
sD = new char[h];
}
return sD;
}
else if(s == 14)
{
if(c && sE == null)
{
sE = new char[h];
}
return sE;
}
else if(s == 15)
{
if(c && sF == null)
{
sF = new char[h];
}
return sF;
locks[s].unlock();
return v;
}
else
catch(Throwable e)
{
System.out.print("CANT FIND SECTION: " + s);
e.printStackTrace();
}
return null;
//@done
}
@ -313,7 +95,7 @@ public final class AtomicChunkData implements ChunkGenerator.ChunkData
try
{
m = (char[][]) t.get(c);
m = (ChunkSection[]) t.get(c);
m[0] = s0;
m[1] = s1;
m[2] = s2;
@ -324,12 +106,12 @@ public final class AtomicChunkData implements ChunkGenerator.ChunkData
m[7] = s7;
m[8] = s8;
m[9] = s9;
m[10] = sA;
m[11] = sB;
m[12] = sC;
m[13] = sD;
m[14] = sE;
m[15] = sF;
m[10] = s10;
m[11] = s11;
m[12] = s12;
m[13] = s13;
m[14] = s14;
m[15] = s15;
}
catch(IllegalArgumentException | IllegalAccessException e)
@ -355,6 +137,103 @@ public final class AtomicChunkData implements ChunkGenerator.ChunkData
e.printStackTrace();
}
for(int i = 0; i < 16; i++)
{
try
{
Field g = AtomicChunkData.class.getDeclaredField("s" + i);
g.setAccessible(true);
f[i] = g;
}
catch(Throwable e)
{
e.printStackTrace();
}
}
t = x;
}
public int getMaxHeight()
{
return this.maxHeight;
}
public void setBlock(int x, int y, int z, Material material)
{
this.setBlock(x, y, z, material.createBlockData());
}
public void setBlock(int x, int y, int z, MaterialData material)
{
this.setBlock(x, y, z, CraftMagicNumbers.getBlock(material));
}
public void setBlock(int x, int y, int z, BlockData blockData)
{
this.setBlock(x, y, z, ((CraftBlockData) blockData).getState());
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material.createBlockData());
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, CraftMagicNumbers.getBlock(material));
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData)
{
this.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, ((CraftBlockData) blockData).getState());
}
public Material getType(int x, int y, int z)
{
return CraftMagicNumbers.getMaterial(this.getTypeId(x, y, z).getBlock());
}
public MaterialData getTypeAndData(int x, int y, int z)
{
return CraftMagicNumbers.getMaterial(this.getTypeId(x, y, z));
}
public BlockData getBlockData(int x, int y, int z)
{
return CraftBlockData.fromData(this.getTypeId(x, y, z));
}
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, IBlockData type)
{
throw new RuntimeException("Not Supported!");
}
public IBlockData getTypeId(int x, int y, int z)
{
if(x == (x & 15) && y >= 0 && y < this.maxHeight && z == (z & 15))
{
ChunkSection section = ofSection(y, false);
return section == null ? Blocks.AIR.getBlockData() : section.getType(x, y & 15, z);
}
else
{
return Blocks.AIR.getBlockData();
}
}
public byte getData(int x, int y, int z)
{
return CraftMagicNumbers.toLegacyData(this.getTypeId(x, y, z));
}
private void setBlock(int x, int y, int z, IBlockData type)
{
if(x == (x & 15) && y >= 0 && y < this.maxHeight && z == (z & 15))
{
ChunkSection section = ofSection(y, true);
section.setType(x, y & 15, z, type);
}
}
}

View File

@ -16,29 +16,30 @@ public class GenLayerBiome extends GenLayer
private CNG hfracture;
private CNG alt;
private CNG height;
private CNG ocean;
private CNG superheight;
public GenLayerBiome(World world, Random random, RNG rng)
{
super(world, random, rng);
//@builder
temperature = new CNG(rng.nextRNG(), 1, 2)
.scale(0.0018)
.fractureWith(new CNG(rng.nextRNG(), 1, 1).scale(0.06), 23);
.scale(0.0022)
.fractureWith(new CNG(rng.nextRNG(), 1, 1).scale(0.06), 32);
hfracture = new CNG(rng.nextRNG(), 1, 2)
.scale(0.0124);
humidity = new CNG(rng.nextRNG(), 1, 2)
.scale(0.0024)
.fractureWith(new CNG(rng.nextRNG(), 1, 1).scale(0.06), 12);
.fractureWith(new CNG(rng.nextRNG(), 1, 1).scale(0.06), 32);
superheight = new CNG(rng.nextRNG(), 1, 8)
.scale(0.0004)
.fractureWith(new CNG(rng.nextRNG(), 1, 1).scale(0.021), 250);
height = new CNG(rng.nextRNG(), 1, 8)
.scale(0.0017601)
.fractureWith(new CNG(rng.nextRNG(), 1, 6)
.scale(0.0574)
.fractureWith(new CNG(rng.nextRNG(), 1, 1), 30)
.scale(0.116), 3);
ocean = new CNG(rng.nextRNG(), 1, 3)
.scale(0.0004601)
.fractureWith(new CNG(rng.nextRNG(), 1, 4).scale(0.016), 499);
.scale(0.0174)
.fractureWith(new CNG(rng.nextRNG(), 1, 1)
.scale(0.0034), 31)
.scale(0.066), 58);
alt = new CNG(rng.nextRNG(), 1, 1)
.scale(0.0008)
.fractureWith(new CNG(rng.nextRNG(), 1, 1).scale(0.3), 100);
@ -57,7 +58,7 @@ public class GenLayerBiome extends GenLayer
public double getTemperature(double x, double z)
{
return M.clip(temperature.noise(x, z) - (getHeight(x, z) * 0.45), 0D, 1D);
return M.clip(temperature.noise(x, z) - (getHeight(x, z) * 0.19), 0D, 1D);
}
public double getHumidity(double x, double z)
@ -67,7 +68,7 @@ public class GenLayerBiome extends GenLayer
public double getHeight(double x, double z)
{
return M.clip(Math.pow(height.noise(x + (hfracture.noise(x, z) * 180), z + (hfracture.noise(z, x) * 180)), 3) * 2.654, 0D, 1D);
return M.clip(Math.pow(height.noise(x + (hfracture.noise(x, z) * 33), z + (hfracture.noise(z, x) * 33)), 2.31 + superheight.noise(x, z)) * 2.654, 0D, 1D);
}
@Override

View File

@ -0,0 +1,47 @@
package ninja.bytecode.iris.gen;
import java.util.Random;
import org.bukkit.World;
import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.RNG;
public class GenLayerDeepOcean extends GenLayer
{
private CNG gen;
private CNG cond;
private double deepHeight = 0.493;
public GenLayerDeepOcean(World world, Random random, RNG rng)
{
//@builder
super(world, random, rng);
gen = new CNG(rng.nextRNG(), 1D, 4)
.scale(0.023)
.fractureWith(new CNG(rng.nextRNG(), 1D, 1)
.scale(0.05), 25);
cond = new CNG(rng.nextRNG(), 1D, 4)
.scale(0.018)
.fractureWith(new CNG(rng.nextRNG(), 1D, 1)
.scale(0.025), 33);
//@done
}
@Override
public double generateLayer(double noise, double dx, double dz)
{
double deepHeight = this.deepHeight - (cond.noise(dx, dz) * 0.03);
if(noise <= deepHeight)
{
double inv = 1D / deepHeight;
double fract = ((1D - (((noise + (1D - deepHeight)) * inv) * deepHeight))) * inv;
double on = gen.noise(dx, dz) * 1.93 * fract;
return noise - on;
}
return noise;
}
}

View File

@ -1,28 +0,0 @@
package ninja.bytecode.iris.gen;
import java.util.Random;
import org.bukkit.World;
import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.RNG;
public class GenLayerDeppOcean extends GenLayer
{
private CNG gen;
public GenLayerDeppOcean(World world, Random random, RNG rng)
{
//@builder
super(world, random, rng);
gen = new CNG(rng.nextRNG(), 1D, 4)
.scale(0.012);
//@done
}
@Override
public double generateLayer(double noise, double dx, double dz)
{
double deeper = gen.noise(dx, dz);
}
}

View File

@ -1,37 +0,0 @@
package ninja.bytecode.iris.gen;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.World;
import ninja.bytecode.iris.MB;
import ninja.bytecode.shuriken.math.CNG;
import ninja.bytecode.shuriken.math.RNG;
public class GenLayerSnow extends GenLayer
{
private CNG snow;
public GenLayerSnow(World world, Random random, RNG rng)
{
super(world, random, rng);
//@builder
snow = new CNG(rng.nextRNG(), 1, 1)
.scale(0.1);
//@done
}
public MB getSnow(double dx, double dz, double snowChance)
{
int m = (int) ((snowChance * 14) * snow.noise(dx, dz));
m = m > 7 ? 7 : m;
return new MB(Material.SNOW, m);
}
@Override
public double generateLayer(double noise, double dx, double dz)
{
return noise;
}
}

View File

@ -2,72 +2,207 @@ package ninja.bytecode.iris.util;
import org.bukkit.Material;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import ninja.bytecode.iris.MB;
import ninja.bytecode.iris.gen.GenLayerBase;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.math.M;
public class RealBiome
{
public static final double a = 0;
public static final double h = 0.5;
public static final double t = 0.5;
//@builder
public static final RealBiome[] biomes = {
new RealBiome(0, 0.5, h, -1).water(), // Ocean
new RealBiome(1, 0.6, 0.4, 0.125), // Plains
new RealBiome(0, 0.5, h, -1)
.water()
.surface(Material.SAND.createBlockData())
.surface(Material.SEAGRASS.createBlockData(), 0.02),
new RealBiome(1, 0.6, 0.4, 0.125)// Plains
.surface(Material.GRASS.createBlockData(), 0.58)
.surface(Material.TALL_GRASS.createBlockData(), 0.18)
.surface(Material.CORNFLOWER.createBlockData(), 0.002)
.surface(Material.SUNFLOWER.createBlockData(), 0.002)
.surface(Material.ROSE_BUSH.createBlockData(), 0.002)
.surface(Material.DANDELION.createBlockData(), 0.002)
.surface(Material.ORANGE_TULIP.createBlockData(), 0.001)
.surface(Material.PINK_TULIP.createBlockData(), 0.001)
.surface(Material.RED_TULIP.createBlockData(), 0.001)
.surface(Material.WHITE_TULIP.createBlockData(), 0.001)
.surface(Material.OXEYE_DAISY.createBlockData(), 0.001),
new RealBiome(2, 2, 0, 0.125) // Desert
.surface(new MB(Material.SAND))
.dirt(new MB(Material.SAND), new MB(Material.SAND, 1))
.rock(new MB(Material.SANDSTONE)),
new RealBiome(3, 0.2, 0.3, 0.56), // Extreme Hills
new RealBiome(4, 0.5, 0.8, a), // Forest
new RealBiome(5, 0.25, 0.8, 0.2), // Taiga
new RealBiome(6, 0.8, 0.9, -0.2), // Swampland
.surface(Material.SAND.createBlockData())
.dirt(Material.SAND.createBlockData())
.rock(Material.SANDSTONE.createBlockData()),
new RealBiome(3, 0.2, 0.3, 0.56)
.surface(Material.GRASS.createBlockData(), 0.18), // Extreme Hills
new RealBiome(4, 0.5, 0.8, a).surface(Material.TALL_GRASS.createBlockData(), 0.48), // Forest
new RealBiome(5, 0.25, 0.8, 0.2).surface(Material.TALL_GRASS.createBlockData(), 0.18), // Taiga
new RealBiome(6, 0.8, 0.9, -0.2).surface(Material.TALL_GRASS.createBlockData(), 0.38), // Swampland
new RealBiome(7, t, h, -0.5).river(), // River
new RealBiome(8, 2, 0, a).dimensional(), // Hell
new RealBiome(9, t, h, a).dimensional(), // The End
new RealBiome(10, 0, 0.5, -1).water(), // Frozen Ocean
new RealBiome(10, 0, 0.5, -1)
.water()
.surface(Material.SAND.createBlockData()),
new RealBiome(11, 0, 0.5, -0.5).river(), // Frozen River
new RealBiome(12, 0, 0.5, 0.125).surface(new MB(Material.SNOW_BLOCK)), // Ice Plains
new RealBiome(12, 0, 0.5, 0.125)
.surface(Material.SNOW_BLOCK.createBlockData()), // Ice Plains
new RealBiome(13, 0, 0.5, 0.765) // Ice Mountains
.surface(new MB(Material.SNOW_BLOCK))
.dirt(new MB(Material.PACKED_ICE)),
.surface(Material.SNOW_BLOCK.createBlockData())
.dirt(Material.PACKED_ICE.createBlockData()),
new RealBiome(14, 0.9, 1, 0.2).modifier() // Mushroom Island
.surface(new MB(Material.MYCEL)),
.surface(Material.MYCELIUM.createBlockData()),
new RealBiome(15, 0, 1, 0).modifier() // Mushroom Island Shore
.surface(new MB(Material.MYCEL)),
new RealBiome(16, 0.8, 0.4, 0).beach(), // Beaches
.surface(Material.MYCELIUM.createBlockData()),
new RealBiome(16, 0.8, 0.4, 0).beach()
.surface(Material.SAND.createBlockData()), // Beaches
new RealBiome(17, 2, 0, 0.75) // Desert Hills
.surface(new MB(Material.SAND))
.dirt(new MB(Material.SAND), new MB(Material.SAND, 1))
.rock(new MB(Material.SANDSTONE)),
new RealBiome(18, 0.6, 0.8, 0.75), // Forest Hills
new RealBiome(19, 0.25, 0.8, 0.75), // Taiga Hills
new RealBiome(20, 0.2, 0.3, 0.8), // Extreme Hills Edge
new RealBiome(21, 0.95, 0.9, a), // Jungle
new RealBiome(22, 0.95, 0.9, 0.75), // Jungle
new RealBiome(23, 0.9, 0.9, 0.15), // Jungle Edge
new RealBiome(24, t, h, -1.8).water(), // Deep Ocean
.surface(Material.SAND.createBlockData())
.dirt(Material.SAND.createBlockData())
.rock(Material.SANDSTONE.createBlockData()),
new RealBiome(18, 0.6, 0.8, 0.75).surface(Material.GRASS.createBlockData(), 0.38).surface(Material.TALL_GRASS.createBlockData(), 0.08), // Forest Hills
new RealBiome(19, 0.25, 0.8, 0.75).surface(Material.GRASS.createBlockData(), 0.28).surface(Material.TALL_GRASS.createBlockData(), 0.08), // Taiga Hills
new RealBiome(20, 0.2, 0.3, 0.8).surface(Material.GRASS.createBlockData(), 0.18).surface(Material.TALL_GRASS.createBlockData(), 0.08), // Extreme Hills Edge
new RealBiome(21, 0.95, 0.9, a).surface(Material.GRASS.createBlockData(), 0.68).surface(Material.TALL_GRASS.createBlockData(), 0.22), // Jungle
new RealBiome(22, 0.95, 0.9, 0.75).surface(Material.GRASS.createBlockData(), 0.72).surface(Material.TALL_GRASS.createBlockData(), 0.28), // Jungle
new RealBiome(23, 0.9, 0.9, 0.15).surface(Material.GRASS.createBlockData(), 0.62).surface(Material.TALL_GRASS.createBlockData(), 0.22), // Jungle Edge
new RealBiome(24, t, h, -1.8)
.water()
.surface(Material.SAND.createBlockData()), // Deep Ocean
new RealBiome(25, 0.2, 0.3, 0.1).beach(), // Stone Beach
new RealBiome(26, 0.2, 0.3, 0).beach(), // Cold Beach
new RealBiome(27, 0.5, 0.5, a), // Birch Forest
new RealBiome(28, 0.4, 0.4, 0.25), // Birch Forest Hills
new RealBiome(29, 0.7, 0.8, a), // Roofed Forest
new RealBiome(30, -0.5, 0.4, 0.2), // Cold Taiga
new RealBiome(31, -0.5, 0.4, 0.75), // Cold Taiga Hills
new RealBiome(32, 0.4, 0.8, 0.2), // Redwood Taiga
new RealBiome(33, 0.3, 0.8, 0.75), // Redwood Taiga Hills
new RealBiome(34, 0.2, 0.3, 1), // Extra Hills with Trees
new RealBiome(35, 1.2, 0, 0.125), // Savanna
new RealBiome(36, 1, 0, 0.28), // Savanna Plateau
new RealBiome(27, 0.5, 0.5, a).surface(Material.GRASS.createBlockData(), 0.38).surface(Material.GRASS.createBlockData(), 0.18), // Birch Forest
new RealBiome(28, 0.4, 0.4, 0.25).surface(Material.GRASS.createBlockData(), 0.38).surface(Material.GRASS.createBlockData(), 0.18), // Birch Forest Hills
new RealBiome(29, 0.7, 0.8, a).surface(Material.GRASS.createBlockData(), 0.68).surface(Material.GRASS.createBlockData(), 0.28), // Roofed Forest
new RealBiome(30, -0.5, 0.4, 0.2).surface(Material.GRASS.createBlockData(), 0.28).surface(Material.GRASS.createBlockData(), 0.18), // Cold Taiga
new RealBiome(31, -0.5, 0.4, 0.75).surface(Material.GRASS.createBlockData(), 0.28).surface(Material.GRASS.createBlockData(), 0.18), // Cold Taiga Hills
new RealBiome(32, 0.4, 0.8, 0.2).surface(Material.GRASS.createBlockData(), 0.38).surface(Material.GRASS.createBlockData(), 0.18), // Redwood Taiga
new RealBiome(33, 0.3, 0.8, 0.75).surface(Material.GRASS.createBlockData(), 0.38).surface(Material.GRASS.createBlockData(), 0.18), // Redwood Taiga Hills
new RealBiome(34, 0.2, 0.3, 1).surface(Material.GRASS.createBlockData(), 0.28).surface(Material.GRASS.createBlockData(), 0.18), // Extra Hills with Trees
new RealBiome(35, 1.2, 0, 0.125).surface(Material.GRASS.createBlockData(), 0.28).surface(Material.GRASS.createBlockData(), 0.18), // Savanna
new RealBiome(36, 1, 0, 0.28).surface(Material.GRASS.createBlockData(), 0.18).surface(Material.GRASS.createBlockData(), 0.18), // Savanna Plateau
new RealBiome(37, 2, 0, a), // Mesa
new RealBiome(38, 2, 0, 0.28), // Mesa Plateau F
new RealBiome(39, 2, 0, 0.31), // Mesa Plateau
new RealBiome(Biome.WARM_OCEAN.ordinal(), 0.6, h, -1)
.water()
.surface(Material.SAND.createBlockData(), Material.CLAY.createBlockData(), Material.GRAVEL.createBlockData())
.surface(Material.SEAGRASS.createBlockData(), 0.64)
.surface(Material.TALL_SEAGRASS.createBlockData(), 0.44),
new RealBiome(Biome.LUKEWARM_OCEAN.ordinal(), 0.7, h, -1)
.water()
.surface(Material.SAND.createBlockData(), Material.CLAY.createBlockData(), Material.GRAVEL.createBlockData())
.surface(Material.SEAGRASS.createBlockData(), 0.44)
.surface(Material.TALL_SEAGRASS.createBlockData(), 0.24),
new RealBiome(Biome.COLD_OCEAN.ordinal(), 0.4, h, -1)
.water()
.surface(Material.SAND.createBlockData(), Material.CLAY.createBlockData(), Material.GRAVEL.createBlockData()),
new RealBiome(Biome.DEEP_WARM_OCEAN.ordinal(), 0.6, h, -1)
.water()
.surface(Material.BRAIN_CORAL_BLOCK.createBlockData(), Material.FIRE_CORAL_BLOCK.createBlockData(), Material.HORN_CORAL_BLOCK.createBlockData(), Material.MAGMA_BLOCK.createBlockData(), Material.TUBE_CORAL_BLOCK.createBlockData(), Material.BRAIN_CORAL_BLOCK.createBlockData(), Material.BLUE_CONCRETE_POWDER.createBlockData(), Material.CYAN_CONCRETE_POWDER.createBlockData(), Material.LIGHT_BLUE_CONCRETE_POWDER.createBlockData(), Material.SAND.createBlockData())
.surface(Material.SAND.createBlockData())
.surface(Material.SEAGRASS.createBlockData(), 0.39)
.surface(Material.TALL_SEAGRASS.createBlockData(), 0.52)
.surface(Material.BRAIN_CORAL.createBlockData(), 0.09)
.surface(Material.BUBBLE_CORAL.createBlockData(), 0.09)
.surface(Material.FIRE_CORAL.createBlockData(), 0.09)
.surface(Material.HORN_CORAL.createBlockData(), 0.09)
.surface(Material.TUBE_CORAL.createBlockData(), 0.09)
.surface(Material.BRAIN_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.BUBBLE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.FIRE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.HORN_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.SEA_LANTERN.createBlockData(), 0.006)
.surface(Material.TUBE_CORAL_FAN.createBlockData(), 0.05),
new RealBiome(Biome.DEEP_LUKEWARM_OCEAN.ordinal(), 0.7, h, -1)
.water()
.surface(Material.BLUE_CONCRETE_POWDER.createBlockData(), Material.BROWN_CONCRETE_POWDER.createBlockData(), Material.CYAN_CONCRETE_POWDER.createBlockData(), Material.LIGHT_BLUE_CONCRETE_POWDER.createBlockData(), Material.SAND.createBlockData())
.surface(Material.SAND.createBlockData())
.surface(Material.SEAGRASS.createBlockData(), 0.24)
.surface(Material.TALL_SEAGRASS.createBlockData(), 0.55)
.surface(Material.BRAIN_CORAL.createBlockData(), 0.09)
.surface(Material.BUBBLE_CORAL.createBlockData(), 0.09)
.surface(Material.FIRE_CORAL.createBlockData(), 0.09)
.surface(Material.HORN_CORAL.createBlockData(), 0.09)
.surface(Material.TUBE_CORAL.createBlockData(), 0.09)
.surface(Material.BRAIN_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.BUBBLE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.FIRE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.HORN_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.SEA_LANTERN.createBlockData(), 0.009)
.surface(Material.TUBE_CORAL_FAN.createBlockData(), 0.05),
new RealBiome(Biome.DEEP_COLD_OCEAN.ordinal(), 0.4, h, -1)
.water()
.surface(Material.SAND.createBlockData())
.surface(Material.DEAD_BRAIN_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_BUBBLE_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_FIRE_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_HORN_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_TUBE_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_BRAIN_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.DEAD_BUBBLE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.DEAD_FIRE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.DEAD_HORN_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.SEAGRASS.createBlockData(), 0.09)
.surface(Material.TALL_SEAGRASS.createBlockData(), 0.02),
new RealBiome(Biome.DEEP_FROZEN_OCEAN.ordinal(), 0, h, -1)
.surface(Material.SAND.createBlockData())
.water()
.surface(Material.DEAD_BRAIN_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_BUBBLE_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_FIRE_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_HORN_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_TUBE_CORAL.createBlockData(), 0.09)
.surface(Material.DEAD_BRAIN_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.DEAD_BUBBLE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.DEAD_FIRE_CORAL_FAN.createBlockData(), 0.05)
.surface(Material.DEAD_HORN_CORAL_FAN.createBlockData(), 0.05),
new RealBiome(Biome.SUNFLOWER_PLAINS.ordinal(), 0.4, h, 0.015),
new RealBiome(Biome.DESERT_LAKES.ordinal(), 1.45, 0.1, 0.015).water(),
new RealBiome(Biome.GRAVELLY_MOUNTAINS.ordinal(), 0.5, 0.2, 0.75),
new RealBiome(Biome.FLOWER_FOREST.ordinal(), 0.55, 0.8, a)
.surface(Material.GRASS.createBlockData(), 0.45)
.surface(Material.TALL_GRASS.createBlockData(), 0.15)
.surface(Material.CORNFLOWER.createBlockData(), 0.009)
.surface(Material.SUNFLOWER.createBlockData(), 0.009)
.surface(Material.ROSE_BUSH.createBlockData(), 0.009)
.surface(Material.DANDELION.createBlockData(), 0.009)
.surface(Material.ORANGE_TULIP.createBlockData(), 0.007)
.surface(Material.PINK_TULIP.createBlockData(), 0.007)
.surface(Material.RED_TULIP.createBlockData(), 0.007)
.surface(Material.WHITE_TULIP.createBlockData(), 0.007)
.surface(Material.OXEYE_DAISY.createBlockData(), 0.007),
new RealBiome(Biome.TAIGA_MOUNTAINS.ordinal(), 0.25, 0.8, 0.8)
.surface(Material.GRASS.createBlockData(), 0.12),
new RealBiome(Biome.SWAMP_HILLS.ordinal(), 0.6, 1, 0.25)
.surface(Material.GRASS.createBlockData(), 0.18),
new RealBiome(Biome.BAMBOO_JUNGLE.ordinal(), 0.8, 0.77, 0.125)
.surface(Material.GRASS.createBlockData(), 0.78)
.surface(Material.TALL_GRASS.createBlockData(), 0.28),
new RealBiome(Biome.BAMBOO_JUNGLE_HILLS.ordinal(), 0.75, 0.7, 0.225)
.surface(Material.GRASS.createBlockData(), 0.68)
.surface(Material.TALL_GRASS.createBlockData(), 0.28),
};
//@done
public static RealBiome of(Biome e)
{
for(RealBiome i : biomes)
{
if(i.getBiome().ordinal() == e.ordinal())
{
return i;
}
}
return biomes[1];
}
private int biomeId;
private double temperature;
private double humidity;
@ -77,13 +212,14 @@ public class RealBiome
private boolean water;
private boolean beach;
private boolean dimensional;
private GList<MB> surface;
private GList<MB> dirt;
private GList<MB> rock;
private GList<BlockData> surface;
private GList<BlockData> dirt;
private GList<BlockData> rock;
private GMap<BlockData, Double> surfaceDecorator;
private boolean defs;
private boolean defd;
private boolean defr;
public RealBiome(int biomeId, double temperature, double humidity, double height)
{
defs = true;
@ -96,26 +232,40 @@ public class RealBiome
surface = new GList<>();
dirt = new GList<>();
rock = new GList<>();
surface.add(new MB(Material.GRASS));
dirt.add(new MB(Material.DIRT), new MB(Material.DIRT, 1));
rock.add(new MB(Material.STONE), new MB(Material.STONE, 5), new MB(Material.COBBLESTONE));
surfaceDecorator = new GMap<>();
surface.add(Material.GRASS_BLOCK.createBlockData());
dirt.add(Material.DIRT.createBlockData(), Material.COARSE_DIRT.createBlockData());
rock.add(Material.STONE.createBlockData(), Material.ANDESITE.createBlockData(), Material.COBBLESTONE.createBlockData());
temperature = temperature > 1 ? 1 : temperature < 0 ? 0 : temperature;
humidity = humidity > 1 ? 1 : humidity < 0 ? 0 : humidity;
height = height > 1 ? 1 : height < 0 ? 0 : height;
}
public BlockData getSurfaceDecoration()
{
for(BlockData i : surfaceDecorator.k())
{
if(M.r(surfaceDecorator.get(i)))
{
return i;
}
}
return null;
}
public static RealBiome match(double temperature, double humidity, double height, double d)
{
GList<RealBiome> b = new GList<>();
double distance = Double.MAX_VALUE;
for(RealBiome i : biomes)
{
if(i.modifier)
{
continue;
}
double dist = i.getDistance(temperature, humidity, height);
if(dist < distance)
{
@ -123,21 +273,27 @@ public class RealBiome
b.add(i);
}
}
return b.get((int) (d * Math.min(b.size(), 3)));
}
public RealBiome surface(BlockData data, double percentChance)
{
surfaceDecorator.put(data, percentChance);
return this;
}
public double getDistance(double temperature, double humidity, double height)
{
return Math.abs((temperature - this.temperature) * 3.5) + Math.abs((humidity - this.humidity) * 2.5) + Math.abs((height - this.height) * 4.8);
}
public Biome getBiome()
{
return Biome.values()[biomeId];
}
public RealBiome surface(MB... mb)
public RealBiome surface(BlockData... mb)
{
if(defs)
{
@ -148,71 +304,71 @@ public class RealBiome
return this;
}
public RealBiome dirt(MB... mb)
public RealBiome dirt(BlockData... mb)
{
if(defd)
{
defd = false;
dirt.clear();
}
this.dirt.add(mb);
return this;
}
public RealBiome rock(MB... mb)
public RealBiome rock(BlockData... mb)
{
if(defr)
{
defr = false;
rock.clear();
}
this.rock.add(mb);
return this;
}
public RealBiome modifier()
{
modifier = true;
return this;
}
public RealBiome river()
{
river = true;
return this.modifier();
}
public RealBiome water()
{
water = true;
return this.modifier();
}
public RealBiome beach()
{
beach = true;
return this.modifier();
}
public RealBiome dimensional()
{
dimensional = true;
return this.modifier();
}
public MB surface(int x, int y, int z, GenLayerBase glBase)
public BlockData surface(int x, int y, int z, GenLayerBase glBase)
{
return surface.get(glBase.scatterInt(x, y, z, surface.size()));
}
public MB dirt(int x, int y, int z, GenLayerBase glBase)
public BlockData dirt(int x, int y, int z, GenLayerBase glBase)
{
return dirt.get(glBase.scatterInt(x, y, z, dirt.size()));
}
public MB rock(int x, int y, int z, GenLayerBase glBase)
public BlockData rock(int x, int y, int z, GenLayerBase glBase)
{
return rock.get(glBase.scatterInt(x, y, z, rock.size()));
}
@ -282,17 +438,17 @@ public class RealBiome
return dimensional;
}
public GList<MB> getSurface()
public GList<BlockData> getSurface()
{
return surface;
}
public GList<MB> getDirt()
public GList<BlockData> getDirt()
{
return dirt;
}
public GList<MB> getRock()
public GList<BlockData> getRock()
{
return rock;
}

View File

@ -1,3 +1,4 @@
name: ${project.name}
version: ${project.version}
main: ninja.bytecode.iris.Iris
main: ninja.bytecode.iris.Iris
api-version: 1.13