diff --git a/dependency-reduced-pom.xml b/dependency-reduced-pom.xml
index 30da0e37a..19169a9be 100644
--- a/dependency-reduced-pom.xml
+++ b/dependency-reduced-pom.xml
@@ -77,7 +77,7 @@
org.spigotmc
spigot-api
- 1.14.4-R0.1-SNAPSHOT
+ 1.12.2-R0.1-SNAPSHOT
provided
@@ -85,25 +85,29 @@
commons-lang
- guava
- com.google.guava
+ json-simple
+ com.googlecode.json-simple
- bungeecord-chat
- net.md-5
+ guava
+ com.google.guava
snakeyaml
org.yaml
+
+ bungeecord-chat
+ net.md-5
+
cb
- craftbukkit-1.14.4
+ craftbukkit-1.12.2
1
system
- ${project.basedir}/lib/craftbukkit-1.14.4.jar
+ ${project.basedir}/lib/craftbukkit-1.12.2.jar
diff --git a/pom.xml b/pom.xml
index 820b28278..d4470ef85 100644
--- a/pom.xml
+++ b/pom.xml
@@ -90,15 +90,15 @@
org.spigotmc
spigot-api
- 1.14.4-R0.1-SNAPSHOT
+ 1.12.2-R0.1-SNAPSHOT
provided
- craftbukkit-1.14.4
+ craftbukkit-1.12.2
cb
1
system
- ${project.basedir}/lib/craftbukkit-1.14.4.jar
+ ${project.basedir}/lib/craftbukkit-1.12.2.jar
\ No newline at end of file
diff --git a/src/main/java/ninja/bytecode/iris/Iris.java b/src/main/java/ninja/bytecode/iris/Iris.java
index f2cc0ad71..4201e6161 100644
--- a/src/main/java/ninja/bytecode/iris/Iris.java
+++ b/src/main/java/ninja/bytecode/iris/Iris.java
@@ -20,7 +20,6 @@ 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;
@@ -31,7 +30,6 @@ public class Iris extends JavaPlugin implements Listener
settings = new Settings();
gen = new IrisGenerator();
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
@@ -54,7 +52,6 @@ public class Iris extends JavaPlugin implements Listener
public void onDisable()
{
noisePool.close();
- blockPool.close();
}
@Override
diff --git a/src/main/java/ninja/bytecode/iris/IrisGenerator.java b/src/main/java/ninja/bytecode/iris/IrisGenerator.java
index 0936c8238..e3ba7be12 100644
--- a/src/main/java/ninja/bytecode/iris/IrisGenerator.java
+++ b/src/main/java/ninja/bytecode/iris/IrisGenerator.java
@@ -6,9 +6,6 @@ import org.bukkit.Chunk;
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 org.bukkit.util.Vector;
import ninja.bytecode.iris.gen.GenLayerBase;
@@ -21,10 +18,10 @@ 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 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 genLayers;
private GenLayerBiome glBiome;
private GenLayerBase glBase;
@@ -75,75 +72,21 @@ public class IrisGenerator extends ParallelChunkGenerator
double temp = glBiome.getTemperature(wx, wz, height);
RealBiome b = glBiome.getBiome(wx, wz, temp, height);
boolean underwater = height < waterLevel;
-
+
// Change biome to ocean / deep ocean if underwater height
if(underwater)
{
- if(waterLevel - height > 20)
- {
- if(temp <= 0.05)
- {
- 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);
- }
- }
+ b = RealBiome.biomes[Biome.OCEAN.ordinal()];
}
if(height > 122 && height < 128 + (temp * 1.5) + (glBase.scatter(wx, wx * wz, wz) * 3.35))
{
- b = RealBiome.of(Biome.BEACH);
+ b = RealBiome.biomes[Biome.BEACHES.ordinal()];
}
for(int i = 0; i < Math.max(height, waterLevel); i++)
{
- BlockData mb = AIR;
+ MB mb = AIR;
// Bedrockify
if(i == 0 || (!Iris.settings.gen.flatBedrock && ((i == 1 && glBase.scatterChance(wx, i, wz, 0.45)))))
@@ -175,48 +118,31 @@ public class IrisGenerator extends ParallelChunkGenerator
mb = b.rock(wx, i, wz, glBase);
}
- if(mb.getMaterial().equals(Material.AIR))
+ if(mb.equals(AIR))
{
continue;
}
- setBlock(x, i, z, mb);
+ setBlock(x, i, z, mb.material, mb.data);
}
- BlockData v = b.getSurfaceDecoration();
+ MB 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);
- }
+ setBlock(x, height, z, v.material, v.data);
}
return b.getBiome();
}
- private void scheduleUpdate(int x, int y, int z)
- {
- updates.add(new Vector(x, y, z));
- }
public int pick(int max, double noise)
{
return (int) (noise * max);
}
- public BlockData pick(BlockData[] array, double noise)
+ public MB pick(MB[] array, double noise)
{
return array[pick(array.length, noise)];
}
diff --git a/src/main/java/ninja/bytecode/iris/MB.java b/src/main/java/ninja/bytecode/iris/MB.java
new file mode 100644
index 000000000..148cc449e
--- /dev/null
+++ b/src/main/java/ninja/bytecode/iris/MB.java
@@ -0,0 +1,20 @@
+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);
+ }
+}
diff --git a/src/main/java/ninja/bytecode/iris/ParallelChunkGenerator.java b/src/main/java/ninja/bytecode/iris/ParallelChunkGenerator.java
index ed5e69bbd..d201f339f 100644
--- a/src/main/java/ninja/bytecode/iris/ParallelChunkGenerator.java
+++ b/src/main/java/ninja/bytecode/iris/ParallelChunkGenerator.java
@@ -5,13 +5,11 @@ 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;
@@ -25,7 +23,6 @@ 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);
@@ -44,7 +41,6 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
}
tg = Iris.noisePool.startWork();
- tb = Iris.blockPool.startWork();
for(i = 0; i < 16; i++)
{
@@ -57,16 +53,12 @@ public abstract class ParallelChunkGenerator extends ChunkGenerator
int b = wz;
int c = i;
int d = j;
- tg.queue(() ->
- {
- biome.setBiome(c, d, genColumn(a, b, c, d));
- });
+ tg.queue(() -> biome.setBiome(c, d, genColumn(a, b, c, d)));
}
}
TaskResult r = tg.execute();
-
- rs.put(r.timeElapsed + tb.execute().timeElapsed);
+ rs.put(r.timeElapsed);
Shuriken.profiler.stop("chunkgen-" + world.getName());
if(cl.flip())
@@ -77,7 +69,6 @@ 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++)
@@ -90,27 +81,29 @@ 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);
- protected void queueSets(NastyRunnable r)
+ @SuppressWarnings("deprecation")
+ protected void setBlock(int x, int y, int z, Material b)
{
- tb.queue(r);
+ setBlock(x, y, z, b.getId(), (byte) 0);
}
- protected void setBlock(int x, int y, int z, BlockData b)
+ @SuppressWarnings("deprecation")
+ protected void setBlock(int x, int y, int z, Material b, byte d)
{
- if(b.getMaterial().equals(Material.AIR))
- {
- return;
- }
+ setBlock(x, y, z, b.getId(), d);
+ }
- tb.queue(() -> data.setBlock(x, y, z, b));
+ 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)
+ {
+ data.setBlock(x, y, z, b, d);
}
}
\ No newline at end of file
diff --git a/src/main/java/ninja/bytecode/iris/atomics/AtomicChunkData.java b/src/main/java/ninja/bytecode/iris/atomics/AtomicChunkData.java
index 0d1f3625c..3626df46d 100644
--- a/src/main/java/ninja/bytecode/iris/atomics/AtomicChunkData.java
+++ b/src/main/java/ninja/bytecode/iris/atomics/AtomicChunkData.java
@@ -5,79 +5,213 @@ import java.util.concurrent.locks.ReentrantLock;
import org.bukkit.Material;
import org.bukkit.World;
-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.craftbukkit.v1_12_R1.generator.CraftChunkData;
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 Field[] locks;
+ private static final Field[] sections;
private static final int h = 0x1000;
- private static final Field[] f = new Field[16];
private final int maxHeight;
- 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 static ReentrantLock lock0;
+ private static ReentrantLock lock1;
+ private static ReentrantLock lock2;
+ private static ReentrantLock lock3;
+ private static ReentrantLock lock4;
+ private static ReentrantLock lock5;
+ private static ReentrantLock lock6;
+ private static ReentrantLock lock7;
+ private static ReentrantLock lock8;
+ private static ReentrantLock lock9;
+ private static ReentrantLock lock10;
+ private static ReentrantLock lock11;
+ private static ReentrantLock lock12;
+ private static ReentrantLock lock13;
+ private static ReentrantLock lock14;
+ private static ReentrantLock lock15;
+ private char[] s0;
+ private char[] s1;
+ private char[] s2;
+ private char[] s3;
+ private char[] s4;
+ private char[] s5;
+ private char[] s6;
+ private char[] s7;
+ private char[] s8;
+ private char[] s9;
+ private char[] s10;
+ private char[] s11;
+ private char[] s12;
+ private char[] s13;
+ private char[] s14;
+ private char[] s15;
+ private char[][] m;
private World w;
public AtomicChunkData(World world)
{
this.maxHeight = world.getMaxHeight();
this.w = world;
+
}
- private ReentrantLock[] makeLocks()
+ @Override
+ public int getMaxHeight()
{
- ReentrantLock[] f = new ReentrantLock[16];
+ return maxHeight;
+ }
- for(int i = 0; i < 16; i++)
+ @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))
{
- f[i] = new ReentrantLock();
+ return 0;
}
- return f;
+ char[] section = getChunkSection(y, false);
+
+ if(section == null)
+ {
+ return 0;
+ }
+
+ else
+ {
+ return section[(y & 0xf) << 8 | z << 4 | x] >> 4;
+ }
}
- private ChunkSection ofSection(int y, boolean c)
+ @Override
+ public byte getData(int x, int y, int z)
{
- int s = y >> 4;
+ 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;
+ }
+
+ ReentrantLock l = null;
+
try
{
- locks[s].lock();
- ChunkSection v = (ChunkSection) f[s].get(this);
+ l = (ReentrantLock) locks[y >> 4].get(null);
+ }
- if(v == null)
+ catch(IllegalArgumentException | IllegalAccessException e)
+ {
+ e.printStackTrace();
+ }
+
+ l.lock();
+ getChunkSection(y, true)[(y & 0xf) << 8 | z << 4 | x] = type;
+ l.unlock();
+ }
+
+ private char[] getChunkSection(int y, boolean c)
+ {
+ try
+ {
+ int s = y >> 4;
+ Field sf = sections[s];
+ char[] section = (char[]) sf.get(this);
+
+ if(section == null && c)
{
- v = new ChunkSection(y);
- f[s].set(this, v);
+ sf.set(this, new char[h]);
+ section = (char[]) sf.get(this);
}
- locks[s].unlock();
- return v;
+ return section;
}
catch(Throwable e)
@@ -86,7 +220,6 @@ public final class AtomicChunkData implements ChunkGenerator.ChunkData
}
return null;
- //@done
}
public ChunkData toChunkData()
@@ -95,7 +228,7 @@ public final class AtomicChunkData implements ChunkGenerator.ChunkData
try
{
- m = (ChunkSection[]) t.get(c);
+ m = (char[][]) t.get(c);
m[0] = s0;
m[1] = s1;
m[2] = s2;
@@ -124,6 +257,40 @@ public final class AtomicChunkData implements ChunkGenerator.ChunkData
static
{
+ Field[] l = new Field[16];
+ Field[] s = new Field[16];
+
+ for(int i = 0; i < 16; i++)
+ {
+ try
+ {
+ l[i] = AtomicChunkData.class.getDeclaredField("lock" + i);
+ s[i] = AtomicChunkData.class.getDeclaredField("s" + i);
+
+ }
+
+ catch(Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+
+ locks = l;
+ sections = s;
+
+ for(int i = 0; i < 16; i++)
+ {
+ try
+ {
+ locks[i].set(null, new ReentrantLock());
+ }
+
+ catch(Throwable e)
+ {
+ e.printStackTrace();
+ }
+ }
+
Field x = null;
try
@@ -137,103 +304,6 @@ 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);
- }
- }
}
\ No newline at end of file
diff --git a/src/main/java/ninja/bytecode/iris/util/RealBiome.java b/src/main/java/ninja/bytecode/iris/util/RealBiome.java
index be8995a26..1561ba986 100644
--- a/src/main/java/ninja/bytecode/iris/util/RealBiome.java
+++ b/src/main/java/ninja/bytecode/iris/util/RealBiome.java
@@ -2,209 +2,72 @@ 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()
- .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(0, 0.5, h, -1).water(), // Ocean
+ new RealBiome(1, 0.6, 0.4, 0.125), // Plains
new RealBiome(2, 2, 0, 0.125) // Desert
- .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
+ .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
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()
- .surface(Material.SAND.createBlockData()),
+ new RealBiome(10, 0, 0.5, -1).water(), // Frozen Ocean
new RealBiome(11, 0, 0.5, -0.5).river(), // Frozen River
- new RealBiome(12, 0, 0.5, 0.125)
- .surface(Material.SNOW_BLOCK.createBlockData()), // Ice Plains
+ new RealBiome(12, 0, 0.5, 0.125).surface(new MB(Material.SNOW_BLOCK)), // Ice Plains
new RealBiome(13, 0, 0.5, 0.765) // Ice Mountains
- .surface(Material.SNOW_BLOCK.createBlockData())
- .dirt(Material.PACKED_ICE.createBlockData()),
+ .surface(new MB(Material.SNOW_BLOCK))
+ .dirt(new MB(Material.PACKED_ICE)),
new RealBiome(14, 0.9, 1, 0.2).modifier() // Mushroom Island
- .surface(Material.MYCELIUM.createBlockData()),
+ .surface(new MB(Material.MYCEL)),
new RealBiome(15, 0, 1, 0).modifier() // Mushroom Island Shore
- .surface(Material.MYCELIUM.createBlockData()),
- new RealBiome(16, 0.8, 0.4, 0).beach()
- .surface(Material.SAND.createBlockData()), // Beaches
+ .surface(new MB(Material.MYCEL)),
+ new RealBiome(16, 0.8, 0.4, 0).beach(), // Beaches
new RealBiome(17, 2, 0, 0.75) // Desert Hills
- .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
+ .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
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).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(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(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.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.SEAGRASS.createBlockData(), 0.39)
- .surface(Material.TALL_SEAGRASS.createBlockData(), 0.52)
- .surface(Material.MAGMA_BLOCK.createBlockData(), 0.003)
- .surface(Material.SEA_LANTERN.createBlockData(), 0.003)
- .surface(Material.SOUL_SAND.createBlockData(), 0.003)
- .surface(Material.BRAIN_CORAL.createBlockData(), 0.09)
- .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.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;
@@ -214,14 +77,13 @@ public class RealBiome
private boolean water;
private boolean beach;
private boolean dimensional;
- private GList surface;
- private GList dirt;
- private GList rock;
- private GMap surfaceDecorator;
+ private GList surface;
+ private GList dirt;
+ private GList rock;
private boolean defs;
private boolean defd;
private boolean defr;
-
+
public RealBiome(int biomeId, double temperature, double humidity, double height)
{
defs = true;
@@ -234,40 +96,26 @@ public class RealBiome
surface = new GList<>();
dirt = new GList<>();
rock = new GList<>();
- 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());
+ 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));
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 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)
{
@@ -275,27 +123,21 @@ 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(BlockData... mb)
+
+ public RealBiome surface(MB... mb)
{
if(defs)
{
@@ -306,71 +148,71 @@ public class RealBiome
return this;
}
- public RealBiome dirt(BlockData... mb)
+ public RealBiome dirt(MB... mb)
{
if(defd)
{
defd = false;
dirt.clear();
}
-
+
this.dirt.add(mb);
return this;
}
-
- public RealBiome rock(BlockData... mb)
+
+ public RealBiome rock(MB... 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 BlockData surface(int x, int y, int z, GenLayerBase glBase)
+ public MB surface(int x, int y, int z, GenLayerBase glBase)
{
return surface.get(glBase.scatterInt(x, y, z, surface.size()));
}
-
- public BlockData dirt(int x, int y, int z, GenLayerBase glBase)
+
+ public MB dirt(int x, int y, int z, GenLayerBase glBase)
{
return dirt.get(glBase.scatterInt(x, y, z, dirt.size()));
}
-
- public BlockData rock(int x, int y, int z, GenLayerBase glBase)
+
+ public MB rock(int x, int y, int z, GenLayerBase glBase)
{
return rock.get(glBase.scatterInt(x, y, z, rock.size()));
}
@@ -440,17 +282,17 @@ public class RealBiome
return dimensional;
}
- public GList getSurface()
+ public GList getSurface()
{
return surface;
}
- public GList getDirt()
+ public GList getDirt()
{
return dirt;
}
- public GList getRock()
+ public GList getRock()
{
return rock;
}
@@ -469,4 +311,10 @@ public class RealBiome
{
return defr;
}
-}
+
+ public MB getSurfaceDecoration()
+ {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
\ No newline at end of file
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 348fd0087..9c9773c6f 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -1,4 +1,3 @@
name: ${project.name}
version: ${project.version}
-main: ninja.bytecode.iris.Iris
-api-version: 1.13
\ No newline at end of file
+main: ninja.bytecode.iris.Iris
\ No newline at end of file