mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-08 08:46:21 +00:00
Schematic fixes & timings
This commit is contained in:
@@ -13,12 +13,6 @@ import ninja.bytecode.iris.generator.layer.GenLayerBase;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerBiome;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerCaves;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerLayeredNoise;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerOreCoal;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerOreDiamond;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerOreEmerald;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerOreGold;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerOreIron;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerOreLapis;
|
||||
import ninja.bytecode.iris.generator.layer.GenLayerRidge;
|
||||
import ninja.bytecode.iris.generator.populator.ObjectPopulator;
|
||||
import ninja.bytecode.iris.schematic.SchematicGroup;
|
||||
@@ -64,12 +58,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
private GenLayerRidge glRidge;
|
||||
private GenLayerBiome glBiome;
|
||||
private GenLayerCaves glCaves;
|
||||
private GenLayerOreIron glOreIron;
|
||||
private GenLayerOreCoal glOreCoal;
|
||||
private GenLayerOreLapis glOreLapis;
|
||||
private GenLayerOreGold glOreGold;
|
||||
private GenLayerOreEmerald glOreEmerald;
|
||||
private GenLayerOreDiamond glOreDiamond;
|
||||
private RNG rTerrain;
|
||||
private IrisDimension dim;
|
||||
private World world;
|
||||
@@ -121,12 +109,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
glRidge = new GenLayerRidge(this, world, random, rTerrain.nextParallelRNG(3));
|
||||
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes());
|
||||
glCaves = new GenLayerCaves(this, world, random, rTerrain.nextParallelRNG(-1));
|
||||
glOreIron = new GenLayerOreIron(this, world, random, rTerrain.nextParallelRNG(-500), 10);
|
||||
glOreLapis = new GenLayerOreLapis(this, world, random, rTerrain.nextParallelRNG(-501), 15);
|
||||
glOreCoal = new GenLayerOreCoal(this, world, random, rTerrain.nextParallelRNG(-502), 20);
|
||||
glOreGold = new GenLayerOreGold(this, world, random, rTerrain.nextParallelRNG(-503), 25);
|
||||
glOreEmerald = new GenLayerOreEmerald(this, world, random, rTerrain.nextParallelRNG(-504), 30);
|
||||
glOreDiamond = new GenLayerOreDiamond(this, world, random, rTerrain.nextParallelRNG(-505), 35);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -224,14 +206,8 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
glCaves.genCaves(wxx, wzx, x, z, height, this);
|
||||
glOreIron.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
glOreLapis.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
glOreCoal.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
glOreGold.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
glOreEmerald.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
glOreDiamond.genOre(wxx, wzx, x, z, height, this, biome);
|
||||
|
||||
plan.caveMs(glCaves.genCaves(wxx, wzx, x, z, height, this));
|
||||
|
||||
return biome.getRealBiome();
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MaxingGenerator;
|
||||
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
@@ -29,8 +30,9 @@ public class GenLayerCaves extends GenLayer
|
||||
|
||||
}
|
||||
|
||||
public void genCaves(double wxx, double wzx, int x, int z, int s, IrisGenerator g)
|
||||
public double genCaves(double wxx, double wzx, int x, int z, int s, IrisGenerator g)
|
||||
{
|
||||
PrecisionStopwatch p = PrecisionStopwatch.start();
|
||||
for(double itr = 0; itr < 0.1 * Iris.settings.gen.caveDensity; itr += 0.1)
|
||||
{
|
||||
double thickness = 0.25 + itr + (0.5 * caveClamp.noise(wxx, wzx));
|
||||
@@ -69,6 +71,8 @@ public class GenLayerCaves extends GenLayer
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return p.getMilliseconds();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerOreCoal extends GenLayer
|
||||
{
|
||||
private CNG ore;
|
||||
|
||||
public GenLayerOreCoal(IrisGenerator iris, World world, Random random, RNG rng, int shift)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
ore = new CNG(rng.nextParallelRNG(281 + shift), 1D, 1).scale(0.1125).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genOre(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome b)
|
||||
{
|
||||
double orenoise = ore.noise(wxx, wzx);
|
||||
|
||||
if(IrisGenerator.ROCK.contains(MB.of(g.getType(x, (int) (orenoise * 200D) - 15, z))))
|
||||
{
|
||||
g.setBlock(x, (int) (orenoise * 200D) - 15, z, Material.COAL_ORE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerOreDiamond extends GenLayer
|
||||
{
|
||||
private CNG ore;
|
||||
private CNG clamp;
|
||||
|
||||
public GenLayerOreDiamond(IrisGenerator iris, World world, Random random, RNG rng, int shift)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
ore = new CNG(rng.nextParallelRNG(281 + shift), 1D, 1).scale(0.08725).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
clamp = new CNG(rng.nextParallelRNG(299 + shift), 1D, 1).scale(0.0325).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genOre(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome b)
|
||||
{
|
||||
double orenoise = ore.noise(wxx, wzx);
|
||||
|
||||
if(clamp.noise(wxx, wzx) > 0.85 && IrisGenerator.ROCK.contains(MB.of(g.getType(x, (int) (orenoise * 12D), z))))
|
||||
{
|
||||
g.setBlock(x, (int) (orenoise * 12D), z, Material.DIAMOND_ORE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerOreEmerald extends GenLayer
|
||||
{
|
||||
private CNG ore;
|
||||
|
||||
public GenLayerOreEmerald(IrisGenerator iris, World world, Random random, RNG rng, int shift)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
ore = new CNG(rng.nextParallelRNG(281 + shift), 1D, 1).scale(0.1125).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genOre(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome b)
|
||||
{
|
||||
double orenoise = ore.noise(wxx, wzx);
|
||||
|
||||
if(b.getScatterChanceSingle().material.equals(Material.LONG_GRASS) && b.getScatterChanceSingle().material.equals(Material.LONG_GRASS) && b.getScatterChanceSingle().material.equals(Material.LONG_GRASS) && IrisGenerator.ROCK.contains(MB.of(g.getType(x, (int) (orenoise * 32D), z))))
|
||||
{
|
||||
g.setBlock(x, (int) (orenoise * 32D), z, Material.EMERALD_ORE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerOreGold extends GenLayer
|
||||
{
|
||||
private CNG ore;
|
||||
private CNG clamp;
|
||||
|
||||
public GenLayerOreGold(IrisGenerator iris, World world, Random random, RNG rng, int shift)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
ore = new CNG(rng.nextParallelRNG(281 + shift), 1D, 3).scale(0.0925).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.0015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
clamp = new CNG(rng.nextParallelRNG(299 + shift), 1D, 1).scale(0.0325).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genOre(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome b)
|
||||
{
|
||||
double orenoise = ore.noise(wxx, wzx);
|
||||
|
||||
if(clamp.noise(wxx, wzx) > 0.75 && (int) (orenoise * 200D) - 42 < 45 && b.getSurface().contains(new MB(Material.GRASS)) && IrisGenerator.ROCK.contains(MB.of(g.getType(x, (int) (orenoise * 200D) - 42, z))))
|
||||
{
|
||||
g.setBlock(x, (int) (orenoise * 200D) - 42, z, Material.GOLD_ORE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerOreIron extends GenLayer
|
||||
{
|
||||
private CNG ore;
|
||||
|
||||
public GenLayerOreIron(IrisGenerator iris, World world, Random random, RNG rng, int shift)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
ore = new CNG(rng.nextParallelRNG(281 + shift), 1D, 1).scale(0.1125).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genOre(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome b)
|
||||
{
|
||||
double orenoise = ore.noise(wxx, wzx);
|
||||
|
||||
if(IrisGenerator.ROCK.contains(MB.of(g.getType(x, (int) (orenoise * 200D), z))))
|
||||
{
|
||||
g.setBlock(x, (int) (orenoise * 200D), z, Material.IRON_ORE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.layer;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenLayerOreLapis extends GenLayer
|
||||
{
|
||||
private CNG ore;
|
||||
|
||||
public GenLayerOreLapis(IrisGenerator iris, World world, Random random, RNG rng, int shift)
|
||||
{
|
||||
//@builder
|
||||
super(iris, world, random, rng);
|
||||
ore = new CNG(rng.nextParallelRNG(281 + shift), 1D, 3).scale(0.4125).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.0015).fractureWith(new CNG(rng.nextParallelRNG(412 + shift), 1D, 1)
|
||||
.scale(0.03), 33), 592);
|
||||
|
||||
//@done
|
||||
}
|
||||
|
||||
public void genOre(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome b)
|
||||
{
|
||||
double orenoise = ore.noise(wxx, wzx);
|
||||
|
||||
if(b.getSurface().contains(new MB(Material.SAND)) && IrisGenerator.ROCK.contains(MB.of(g.getType(x, (int) (orenoise * 200D), z))))
|
||||
{
|
||||
g.setBlock(x, (int) (orenoise * 200D), z, Material.LAPIS_ORE);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public double generateLayer(double noise, double dx, double dz)
|
||||
{
|
||||
return noise;
|
||||
}
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.populator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.schematic.Schematic;
|
||||
import ninja.bytecode.iris.spec.IrisBiome;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
|
||||
public class BiomeBiasSchematicPopulator extends SurfaceBiasSchematicPopulator
|
||||
{
|
||||
protected IrisBiome biome;
|
||||
public BiomeBiasSchematicPopulator(double chance, IrisBiome biome, Schematic... schematics)
|
||||
{
|
||||
super(chance, schematics);
|
||||
this.biome = biome;
|
||||
|
||||
for(MB i : biome.getSurface())
|
||||
{
|
||||
surface(i.material);
|
||||
}
|
||||
}
|
||||
|
||||
public void doPopulate(World world, Random random, Chunk source, int wx, int wz)
|
||||
{
|
||||
if(world.getBiome(wx, wz).equals(biome.getRealBiome()))
|
||||
{
|
||||
super.doPopulate(world, random, source, wx, wz);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((biome == null) ? 0 : biome.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(!super.equals(obj))
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
BiomeBiasSchematicPopulator other = (BiomeBiasSchematicPopulator) obj;
|
||||
if(biome == null)
|
||||
{
|
||||
if(other.biome != null)
|
||||
return false;
|
||||
}
|
||||
else if(!biome.equals(other.biome))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package ninja.bytecode.iris.generator.populator;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -45,6 +46,7 @@ public class ObjectPopulator extends BlockPopulator
|
||||
@Override
|
||||
public void populate(World world, Random random, Chunk source)
|
||||
{
|
||||
Iris.started("decor");
|
||||
GSet<Biome> hits = new GSet<>();
|
||||
|
||||
for(int i = 0; i < Iris.settings.performance.decorationAccuracy; i++)
|
||||
@@ -73,11 +75,13 @@ public class ObjectPopulator extends BlockPopulator
|
||||
}
|
||||
|
||||
hits.add(biome);
|
||||
populate(world, random, source, biome, objects);
|
||||
populate(world, random, source, biome, ibiome, objects);
|
||||
}
|
||||
|
||||
Iris.stopped("decor");
|
||||
}
|
||||
|
||||
private void populate(World world, Random random, Chunk source, Biome biome, GMap<SchematicGroup, Double> objects)
|
||||
private void populate(World world, Random random, Chunk source, Biome biome, IrisBiome ibiome, GMap<SchematicGroup, Double> objects)
|
||||
{
|
||||
for(SchematicGroup i : objects.k())
|
||||
{
|
||||
@@ -85,14 +89,15 @@ public class ObjectPopulator extends BlockPopulator
|
||||
{
|
||||
int x = (source.getX() << 4) + random.nextInt(16);
|
||||
int z = (source.getZ() << 4) + random.nextInt(16);
|
||||
Block b = world.getHighestBlockAt(x, z);
|
||||
Block b = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN);
|
||||
Material t = b.getType();
|
||||
|
||||
if(!b.getRelative(BlockFace.DOWN).getType().isSolid())
|
||||
if(!t.isSolid() || !ibiome.isSurface(t))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(world, x, b.getY() - 1, z);
|
||||
i.getSchematics().get(random.nextInt(i.getSchematics().size())).place(world, x, b.getY(), z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.populator;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import ninja.bytecode.iris.schematic.Schematic;
|
||||
import ninja.bytecode.iris.util.ChancedPopulator;
|
||||
|
||||
public class SchematicPopulator extends ChancedPopulator
|
||||
{
|
||||
protected final Schematic[] schematics;
|
||||
|
||||
public SchematicPopulator(double chance, Schematic... schematics)
|
||||
{
|
||||
super(chance);
|
||||
this.schematics = schematics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPopulate(World world, Random random, Chunk source, int wx, int wz)
|
||||
{
|
||||
Block b = world.getHighestBlockAt(wx, wz);
|
||||
|
||||
if(!b.getRelative(BlockFace.DOWN).getType().isSolid())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
schematics[random.nextInt(schematics.length)].place(world, wx, b.getY() - 1, wz);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + Arrays.hashCode(schematics);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(!super.equals(obj))
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
SchematicPopulator other = (SchematicPopulator) obj;
|
||||
if(!Arrays.equals(schematics, other.schematics))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -1,78 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.populator;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
|
||||
import ninja.bytecode.iris.schematic.Schematic;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
|
||||
public class SurfaceBiasSchematicPopulator extends SchematicPopulator
|
||||
{
|
||||
private GList<Material> bias;
|
||||
|
||||
public SurfaceBiasSchematicPopulator(double chance, Schematic... schematics)
|
||||
{
|
||||
super(chance, schematics);
|
||||
this.bias = new GList<>();
|
||||
}
|
||||
|
||||
public SurfaceBiasSchematicPopulator surface(Material mb)
|
||||
{
|
||||
bias.add(mb);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = super.hashCode();
|
||||
result = prime * result + ((bias == null) ? 0 : bias.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if(this == obj)
|
||||
return true;
|
||||
if(!super.equals(obj))
|
||||
return false;
|
||||
if(getClass() != obj.getClass())
|
||||
return false;
|
||||
SurfaceBiasSchematicPopulator other = (SurfaceBiasSchematicPopulator) obj;
|
||||
if(bias == null)
|
||||
{
|
||||
if(other.bias != null)
|
||||
return false;
|
||||
}
|
||||
else if(!bias.equals(other.bias))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doPopulate(World world, Random random, Chunk source, int wx, int wz)
|
||||
{
|
||||
if(schematics.length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Block b = world.getHighestBlockAt(wx, wz);
|
||||
|
||||
for(Material i : bias)
|
||||
{
|
||||
if(b.getRelative(BlockFace.DOWN).getType().equals(i))
|
||||
{
|
||||
schematics[random.nextInt(schematics.length)].place(world, wx, b.getY() - 1, wz);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user