mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-04-05 15:26:28 +00:00
Cleanup
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.layer.GenLayerBiome;
|
||||
import ninja.bytecode.iris.object.IrisBiome;
|
||||
import ninja.bytecode.iris.object.IrisRegion;
|
||||
import ninja.bytecode.iris.util.BiomeResult;
|
||||
import ninja.bytecode.iris.util.IrisInterpolation;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||
{
|
||||
protected GenLayerBiome glBiome;
|
||||
|
||||
public BiomeChunkGenerator(String dimensionName)
|
||||
{
|
||||
super(dimensionName);
|
||||
}
|
||||
|
||||
public void onInit(World world, RNG rng)
|
||||
{
|
||||
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
||||
}
|
||||
|
||||
public IrisRegion sampleRegion(int x, int z)
|
||||
{
|
||||
double wx = getZoomed(getModifiedX(x, z));
|
||||
double wz = getZoomed(getModifiedZ(x, z));
|
||||
return glBiome.getRegion(wx, wz);
|
||||
}
|
||||
|
||||
public BiomeResult sampleBiome(int x, int z)
|
||||
{
|
||||
double wx = getZoomed(getModifiedX(x, z));
|
||||
double wz = getZoomed(getModifiedZ(x, z));
|
||||
IrisRegion region = glBiome.getRegion(wx, wz);
|
||||
return glBiome.generateRegionData(wx, wz, region);
|
||||
}
|
||||
|
||||
protected double interpolateHeight(double rx, double rz, Function<IrisBiome, Double> property)
|
||||
{
|
||||
return IrisInterpolation.getNoise(getDimension().getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationScale(), (xx, zz) ->
|
||||
{
|
||||
BiomeResult neighborResult = glBiome.generateData(xx / getDimension().getTerrainZoom(), zz / getDimension().getTerrainZoom());
|
||||
return property.apply(neighborResult.getBiome());
|
||||
});
|
||||
}
|
||||
|
||||
protected double interpolateSurface(double rx, double rz, Function<IrisBiome, Double> property)
|
||||
{
|
||||
return IrisInterpolation.getNoise(getDimension().getInterpolationSurfaceFunction(), (int) Math.round(rx), (int) Math.round(rz), getDimension().getInterpolationSurfaceScale(), (xx, zz) ->
|
||||
{
|
||||
BiomeResult neighborResult = glBiome.generateData(xx / getDimension().getTerrainZoom(), zz / getDimension().getTerrainZoom());
|
||||
return property.apply(neighborResult.getBiome());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,293 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.world.ChunkLoadEvent;
|
||||
import org.bukkit.event.world.ChunkUnloadEvent;
|
||||
import org.bukkit.event.world.WorldUnloadEvent;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.IrisContext;
|
||||
import ninja.bytecode.iris.IrisMetrics;
|
||||
import ninja.bytecode.iris.util.BlockDataTools;
|
||||
import ninja.bytecode.iris.util.CNG;
|
||||
import ninja.bytecode.iris.util.ChronoLatch;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
import ninja.bytecode.shuriken.bench.PrecisionStopwatch;
|
||||
import ninja.bytecode.shuriken.logging.L;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class ContextualChunkGenerator extends ChunkGenerator implements Listener
|
||||
{
|
||||
protected boolean failing;
|
||||
protected int task;
|
||||
protected boolean initialized;
|
||||
protected RNG masterRandom;
|
||||
protected ChronoLatch perSecond;
|
||||
protected ChronoLatch pushLatch;
|
||||
protected IrisMetrics metrics;
|
||||
protected World world;
|
||||
protected int generated;
|
||||
protected int ticks;
|
||||
protected boolean pregenDone;
|
||||
|
||||
public ContextualChunkGenerator()
|
||||
{
|
||||
pushLatch = new ChronoLatch(3000);
|
||||
perSecond = new ChronoLatch(1000);
|
||||
CNG.creates = 0;
|
||||
generated = 0;
|
||||
ticks = 0;
|
||||
task = -1;
|
||||
initialized = false;
|
||||
failing = false;
|
||||
pregenDone = false;
|
||||
}
|
||||
|
||||
protected abstract void onGenerate(RNG masterRandom, int x, int z, ChunkData data, BiomeGrid grid);
|
||||
|
||||
protected abstract void onInit(World world, RNG masterRandom);
|
||||
|
||||
protected abstract void onTick(int ticks);
|
||||
|
||||
protected abstract void onClose();
|
||||
|
||||
protected abstract void onFailure(Throwable e);
|
||||
|
||||
protected abstract void onChunkLoaded(Chunk c);
|
||||
|
||||
protected abstract void onChunkUnloaded(Chunk c);
|
||||
|
||||
protected abstract void onPlayerJoin(Player p);
|
||||
|
||||
protected abstract void onPlayerLeft(Player p);
|
||||
|
||||
private void init(World world, RNG rng)
|
||||
{
|
||||
if(initialized)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.world = world;
|
||||
this.masterRandom = new RNG(world.getSeed());
|
||||
metrics = new IrisMetrics(128);
|
||||
initialized = true;
|
||||
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
|
||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::tick, 0, 0);
|
||||
onInit(world, masterRandom);
|
||||
}
|
||||
|
||||
private void tick()
|
||||
{
|
||||
if(perSecond.flip())
|
||||
{
|
||||
if(generated > 770)
|
||||
{
|
||||
pregenDone = true;
|
||||
}
|
||||
|
||||
if(pregenDone)
|
||||
{
|
||||
metrics.getPerSecond().put(generated);
|
||||
generated = 0;
|
||||
}
|
||||
}
|
||||
|
||||
onTick(ticks++);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerTeleportEvent e)
|
||||
{
|
||||
if(e.getFrom().getWorld().equals(world) && !e.getTo().getWorld().equals(world))
|
||||
{
|
||||
onPlayerLeft(e.getPlayer());
|
||||
}
|
||||
|
||||
if(!e.getFrom().getWorld().equals(world) && e.getTo().getWorld().equals(world))
|
||||
{
|
||||
onPlayerJoin(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerQuitEvent e)
|
||||
{
|
||||
if(e.getPlayer().getWorld().equals(world))
|
||||
{
|
||||
onPlayerLeft(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(PlayerJoinEvent e)
|
||||
{
|
||||
if(e.getPlayer().getWorld().equals(world))
|
||||
{
|
||||
onPlayerJoin(e.getPlayer());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(ChunkLoadEvent e)
|
||||
{
|
||||
if(e.getWorld().equals(world))
|
||||
{
|
||||
onChunkLoaded(e.getChunk());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(ChunkUnloadEvent e)
|
||||
{
|
||||
if(e.getWorld().equals(world))
|
||||
{
|
||||
onChunkUnloaded(e.getChunk());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void on(WorldUnloadEvent e)
|
||||
{
|
||||
if(world != null && e.getWorld().equals(world))
|
||||
{
|
||||
close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void close()
|
||||
{
|
||||
HandlerList.unregisterAll(this);
|
||||
Bukkit.getScheduler().cancelTask(getTask());
|
||||
onClose();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSpawn(World world, int x, int z)
|
||||
{
|
||||
return super.canSpawn(world, x, z);
|
||||
}
|
||||
|
||||
protected ChunkData generateChunkDataFailure(World world, Random no, int x, int z, BiomeGrid biomeGrid)
|
||||
{
|
||||
ChunkData c = Bukkit.createChunkData(world);
|
||||
|
||||
for(int i = 0; i < 16; i++)
|
||||
{
|
||||
for(int j = 0; j < 16; j++)
|
||||
{
|
||||
int h = 0;
|
||||
|
||||
if(j == i || j + i == 16)
|
||||
{
|
||||
c.setBlock(i, h, j, BlockDataTools.getBlockData("RED_TERRACOTTA"));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
c.setBlock(i, h, j, BlockDataTools.getBlockData("BLACK_TERRACOTTA"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChunkData generateChunkData(World world, Random no, int x, int z, BiomeGrid biomeGrid)
|
||||
{
|
||||
PrecisionStopwatch sx = PrecisionStopwatch.start();
|
||||
|
||||
if(failing)
|
||||
{
|
||||
return generateChunkDataFailure(world, no, x, z, biomeGrid);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if(pushLatch.flip())
|
||||
{
|
||||
if(this.world == null)
|
||||
{
|
||||
this.world = world;
|
||||
}
|
||||
|
||||
Iris.hotloader.check();
|
||||
|
||||
if(this instanceof IrisContext)
|
||||
{
|
||||
IrisContext.pushContext((IrisContext) this);
|
||||
}
|
||||
}
|
||||
|
||||
PrecisionStopwatch s = PrecisionStopwatch.start();
|
||||
RNG random = new RNG(world.getSeed());
|
||||
init(world, random.nextParallelRNG(0));
|
||||
ChunkData c = Bukkit.createChunkData(world);
|
||||
onGenerate(random, x, z, c, biomeGrid);
|
||||
metrics.getTotal().put(s.getMilliseconds());
|
||||
generated++;
|
||||
long hits = CNG.hits;
|
||||
CNG.hits = 0;
|
||||
Iris.instance.hit(hits);
|
||||
metrics.getLoss().put(sx.getMilliseconds() - s.getMilliseconds());
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
{
|
||||
failing = true;
|
||||
Iris.error("ERROR! Failed to generate chunk! Iris has entered a failed state!");
|
||||
|
||||
for(Player i : world.getPlayers())
|
||||
{
|
||||
Iris.instance.imsg(i, ChatColor.DARK_RED + "Iris Generator has entered a failed state!");
|
||||
Iris.instance.imsg(i, ChatColor.RED + "- Check the console for the error.");
|
||||
Iris.instance.imsg(i, ChatColor.RED + "- Then simply run /iris dev");
|
||||
}
|
||||
|
||||
L.ex(e);
|
||||
onFailure(e);
|
||||
}
|
||||
|
||||
return generateChunkDataFailure(world, no, x, z, biomeGrid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||
{
|
||||
return super.getDefaultPopulators(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getFixedSpawnLocation(World world, Random random)
|
||||
{
|
||||
return super.getFixedSpawnLocation(world, random);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParallelCapable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.object.IrisDimension;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class DimensionChunkGenerator extends ContextualChunkGenerator
|
||||
{
|
||||
protected final String dimensionName;
|
||||
|
||||
public DimensionChunkGenerator(String dimensionName)
|
||||
{
|
||||
super();
|
||||
this.dimensionName = dimensionName;
|
||||
}
|
||||
|
||||
public IrisDimension getDimension()
|
||||
{
|
||||
IrisDimension d = Iris.data.getDimensionLoader().load(dimensionName);
|
||||
|
||||
if(d == null)
|
||||
{
|
||||
Iris.error("Can't find dimension: " + dimensionName);
|
||||
}
|
||||
|
||||
return d;
|
||||
}
|
||||
|
||||
public double getModifiedX(int rx, int rz)
|
||||
{
|
||||
return (getDimension().cosRotate() * rx) + (-getDimension().sinRotate() * rz) + getDimension().getCoordFracture(masterRandom, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz);
|
||||
}
|
||||
|
||||
public double getModifiedZ(int rx, int rz)
|
||||
{
|
||||
return (getDimension().sinRotate() * rx) + (getDimension().cosRotate() * rz) + getDimension().getCoordFracture(masterRandom, 39392).fitDoubleD(-getDimension().getCoordFractureDistance() / 2, getDimension().getCoordFractureDistance() / 2, rx, rz);
|
||||
}
|
||||
|
||||
public double getZoomed(double modified)
|
||||
{
|
||||
return (double) (modified) / getDimension().getTerrainZoom();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.IrisContext;
|
||||
import ninja.bytecode.iris.object.IrisRegion;
|
||||
import ninja.bytecode.iris.util.BiomeResult;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class IrisGenerator extends ParallaxChunkGenerator implements IrisContext
|
||||
{
|
||||
public IrisGenerator(String dimensionName, int threads)
|
||||
{
|
||||
super(dimensionName, threads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeResult getBiome(int x, int z)
|
||||
{
|
||||
return sampleBiome(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IrisRegion getRegion(int x, int z)
|
||||
{
|
||||
return sampleRegion(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight(int x, int z)
|
||||
{
|
||||
return sampleHeight(x, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onTick(int ticks)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClose()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFailure(Throwable e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChunkLoaded(Chunk c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onChunkUnloaded(Chunk c)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPlayerJoin(Player p)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPlayerLeft(Player p)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.util.HeightMap;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class ParallaxChunkGenerator extends TerrainChunkGenerator
|
||||
{
|
||||
public ParallaxChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
super(dimensionName, threads);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import org.bukkit.World;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.Iris;
|
||||
import ninja.bytecode.iris.object.atomics.AtomicSliver;
|
||||
import ninja.bytecode.iris.object.atomics.AtomicSliverMap;
|
||||
import ninja.bytecode.iris.util.GroupedExecutor;
|
||||
import ninja.bytecode.iris.util.HeightMap;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class ParallelChunkGenerator extends BiomeChunkGenerator
|
||||
{
|
||||
private GroupedExecutor tx;
|
||||
private int threads;
|
||||
|
||||
public ParallelChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
super(dimensionName);
|
||||
this.threads = threads;
|
||||
}
|
||||
|
||||
public void changeThreadCount(int tc)
|
||||
{
|
||||
threads = tc;
|
||||
GroupedExecutor e = tx;
|
||||
tx = new GroupedExecutor(threads, Thread.NORM_PRIORITY, "Iris Generator - " + world.getName());
|
||||
Iris.executors.add(tx);
|
||||
|
||||
if(e != null)
|
||||
{
|
||||
e.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void onGenerateColumn(int cx, int cz, int wx, int wz, int x, int z, AtomicSliver sliver);
|
||||
|
||||
protected abstract int onSampleColumnHeight(int cx, int cz, int wx, int wz, int x, int z);
|
||||
|
||||
protected abstract void onPostGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid, HeightMap height);
|
||||
|
||||
protected int sampleHeight(int x, int z)
|
||||
{
|
||||
return onSampleColumnHeight(x >> 4, z >> 4, x, z, x & 15, z & 15);
|
||||
}
|
||||
|
||||
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
|
||||
{
|
||||
AtomicSliverMap map = new AtomicSliverMap();
|
||||
HeightMap height = new HeightMap();
|
||||
String key = "c" + x + "," + z;
|
||||
int ii, jj;
|
||||
|
||||
for(ii = 0; ii < 16; ii++)
|
||||
{
|
||||
int i = ii;
|
||||
int wx = (x * 16) + i;
|
||||
|
||||
for(jj = 0; jj < 16; jj++)
|
||||
{
|
||||
int j = jj;
|
||||
int wz = (z * 16) + j;
|
||||
AtomicSliver sliver = map.getSliver(i, j);
|
||||
|
||||
tx.queue(key, () ->
|
||||
{
|
||||
onGenerateColumn(x, z, wx, wz, i, j, sliver);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
tx.waitFor(key);
|
||||
map.write(data, grid, height);
|
||||
onPostGenerate(random, x, z, data, grid, height);
|
||||
}
|
||||
|
||||
public void onInit(World world, RNG rng)
|
||||
{
|
||||
super.onInit(world, rng);
|
||||
changeThreadCount(threads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isParallelCapable()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package ninja.bytecode.iris.generator;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import ninja.bytecode.iris.object.IrisBiome;
|
||||
import ninja.bytecode.iris.object.IrisRegion;
|
||||
import ninja.bytecode.iris.object.atomics.AtomicSliver;
|
||||
import ninja.bytecode.iris.util.BiomeResult;
|
||||
import ninja.bytecode.iris.util.CNG;
|
||||
import ninja.bytecode.iris.util.RNG;
|
||||
import ninja.bytecode.shuriken.collections.KList;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public abstract class TerrainChunkGenerator extends ParallelChunkGenerator
|
||||
{
|
||||
protected static final BlockData STONE = Material.STONE.createBlockData();
|
||||
protected static final BlockData WATER = Material.WATER.createBlockData();
|
||||
protected CNG terrainNoise;
|
||||
|
||||
public TerrainChunkGenerator(String dimensionName, int threads)
|
||||
{
|
||||
super(dimensionName, threads);
|
||||
}
|
||||
|
||||
public void onInit(World world, RNG rng)
|
||||
{
|
||||
super.onInit(world, rng);
|
||||
terrainNoise = CNG.signature(masterRandom.nextParallelRNG(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onGenerateColumn(int cx, int cz, int rx, int rz, int x, int z, AtomicSliver sliver)
|
||||
{
|
||||
BlockData block;
|
||||
int fluidHeight = getDimension().getFluidHeight();
|
||||
double ox = getModifiedX(rx, rz);
|
||||
double oz = getModifiedZ(rx, rz);
|
||||
double wx = getZoomed(ox);
|
||||
double wz = getZoomed(oz);
|
||||
int depth = 0;
|
||||
IrisRegion region = glBiome.getRegion(wx, wz);
|
||||
BiomeResult biomeResult = glBiome.generateRegionData(wx, wz, region);
|
||||
IrisBiome biome = biomeResult.getBiome();
|
||||
double lo = interpolateHeight(ox, oz, (b) -> b.getLowHeight());
|
||||
double hi = interpolateSurface(ox, oz, (b) -> b.getHighHeight());
|
||||
double noise = lo + (terrainNoise.fitDoubleD(0, hi - lo, wx, wz));
|
||||
int height = (int) Math.round(noise) + fluidHeight;
|
||||
|
||||
if(height < fluidHeight + 1)
|
||||
{
|
||||
if(biome.isLand())
|
||||
{
|
||||
biome = glBiome.generateShoreData(wx, wz, region).getBiome();
|
||||
}
|
||||
}
|
||||
|
||||
KList<BlockData> layers = biome.generateLayers(wx, wz, masterRandom, height);
|
||||
|
||||
for(int k = Math.max(height, fluidHeight); k >= 0; k--)
|
||||
{
|
||||
boolean underwater = k > height && k <= fluidHeight;
|
||||
sliver.set(k, biome.getDerivative());
|
||||
|
||||
if(underwater)
|
||||
{
|
||||
block = WATER;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
block = layers.hasIndex(depth) ? layers.get(depth) : STONE;
|
||||
depth++;
|
||||
}
|
||||
|
||||
sliver.set(k, block);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int onSampleColumnHeight(int cx, int cz, int rx, int rz, int x, int z)
|
||||
{
|
||||
int fluidHeight = getDimension().getFluidHeight();
|
||||
double ox = getModifiedX(rx, rz);
|
||||
double oz = getModifiedZ(rx, rz);
|
||||
double lo = interpolateHeight(ox, oz, (b) -> b.getLowHeight());
|
||||
double hi = interpolateSurface(ox, oz, (b) -> b.getHighHeight());
|
||||
double noise = lo + (terrainNoise.fitDoubleD(0, hi - lo, getZoomed(ox), getZoomed(oz)));
|
||||
|
||||
return (int) Math.round(noise) + fluidHeight;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user