mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 15:26:28 +00:00
Parallax Object Generation
This commit is contained in:
@@ -1,13 +1,11 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.util.NumberConversions;
|
||||
|
||||
import mortar.util.text.C;
|
||||
@@ -30,14 +28,15 @@ import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.ChunkPlan;
|
||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.ParallelChunkGenerator;
|
||||
import ninja.bytecode.iris.util.ParallaxWorldGenerator;
|
||||
import ninja.bytecode.iris.util.SChunkVector;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class IrisGenerator extends ParallelChunkGenerator
|
||||
public class IrisGenerator extends ParallaxWorldGenerator
|
||||
{
|
||||
//@builder
|
||||
public static final GList<MB> ROCK = new GList<MB>().add(new MB[] {
|
||||
@@ -75,7 +74,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
private GenLayerCliffs glCliffs;
|
||||
private RNG rTerrain;
|
||||
private CompiledDimension dim;
|
||||
private World world;
|
||||
|
||||
public IrisGenerator()
|
||||
{
|
||||
@@ -113,7 +111,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
|
||||
//@builder
|
||||
this.world = world;
|
||||
rTerrain = new RNG(world.getSeed());
|
||||
glLNoise = new GenLayerLayeredNoise(this, world, random, rTerrain.nextParallelRNG(2));
|
||||
glBiome = new GenLayerBiome(this, world, random, rTerrain.nextParallelRNG(4), dim.getBiomes());
|
||||
@@ -124,6 +121,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
glCliffs = new GenLayerCliffs(this, world, random, rTerrain.nextParallelRNG(9));
|
||||
scatterCache = new double[16][][];
|
||||
scatter = new CNG(rTerrain.nextParallelRNG(52), 1, 1).scale(10);
|
||||
god = new GenObjectDecorator(this);
|
||||
//@done
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
@@ -242,11 +240,25 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome genColumn(int wxxf, int wzxf, int x, int z, ChunkPlan plan)
|
||||
public void onGenParallax(int x, int z, Random random)
|
||||
{
|
||||
try
|
||||
{
|
||||
god.decorateParallax(x, z, random);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Biome onGenColumn(int wxxf, int wzxf, int x, int z, ChunkPlan plan, AtomicChunkData data)
|
||||
{
|
||||
if(disposed)
|
||||
{
|
||||
setBlock(x, 0, z, Material.MAGENTA_GLAZED_TERRACOTTA);
|
||||
data.setBlock(x, 0, z, Material.MAGENTA_GLAZED_TERRACOTTA);
|
||||
return Biome.VOID;
|
||||
}
|
||||
|
||||
@@ -296,7 +308,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
for(int j = 0; j < snowHeight; j++)
|
||||
{
|
||||
highest = j == snowHeight - 1 ? highest < j ? j : highest : highest < j + 1 ? j + 1 : highest;
|
||||
setBlock(x, i + j + 1, z, j == snowHeight - 1 ? Material.SNOW : Material.SNOW_BLOCK, j == snowHeight - 1 ? (byte) layers : (byte) 0);
|
||||
data.setBlock(x, i + j + 1, z, j == snowHeight - 1 ? Material.SNOW : Material.SNOW_BLOCK, j == snowHeight - 1 ? (byte) layers : (byte) 0);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -307,24 +319,24 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
if(!mbx.material.equals(Material.AIR))
|
||||
{
|
||||
highest = i > highest ? i : highest;
|
||||
setBlock(x, i + 1, z, mbx.material, mbx.data);
|
||||
data.setBlock(x, i + 1, z, mbx.material, mbx.data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
highest = i > highest ? i : highest;
|
||||
setBlock(x, i, z, mb.material, mb.data);
|
||||
data.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
glCaves.genCaves(wxx, wzx, x, z, height, this);
|
||||
glCarving.genCarves(wxx, wzx, x, z, height, this, biome);
|
||||
glCaverns.genCaverns(wxx, wzx, x, z, height, this, biome);
|
||||
glCaves.genCaves(wxx, wzx, x, z, height, this, data);
|
||||
glCarving.genCarves(wxx, wzx, x, z, height, this, biome, data);
|
||||
glCaverns.genCaverns(wxx, wzx, x, z, height, this, biome, data);
|
||||
int hw = 0;
|
||||
int hl = 0;
|
||||
|
||||
for(int i = highest; i > 0; i--)
|
||||
{
|
||||
Material t = getType(x, i, z);
|
||||
Material t = data.getType(x, i, z);
|
||||
hw = i > seaLevel && hw == 0 && (t.equals(Material.WATER) || t.equals(Material.STATIONARY_WATER)) ? i : hw;
|
||||
hl = hl == 0 && !t.equals(Material.AIR) ? i : hl;
|
||||
}
|
||||
@@ -336,31 +348,12 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
return biome.getRealBiome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decorateColumn(int wx, int wz, int x, int z, ChunkPlan plan)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPostChunk(World world, int x, int z, Random random, AtomicChunkData data, ChunkPlan plan)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||
{
|
||||
GList<BlockPopulator> p = new GList<>();
|
||||
|
||||
if(Iris.settings.gen.genObjects)
|
||||
{
|
||||
p.add(god = new GenObjectDecorator(this));
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
private double getBiomedHeight(int x, int z, ChunkPlan plan)
|
||||
{
|
||||
double xh = plan.getHeight(x, z);
|
||||
@@ -377,11 +370,6 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
return xh;
|
||||
}
|
||||
|
||||
public World getWorld()
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
public RNG getRTerrain()
|
||||
{
|
||||
return rTerrain;
|
||||
@@ -398,7 +386,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
return;
|
||||
}
|
||||
L.w(C.YELLOW + "Disposed Iris World " + C.RED + world.getName());
|
||||
L.w(C.YELLOW + "Disposed Iris World " + C.RED + getWorld().getName());
|
||||
disposed = true;
|
||||
dim = null;
|
||||
glLNoise = null;
|
||||
@@ -407,6 +395,7 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
glCaverns = null;
|
||||
glSnow = null;
|
||||
glCliffs = null;
|
||||
god.dispose();
|
||||
}
|
||||
|
||||
public boolean isDisposed()
|
||||
@@ -439,4 +428,16 @@ public class IrisGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
return god.randomObject(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected SChunkVector getParallaxSize()
|
||||
{
|
||||
return dim.getMaxChunkSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUnload()
|
||||
{
|
||||
dispose();
|
||||
}
|
||||
}
|
||||
@@ -98,7 +98,7 @@ public class GenObject
|
||||
}
|
||||
|
||||
mountHeight = avg(avy);
|
||||
mount = new BlockVector(avg(avx), 0, avg(avz));
|
||||
mount = new BlockVector(0, 0, 0);
|
||||
}
|
||||
|
||||
private int avg(double[] v)
|
||||
@@ -255,7 +255,7 @@ public class GenObject
|
||||
|
||||
public Location place(int wx, int wy, int wz, IPlacer placer)
|
||||
{
|
||||
Location start = new Location(placer.getWorld(), wx, wy, wz).clone().add(sh(w), sh(h) + 1, sh(d));
|
||||
Location start = new Location(placer.getWorld(), wx, wy, wz).clone().add(0, sh(h) + 1, 0);
|
||||
|
||||
if(mount == null)
|
||||
{
|
||||
@@ -279,21 +279,25 @@ public class GenObject
|
||||
MB b = getSchematic().get(i);
|
||||
Location f = start.clone().add(i.toBlockVector());
|
||||
|
||||
Material m = placer.get(f.clone().subtract(0, 1, 0)).material;
|
||||
if(i.getY() == mountHeight && (m.equals(Material.WATER) || m.equals(Material.STATIONARY_WATER) || m.equals(Material.LAVA) || m.equals(Material.STATIONARY_LAVA)))
|
||||
if(!Iris.settings.performance.noObjectFail)
|
||||
{
|
||||
for(Location j : undo.k())
|
||||
{
|
||||
placer.set(j, undo.get(j));
|
||||
}
|
||||
Material m = placer.get(f.clone().subtract(0, 1, 0)).material;
|
||||
|
||||
if(Iris.settings.performance.verbose)
|
||||
if(i.getY() == mountHeight && (m.equals(Material.WATER) || m.equals(Material.STATIONARY_WATER) || m.equals(Material.LAVA) || m.equals(Material.STATIONARY_LAVA)))
|
||||
{
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + getName() + C.WHITE + " failed to place in " + C.YELLOW + m.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(f.getBlockX()) + " " + F.f(f.getBlockY()) + " " + F.f(f.getBlockZ()));
|
||||
}
|
||||
for(Location j : undo.k())
|
||||
{
|
||||
placer.set(j, undo.get(j));
|
||||
}
|
||||
|
||||
failures++;
|
||||
return null;
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + getName() + C.WHITE + " failed to place in " + C.YELLOW + m.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(f.getBlockX()) + " " + F.f(f.getBlockY()) + " " + F.f(f.getBlockZ()));
|
||||
}
|
||||
|
||||
failures++;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
|
||||
@@ -2,41 +2,34 @@ package ninja.bytecode.iris.generator.genobject;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
|
||||
import mortar.logic.format.F;
|
||||
import mortar.util.text.C;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.generator.placer.BukkitPlacer;
|
||||
import ninja.bytecode.iris.generator.placer.NMSPlacer;
|
||||
import ninja.bytecode.iris.generator.placer.AtomicParallaxPlacer;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
import ninja.bytecode.iris.util.IPlacer;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.ParallaxCache;
|
||||
import ninja.bytecode.iris.util.SMCAVector;
|
||||
import ninja.bytecode.shuriken.collections.GList;
|
||||
import ninja.bytecode.shuriken.collections.GMap;
|
||||
import ninja.bytecode.shuriken.collections.GSet;
|
||||
import ninja.bytecode.shuriken.execution.ChronoLatch;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
import ninja.bytecode.shuriken.math.M;
|
||||
import ninja.bytecode.shuriken.math.RNG;
|
||||
|
||||
public class GenObjectDecorator extends BlockPopulator
|
||||
public class GenObjectDecorator
|
||||
{
|
||||
private GList<PlacedObject> placeHistory;
|
||||
private GMap<IrisBiome, GList<GenObjectGroup>> orderCache;
|
||||
private GMap<IrisBiome, GMap<GenObjectGroup, Double>> populationCache;
|
||||
private IPlacer placer;
|
||||
private Executor ex;
|
||||
private IrisGenerator g;
|
||||
private ChronoLatch cl = new ChronoLatch(250);
|
||||
|
||||
@@ -46,7 +39,6 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
placeHistory = new GList<>();
|
||||
populationCache = new GMap<>();
|
||||
orderCache = new GMap<>();
|
||||
ex = Executors.newSingleThreadExecutor();
|
||||
|
||||
for(IrisBiome i : generator.getDimension().getBiomes())
|
||||
{
|
||||
@@ -100,25 +92,24 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
L.i("Population Cache is " + populationCache.size());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void populate(World world, Random rnotusingyou, Chunk source)
|
||||
public void decorateParallax(int cx, int cz, Random random)
|
||||
{
|
||||
if(g.isDisposed())
|
||||
try
|
||||
{
|
||||
placeHistory.clear();
|
||||
return;
|
||||
}
|
||||
if(g.isDisposed())
|
||||
{
|
||||
placeHistory.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
ex.execute(() ->
|
||||
{
|
||||
Random random = new Random(((source.getX() - 32) * (source.getZ() + 54)) + world.getSeed());
|
||||
ParallaxCache cache = new ParallaxCache(g);
|
||||
GSet<IrisBiome> hits = new GSet<>();
|
||||
|
||||
for(int i = 0; i < Iris.settings.performance.decorationAccuracy; i++)
|
||||
{
|
||||
int x = (source.getX() << 4) + random.nextInt(16);
|
||||
int z = (source.getZ() << 4) + random.nextInt(16);
|
||||
IrisBiome biome = g.getBiome((int) g.getOffsetX(x), (int) g.getOffsetX(z));
|
||||
int x = (cx << 4) + random.nextInt(16);
|
||||
int z = (cz << 4) + random.nextInt(16);
|
||||
IrisBiome biome = cache.getBiome(x, z);
|
||||
|
||||
if(hits.contains(biome))
|
||||
{
|
||||
@@ -133,20 +124,19 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
}
|
||||
|
||||
hits.add(biome);
|
||||
|
||||
populate(world, random, source, biome, orderCache.get(biome));
|
||||
populate(cx, cz, random, biome, cache);
|
||||
}
|
||||
}
|
||||
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.flush();
|
||||
}
|
||||
});
|
||||
catch(Throwable e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void populate(World world, Random random, Chunk source, IrisBiome biome, GList<GenObjectGroup> order)
|
||||
private void populate(int cx, int cz, Random random, IrisBiome biome, ParallaxCache cache)
|
||||
{
|
||||
for(GenObjectGroup i : order)
|
||||
for(GenObjectGroup i : orderCache.get(biome))
|
||||
{
|
||||
if(biome.getSchematicGroups().get(i.getName()) == null)
|
||||
{
|
||||
@@ -158,60 +148,65 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
{
|
||||
if(M.r(Iris.settings.gen.objectDensity))
|
||||
{
|
||||
int x = (source.getX() << 4) + random.nextInt(16);
|
||||
int z = (source.getZ() << 4) + random.nextInt(16);
|
||||
Block b = world.getHighestBlockAt(x, z).getRelative(BlockFace.DOWN);
|
||||
Material t = b.getType();
|
||||
GenObject go = i.getSchematics().get(random.nextInt(i.getSchematics().size()));
|
||||
int x = (cx << 4) + random.nextInt(16);
|
||||
int z = (cz << 4) + random.nextInt(16);
|
||||
|
||||
if(!t.isSolid() || !biome.isSurface(t))
|
||||
if(i.getWorldChance() >= 0D)
|
||||
{
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + i.getName() + "/*" + C.WHITE + " failed to place in " + C.YELLOW + t.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(b.getX()) + " " + F.f(b.getY()) + " " + F.f(b.getZ()));
|
||||
}
|
||||
int rngx = (int) Math.floor(x / (double) (i.getWorldRadius() == 0 ? 32 : i.getWorldRadius()));
|
||||
int rngz = (int) Math.floor(z / (double) (i.getWorldRadius() == 0 ? 32 : i.getWorldRadius()));
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if(placer == null)
|
||||
{
|
||||
if(Iris.settings.performance.fastDecoration)
|
||||
{
|
||||
placer = new NMSPlacer(world);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
placer = new BukkitPlacer(world, false);
|
||||
}
|
||||
}
|
||||
|
||||
GenObject g = i.getSchematics().get(random.nextInt(i.getSchematics().size()));
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
|
||||
{
|
||||
Location start = g.place(x, b.getY(), z, placer);
|
||||
|
||||
if(start != null)
|
||||
if(new RNG(new SMCAVector(rngx, rngz).hashCode()).nextDouble() < i.getWorldChance())
|
||||
{
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.v(C.GRAY + "Placed " + C.DARK_GREEN + i.getName() + C.WHITE + "/" + C.DARK_GREEN + g.getName() + C.GRAY + " at " + C.DARK_GREEN + F.f(start.getBlockX()) + " " + F.f(start.getBlockY()) + " " + F.f(start.getBlockZ()));
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + i.getName() + "/*" + C.WHITE + " failed to place due to a world chance.");
|
||||
}
|
||||
|
||||
if(Iris.settings.performance.debugMode)
|
||||
{
|
||||
placeHistory.add(new PlacedObject(start.getBlockX(), start.getBlockY(), start.getBlockZ(), i.getName() + ":" + g.getName()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(placeHistory.size() > Iris.settings.performance.placeHistoryLimit)
|
||||
int by = cache.getHeight(x, z);
|
||||
MB mb = cache.get(x, by, z);
|
||||
|
||||
if(!Iris.settings.performance.noObjectFail)
|
||||
{
|
||||
if(!mb.material.isSolid() || !biome.isSurface(mb.material))
|
||||
{
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.w(C.WHITE + "Object " + C.YELLOW + i.getName() + "/*" + C.WHITE + " failed to place in " + C.YELLOW + mb.material.toString().toLowerCase() + C.WHITE + " at " + C.YELLOW + F.f(x) + " " + F.f(by) + " " + F.f(z));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
placer = new AtomicParallaxPlacer(g, cache);
|
||||
Location start = go.place(x, by, z, placer);
|
||||
|
||||
if(start != null)
|
||||
{
|
||||
if(Iris.settings.performance.verbose)
|
||||
{
|
||||
L.v(C.GRAY + "Placed " + C.DARK_GREEN + i.getName() + C.WHITE + "/" + C.DARK_GREEN + go.getName() + C.GRAY + " at " + C.DARK_GREEN + F.f(start.getBlockX()) + " " + F.f(start.getBlockY()) + " " + F.f(start.getBlockZ()));
|
||||
}
|
||||
|
||||
if(Iris.settings.performance.debugMode)
|
||||
{
|
||||
placeHistory.add(new PlacedObject(start.getBlockX(), start.getBlockY(), start.getBlockZ(), i.getName() + ":" + go.getName()));
|
||||
|
||||
if(placeHistory.size() > Iris.settings.performance.placeHistoryLimit)
|
||||
{
|
||||
while(placeHistory.size() > Iris.settings.performance.placeHistoryLimit)
|
||||
{
|
||||
while(placeHistory.size() > Iris.settings.performance.placeHistoryLimit)
|
||||
{
|
||||
placeHistory.remove(0);
|
||||
}
|
||||
placeHistory.remove(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -249,6 +244,11 @@ public class GenObjectDecorator extends BlockPopulator
|
||||
return placeHistory;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public PlacedObject randomObject(String string)
|
||||
{
|
||||
GList<PlacedObject> v = new GList<>();
|
||||
|
||||
@@ -21,6 +21,8 @@ public class GenObjectGroup
|
||||
private GList<String> flags;
|
||||
private String name;
|
||||
private int priority;
|
||||
private double worldChance;
|
||||
private int worldRad;
|
||||
|
||||
public GenObjectGroup(String name)
|
||||
{
|
||||
@@ -28,6 +30,8 @@ public class GenObjectGroup
|
||||
this.flags = new GList<>();
|
||||
this.name = name;
|
||||
priority = Integer.MIN_VALUE;
|
||||
worldChance = Integer.MIN_VALUE;
|
||||
worldRad = 32;
|
||||
}
|
||||
|
||||
public void read(DataInputStream din) throws IOException
|
||||
@@ -295,4 +299,36 @@ public class GenObjectGroup
|
||||
return true;
|
||||
}
|
||||
|
||||
public double getWorldChance()
|
||||
{
|
||||
if(worldChance == Integer.MIN_VALUE)
|
||||
{
|
||||
for(String i : flags)
|
||||
{
|
||||
if(i.startsWith("world chance "))
|
||||
{
|
||||
worldChance = Double.valueOf(i.split("\\Q \\E")[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return worldChance;
|
||||
}
|
||||
|
||||
public double getWorldRadius()
|
||||
{
|
||||
if(worldRad == Integer.MIN_VALUE)
|
||||
{
|
||||
for(String i : flags)
|
||||
{
|
||||
if(i.startsWith("world radius "))
|
||||
{
|
||||
worldRad = Integer.valueOf(i.split("\\Q \\E")[2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return worldRad;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.World;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
@@ -68,7 +69,7 @@ public class GenLayerCarving extends GenLayer
|
||||
return carver.noise(x + fx, y - fy, z + fz);
|
||||
}
|
||||
|
||||
public void genCarves(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome biome)
|
||||
public void genCarves(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome biome, AtomicChunkData data)
|
||||
{
|
||||
if(!Iris.settings.gen.genCarving)
|
||||
{
|
||||
@@ -103,7 +104,7 @@ public class GenLayerCarving extends GenLayer
|
||||
if(carve(wxx, i, wzx) < IrisInterpolation.lerpBezier(0, ch, hill))
|
||||
{
|
||||
carved++;
|
||||
g.setBlock(x, i, z, Material.AIR);
|
||||
data.setBlock(x, i, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ public class GenLayerCarving extends GenLayer
|
||||
|
||||
for(int i = Iris.settings.gen.maxCarvingHeight; i > Iris.settings.gen.minCarvingHeight; i--)
|
||||
{
|
||||
Material m = g.getType(x, i, z);
|
||||
Material m = data.getType(x, i, z);
|
||||
if(!m.equals(Material.AIR))
|
||||
{
|
||||
hit++;
|
||||
@@ -126,7 +127,7 @@ public class GenLayerCarving extends GenLayer
|
||||
{
|
||||
for(int j = i; j > i - 5; j--)
|
||||
{
|
||||
if(g.getType(x, j, z).equals(Material.AIR))
|
||||
if(data.getType(x, j, z).equals(Material.AIR))
|
||||
{
|
||||
fail = true;
|
||||
break;
|
||||
@@ -137,12 +138,12 @@ public class GenLayerCarving extends GenLayer
|
||||
if(!fail)
|
||||
{
|
||||
MB mb = biome.getSurface(wxx, wzx, g.getRTerrain());
|
||||
g.setBlock(x, i, z, mb.material, mb.data);
|
||||
data.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
g.setBlock(x, i, z, Material.AIR);
|
||||
data.setBlock(x, i, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,12 +152,12 @@ public class GenLayerCarving extends GenLayer
|
||||
if(!fail)
|
||||
{
|
||||
MB mb = biome.getSubSurface(wxx, i, wzx, g.getRTerrain());
|
||||
g.setBlock(x, i, z, mb.material, mb.data);
|
||||
data.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
g.setBlock(x, i, z, Material.AIR);
|
||||
data.setBlock(x, i, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.World;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.pack.IrisBiome;
|
||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
@@ -68,7 +69,7 @@ public class GenLayerCaverns extends GenLayer
|
||||
return carver.noise(x + fx, y - fy, z + fz);
|
||||
}
|
||||
|
||||
public void genCaverns(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome biome)
|
||||
public void genCaverns(double wxx, double wzx, int x, int z, int s, IrisGenerator g, IrisBiome biome, AtomicChunkData data)
|
||||
{
|
||||
if(!Iris.settings.gen.genCaverns)
|
||||
{
|
||||
@@ -103,7 +104,7 @@ public class GenLayerCaverns extends GenLayer
|
||||
if(cavern(wxx, i, wzx) < IrisInterpolation.lerpBezier(0, ch, hill))
|
||||
{
|
||||
carved++;
|
||||
g.setBlock(x, i, z, Material.AIR);
|
||||
data.setBlock(x, i, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,7 +114,7 @@ public class GenLayerCaverns extends GenLayer
|
||||
|
||||
for(int i = Iris.settings.gen.maxCavernHeight; i > Iris.settings.gen.minCavernHeight; i--)
|
||||
{
|
||||
Material m = g.getType(x, i, z);
|
||||
Material m = data.getType(x, i, z);
|
||||
if(!m.equals(Material.AIR))
|
||||
{
|
||||
hit++;
|
||||
@@ -126,7 +127,7 @@ public class GenLayerCaverns extends GenLayer
|
||||
{
|
||||
for(int j = i; j > i - 5; j--)
|
||||
{
|
||||
if(g.getType(x, j, z).equals(Material.AIR))
|
||||
if(data.getType(x, j, z).equals(Material.AIR))
|
||||
{
|
||||
fail = true;
|
||||
break;
|
||||
@@ -137,12 +138,12 @@ public class GenLayerCaverns extends GenLayer
|
||||
if(!fail)
|
||||
{
|
||||
MB mb = biome.getSurface(wxx, wzx, g.getRTerrain());
|
||||
g.setBlock(x, i, z, mb.material, mb.data);
|
||||
data.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
g.setBlock(x, i, z, Material.AIR);
|
||||
data.setBlock(x, i, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -151,12 +152,12 @@ public class GenLayerCaverns extends GenLayer
|
||||
if(!fail)
|
||||
{
|
||||
MB mb = biome.getSubSurface(wxx, i, wzx, g.getRTerrain());
|
||||
g.setBlock(x, i, z, mb.material, mb.data);
|
||||
data.setBlock(x, i, z, mb.material, mb.data);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
g.setBlock(x, i, z, Material.AIR);
|
||||
data.setBlock(x, i, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.GenLayer;
|
||||
import ninja.bytecode.iris.util.PolygonGenerator;
|
||||
import ninja.bytecode.shuriken.math.CNG;
|
||||
@@ -18,7 +19,7 @@ public class GenLayerCaves extends GenLayer
|
||||
private CNG caveGirth;
|
||||
private CNG caveClamp;
|
||||
private PolygonGenerator caveVeins;
|
||||
|
||||
|
||||
public GenLayerCaves(IrisGenerator iris, World world, Random random, RNG rng)
|
||||
{
|
||||
super(iris, world, random, rng);
|
||||
@@ -27,47 +28,47 @@ public class GenLayerCaves extends GenLayer
|
||||
caveClamp = new CNG(rng.nextParallelRNG(-10000), 1D, 3).scale(0.1422);
|
||||
caveVeins = new PolygonGenerator(rng.nextParallelRNG(-99999), 4, 0.002 * Iris.settings.gen.caveScale, 1, (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(-5555), 1D, 4).scale(0.02), 70));
|
||||
}
|
||||
|
||||
public void genCaves(double wxx, double wzx, int x, int z, int s, IrisGenerator g)
|
||||
|
||||
public void genCaves(double wxx, double wzx, int x, int z, int s, IrisGenerator g, AtomicChunkData data)
|
||||
{
|
||||
if(!Iris.settings.gen.genCaves)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
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));
|
||||
double size = 3.88D * thickness;
|
||||
double size = (3.88D * thickness);
|
||||
double variance = 8.34D * thickness;
|
||||
double w = size + (variance * caveGirth.noise(wxx, wzx));
|
||||
double h = size + (variance * caveGirth.noise(wzx, wxx));
|
||||
double width = 0;
|
||||
double height = h;
|
||||
double elevation = (caveHeight.noise(wxx + (19949D * itr), wzx - (19949D * itr)) * (350)) - 80;
|
||||
|
||||
while(width <= w && height > 1D)
|
||||
{
|
||||
width+=2;
|
||||
height-=2;
|
||||
width += 2;
|
||||
height -= 2;
|
||||
|
||||
if(caveVeins.hasBorder(3, width, wxx - (19949D * itr), wzx + (19949D * itr)))
|
||||
{
|
||||
double r = (((caveGirth.noise(wxx, wzx, width)) * variance) + height) / 2D;
|
||||
int f = 3;
|
||||
for(int i = (int) -r; i < r && f >= 0; i++)
|
||||
for(int i = (int) -r; i < r; i++)
|
||||
{
|
||||
if(i + height > s)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
Material t = g.getType(x, (int) (elevation + i) - 55, z);
|
||||
|
||||
Material t = data.getType(x, (int) (elevation + i) - 55, z);
|
||||
if(t.equals(Material.BEDROCK) || t.equals(Material.WATER) || t.equals(Material.STATIONARY_WATER))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
g.setBlock(x, (int) (elevation + i) - 55, z, Material.AIR);
|
||||
|
||||
data.setBlock(x, (int) (elevation + i) - 55, z, Material.AIR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
package ninja.bytecode.iris.generator.placer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import ninja.bytecode.iris.generator.IrisGenerator;
|
||||
import ninja.bytecode.iris.util.IrisWorldData;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.ParallaxCache;
|
||||
import ninja.bytecode.iris.util.Placer;
|
||||
|
||||
public class AtomicParallaxPlacer extends Placer
|
||||
{
|
||||
private IrisWorldData data;
|
||||
private ParallaxCache cache;
|
||||
|
||||
public AtomicParallaxPlacer(IrisGenerator g, ParallaxCache cache)
|
||||
{
|
||||
super(g.getWorld());
|
||||
this.data = g.getWorldData();
|
||||
this.cache = cache;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MB get(Location l)
|
||||
{
|
||||
return cache.get(l.getBlockX(), l.getBlockY(), l.getBlockZ());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void set(Location l, MB mb)
|
||||
{
|
||||
data.setBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ(), mb.material.getId(), mb.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestY(Location l)
|
||||
{
|
||||
return cache.getHeight(l.getBlockX(), l.getBlockZ());
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package ninja.bytecode.iris.generator.placer;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
import ninja.bytecode.iris.util.AtomicChunkData;
|
||||
import ninja.bytecode.iris.util.ChunkPlan;
|
||||
import ninja.bytecode.iris.util.MB;
|
||||
import ninja.bytecode.iris.util.Placer;
|
||||
|
||||
public class AtomicPlacer extends Placer
|
||||
{
|
||||
private AtomicChunkData data;
|
||||
private ChunkPlan plan;
|
||||
|
||||
public AtomicPlacer(World world)
|
||||
{
|
||||
super(world);
|
||||
}
|
||||
|
||||
public void bind(AtomicChunkData data, ChunkPlan plan)
|
||||
{
|
||||
this.data = data;
|
||||
this.plan = plan;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MB get(Location l)
|
||||
{
|
||||
return MB.of(data.getType(l.getBlockX(), l.getBlockY(), l.getBlockZ()), data.getData(l.getBlockX(), l.getBlockY(), l.getBlockZ()));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public void set(Location l, MB mb)
|
||||
{
|
||||
data.setBlock(l.getBlockX(), l.getBlockY(), l.getBlockZ(), mb.material.getId(), mb.data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHighestY(Location l)
|
||||
{
|
||||
return plan.getRealHeight(l.getBlockX(), l.getBlockZ());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user