This commit is contained in:
Daniel Mills
2020-08-15 23:07:39 -04:00
parent da79b4e2ea
commit 86be84b015
10 changed files with 1162 additions and 641 deletions

View File

@@ -25,7 +25,8 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
{
protected IrisLock regLock;
private KMap<String, IrisGenerator> generators;
private KMap<String, IrisGenerator> ceilingGenerators;
@@ -33,14 +34,16 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
protected CNG masterFracture;
protected ChronoLatch cwarn = new ChronoLatch(1000);
public BiomeChunkGenerator(String dimensionName) {
public BiomeChunkGenerator(String dimensionName)
{
super(dimensionName);
generators = new KMap<>();
ceilingGenerators = new KMap<>();
regLock = new IrisLock("BiomeChunkGenerator");
}
public void onInit(World world, RNG rng) {
public void onInit(World world, RNG rng)
{
super.onInit(world, rng);
loadGenerators();
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
@@ -48,17 +51,20 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
}
@Override
public void onHotload() {
public void onHotload()
{
super.onHotload();
loadGenerators();
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
}
public void registerGenerator(IrisGenerator g, IrisDimension dim) {
public void registerGenerator(IrisGenerator g, IrisDimension dim)
{
KMap<String, IrisGenerator> generators = dim.isInverted() ? ceilingGenerators : this.generators;
regLock.lock();
if (g.getLoadKey() == null || generators.containsKey(g.getLoadKey())) {
if(g.getLoadKey() == null || generators.containsKey(g.getLoadKey()))
{
regLock.unlock();
return;
}
@@ -67,83 +73,100 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
generators.put(g.getLoadKey(), g);
}
protected KMap<String, IrisGenerator> getGenerators() {
protected KMap<String, IrisGenerator> getGenerators()
{
return getDimension().isInverted() ? ceilingGenerators : generators;
}
protected double getBiomeHeight(double rx, double rz, int x, int z) {
protected double getBiomeHeight(double rx, double rz, int x, int z)
{
double h = 0;
for (IrisGenerator i : getGenerators().values()) {
for(IrisGenerator i : getGenerators().values())
{
h += interpolateGenerator(rx, rz, i);
}
return h;
}
protected double interpolateGenerator(double rx, double rz, IrisGenerator gen) {
double hi = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx),
(int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) -> {
try {
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
for (IrisBiomeGeneratorLink i : b.getGenerators()) {
if (i.getGenerator().equals(gen.getLoadKey())) {
return i.getMax();
}
}
protected double interpolateGenerator(double rx, double rz, IrisGenerator gen)
{
double hi = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) ->
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
for(IrisBiomeGeneratorLink i : b.getGenerators())
{
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMax();
}
}
catch (Throwable e) {
Iris.warn("Failed to sample biome at " + rx + " " + rz + " using the generator "
+ gen.getLoadKey());
}
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample hi biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
}
return 0;
});
double lo = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx), (int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) ->
{
try
{
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
for(IrisBiomeGeneratorLink i : b.getGenerators())
{
if(i.getGenerator().equals(gen.getLoadKey()))
{
return i.getMin();
}
return 0;
});
}
}
double lo = IrisInterpolation.getNoise(gen.getInterpolationFunction(), (int) Math.round(rx),
(int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) -> {
try {
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
catch(Throwable e)
{
e.printStackTrace();
Iris.warn("Failed to sample lo biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
}
for (IrisBiomeGeneratorLink i : b.getGenerators()) {
if (i.getGenerator().equals(gen.getLoadKey())) {
return i.getMin();
}
}
}
catch (Throwable e) {
Iris.warn("Failed to sample biome at " + rx + " " + rz + " using the generator "
+ gen.getLoadKey());
}
return 0;
});
return 0;
});
return M.lerp(lo, hi, gen.getHeight(rx, rz, world.getSeed() + 239945));
}
protected void loadGenerators() {
protected void loadGenerators()
{
generators.clear();
ceilingGenerators.clear();
loadGenerators(((CeilingChunkGenerator) this).getFloorDimension());
loadGenerators(((CeilingChunkGenerator) this).getCeilingDimension());
}
protected void loadGenerators(IrisDimension dim) {
if (dim == null) {
protected void loadGenerators(IrisDimension dim)
{
if(dim == null)
{
return;
}
KList<String> touch = new KList<>();
KList<String> loadQueue = new KList<>();
for (String i : dim.getRegions()) {
for(String i : dim.getRegions())
{
IrisRegion r = loadRegion(i);
if (r != null) {
if(r != null)
{
loadQueue.addAll(r.getLandBiomes());
loadQueue.addAll(r.getSeaBiomes());
loadQueue.addAll(r.getShoreBiomes());
@@ -152,10 +175,12 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
}
}
while (!loadQueue.isEmpty()) {
while(!loadQueue.isEmpty())
{
String next = loadQueue.pop();
if (!touch.contains(next)) {
if(!touch.contains(next))
{
touch.add(next);
IrisBiome biome = loadBiome(next);
biome.getGenerators().forEach((i) -> registerGenerator(i.getCachedGenerator(this), dim));
@@ -164,32 +189,40 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
}
}
public IrisRegion sampleRegion(int x, int z) {
public IrisRegion sampleRegion(int x, int z)
{
double wx = getModifiedX(x, z);
double wz = getModifiedZ(x, z);
return glBiome.getRegion(wx, wz);
}
public BiomeResult sampleBiome(int x, int z) {
return getCache().getRawBiome(x, z, () -> {
if (!getDimension().getFocus().equals("")) {
public BiomeResult sampleBiome(int x, int z)
{
return getCache().getRawBiome(x, z, () ->
{
if(!getDimension().getFocus().equals(""))
{
IrisBiome biome = loadBiome(getDimension().getFocus());
for (String i : getDimension().getRegions()) {
for(String i : getDimension().getRegions())
{
IrisRegion reg = loadRegion(i);
if (reg.getLandBiomes().contains(biome.getLoadKey())) {
if(reg.getLandBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.LAND);
break;
}
if (reg.getSeaBiomes().contains(biome.getLoadKey())) {
if(reg.getSeaBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.SEA);
break;
}
if (reg.getShoreBiomes().contains(biome.getLoadKey())) {
if(reg.getShoreBiomes().contains(biome.getLoadKey()))
{
biome.setInferredType(InferredType.SHORE);
break;
}

View File

@@ -46,7 +46,8 @@ import net.md_5.bungee.api.ChatColor;
@Data
@EqualsAndHashCode(callSuper = false)
public abstract class ContextualChunkGenerator extends ChunkGenerator implements Listener {
public abstract class ContextualChunkGenerator extends ChunkGenerator implements Listener
{
private AtomicMulticache cache;
private IrisDataManager data;
protected boolean failing;
@@ -65,8 +66,10 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
protected long hlast;
private boolean fastPregen = false;
protected boolean pregenDone;
private volatile boolean hotloadable = false;
public ContextualChunkGenerator() {
public ContextualChunkGenerator()
{
pushLatch = new ChronoLatch(3000);
tickLatch = new ChronoLatch(650);
perSecond = new ChronoLatch(1000);
@@ -101,57 +104,72 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
protected abstract void onPlayerLeft(Player p);
public IrisRegion loadRegion(String i) {
public IrisRegion loadRegion(String i)
{
return getData().getRegionLoader().load(i);
}
public IrisBiome loadBiome(String i) {
public IrisBiome loadBiome(String i)
{
return getData().getBiomeLoader().load(i);
}
public IrisStructure loadStructure(String i) {
public IrisStructure loadStructure(String i)
{
return getData().getStructureLoader().load(i);
}
public IrisObject loadObject(String i) {
public IrisObject loadObject(String i)
{
return getData().getObjectLoader().load(i);
}
public IrisDimension loadDimension(String i) {
public IrisDimension loadDimension(String i)
{
return (getData() == null ? Iris.globaldata : getData()).getDimensionLoader().load(i);
}
public IrisGenerator loadGenerator(String i) {
public IrisGenerator loadGenerator(String i)
{
return getData().getGeneratorLoader().load(i);
}
public IrisDataManager getData() {
public IrisDataManager getData()
{
return isDev() ? Iris.globaldata : data;
}
private void init(World world, RNG rng) {
if (initialized) {
private void init(World world, RNG rng)
{
if(initialized)
{
return;
}
data = new IrisDataManager(getWorld().getWorldFolder());
this.world = world;
data = new IrisDataManager(getWorld().getWorldFolder());
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);
setHotloadable(true);
}
private void tick() {
if (dev) {
if (perSecond.flip()) {
if (generated > (fastPregen ? 1950 : 770)) {
private void tick()
{
if(dev)
{
if(perSecond.flip())
{
if(generated > (fastPregen ? 1950 : 770))
{
pregenDone = true;
}
if (pregenDone) {
if(pregenDone)
{
metrics.getPerSecond().put(generated);
generated = 0;
}
@@ -160,7 +178,8 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
}
}
else {
else
{
pregenDone = true;
fastPregen = false;
}
@@ -169,80 +188,100 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
}
@EventHandler
public void on(PlayerTeleportEvent e) {
if (e.getFrom().getWorld().equals(world) && !e.getTo().getWorld().equals(world)) {
public void on(PlayerTeleportEvent e)
{
if(e.getFrom().getWorld().equals(world) && !e.getTo().getWorld().equals(world))
{
tick();
onPlayerLeft(e.getPlayer());
}
if (!e.getFrom().getWorld().equals(world) && e.getTo().getWorld().equals(world)) {
if(!e.getFrom().getWorld().equals(world) && e.getTo().getWorld().equals(world))
{
tick();
onPlayerJoin(e.getPlayer());
}
}
@EventHandler
public void on(PlayerQuitEvent e) {
if (e.getPlayer().getWorld().equals(world)) {
public void on(PlayerQuitEvent e)
{
if(e.getPlayer().getWorld().equals(world))
{
tick();
onPlayerLeft(e.getPlayer());
}
}
@EventHandler
public void on(PlayerJoinEvent e) {
if (e.getPlayer().getWorld().equals(world)) {
public void on(PlayerJoinEvent e)
{
if(e.getPlayer().getWorld().equals(world))
{
tick();
onPlayerJoin(e.getPlayer());
}
}
@EventHandler
public void on(ChunkLoadEvent e) {
if (e.getWorld().equals(world)) {
public void on(ChunkLoadEvent e)
{
if(e.getWorld().equals(world))
{
tick();
onChunkLoaded(e.getChunk());
}
}
@EventHandler
public void on(ChunkUnloadEvent e) {
if (e.getWorld().equals(world)) {
public void on(ChunkUnloadEvent e)
{
if(e.getWorld().equals(world))
{
tick();
onChunkUnloaded(e.getChunk());
}
}
@EventHandler
public void on(WorldUnloadEvent e) {
if (world != null && e.getWorld().equals(world)) {
public void on(WorldUnloadEvent e)
{
if(world != null && e.getWorld().equals(world))
{
close();
}
}
public void close() {
public void close()
{
HandlerList.unregisterAll(this);
Bukkit.getScheduler().cancelTask(getTask());
onClose();
}
@Override
public boolean canSpawn(World world, int x, int z) {
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) {
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++) {
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < 16; j++)
{
int h = 0;
if (j == i || j + i == 16) {
if(j == i || j + i == 16)
{
c.setBlock(i, h, j, B.getBlockData("RED_TERRACOTTA"));
}
else {
else
{
c.setBlock(i, h, j, B.getBlockData("BLACK_TERRACOTTA"));
}
}
@@ -251,18 +290,23 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
return c;
}
protected ChunkData generateChunkFastPregen(World world, Random no, int x, int z, BiomeGrid biomeGrid) {
protected ChunkData generateChunkFastPregen(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++) {
for(int i = 0; i < 16; i++)
{
for(int j = 0; j < 16; j++)
{
int h = 0;
if (j == i || j + i == 16) {
if(j == i || j + i == 16)
{
c.setBlock(i, h, j, B.getBlockData("BLUE_TERRACOTTA"));
}
else {
else
{
c.setBlock(i, h, j, B.getBlockData("WHITE_TERRACOTTA"));
}
}
@@ -272,33 +316,39 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
}
@Override
public ChunkData generateChunkData(World world, Random no, int x, int z, BiomeGrid biomeGrid) {
public ChunkData generateChunkData(World world, Random no, int x, int z, BiomeGrid biomeGrid)
{
hlock.lock();
if (!dev) {
setHotloadable(false);
if(!dev)
{
pregenDone = true;
fastPregen = false;
}
PrecisionStopwatch sx = PrecisionStopwatch.start();
if (failing) {
if(failing)
{
hlock.unlock();
return generateChunkDataFailure(world, no, x, z, biomeGrid);
}
try {
checkHotload(world);
try
{
PrecisionStopwatch s = PrecisionStopwatch.start();
RNG random = new RNG(world.getSeed());
init(world, random.nextParallelRNG(0));
ChunkData c = Bukkit.createChunkData(world);
if (!pregenDone && fastPregen) {
if(!pregenDone && fastPregen)
{
c = generateChunkFastPregen(world, no, x, z, biomeGrid);
}
else {
else
{
onGenerate(random, x, z, c, biomeGrid);
}
@@ -308,69 +358,85 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
CNG.hits = 0;
Iris.instance.hit(hits);
metrics.getLoss().put(sx.getMilliseconds() - s.getMilliseconds());
setHotloadable(true);
hlock.unlock();
return c;
}
catch (Throwable e) {
catch(Throwable e)
{
fail(e);
}
setHotloadable(true);
hlock.unlock();
return generateChunkDataFailure(world, no, x, z, biomeGrid);
}
public void checkHotload() {
if (M.ms() - hlast < 1000) {
public void checkHotload()
{
if(M.ms() - hlast < 1000)
{
return;
}
hlock.lock();
if (world != null) {
if(world != null)
{
checkHotload(world);
}
hlock.unlock();
}
private void checkHotload(World world) {
if (pushLatch.flip()) {
private void checkHotload(World world)
{
if(!isHotloadable())
{
return;
}
if (this.world == null) {
if(pushLatch.flip())
{
if(this.world == null)
{
this.world = world;
}
Iris.hotloader.check((IrisContext) this);
if (this instanceof IrisContext) {
if(this instanceof IrisContext)
{
IrisContext.pushContext((IrisContext) this);
}
}
}
public void onHotload() {
public void onHotload()
{
hlast = M.ms();
}
protected void fail(Throwable e) {
if (failing) {
protected void fail(Throwable e)
{
if(failing)
{
return;
}
failing = true;
e.printStackTrace();
J.a(() -> {
J.a(() ->
{
J.sleep(1000);
Iris.error(
"---------------------------------------------------------------------------------------------------------");
Iris.error("---------------------------------------------------------------------------------------------------------");
e.printStackTrace();
Iris.error(
"---------------------------------------------------------------------------------------------------------");
Iris.error("---------------------------------------------------------------------------------------------------------");
Iris.error("ERROR! Failed to generate chunk! Iris has entered a failed state!");
Iris.error(
"---------------------------------------------------------------------------------------------------------");
Iris.error("---------------------------------------------------------------------------------------------------------");
for (Player i : world.getPlayers()) {
for(Player i : world.getPlayers())
{
Iris.instance.imsg(i, ChatColor.DARK_RED + "Iris Generator has crashed!");
Iris.instance.imsg(i, ChatColor.RED + "- Check the console for the error.");
Iris.instance.imsg(i, ChatColor.RED + "- To Regen, use /iris std open <dim>");
@@ -382,17 +448,20 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
}
@Override
public List<BlockPopulator> getDefaultPopulators(World world) {
public List<BlockPopulator> getDefaultPopulators(World world)
{
return super.getDefaultPopulators(world);
}
@Override
public Location getFixedSpawnLocation(World world, Random random) {
public Location getFixedSpawnLocation(World world, Random random)
{
return super.getFixedSpawnLocation(world, random);
}
@Override
public boolean isParallelCapable() {
public boolean isParallelCapable()
{
return true;
}
}

View File

@@ -4,6 +4,7 @@ import java.awt.Color;
import java.io.IOException;
import java.lang.reflect.Method;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Location;
import org.bukkit.World;
@@ -28,94 +29,114 @@ import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext {
public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext
{
private Method initLighting;
private IrisLock lock;
private IrisBiome hb = null;
private IrisRegion hr = null;
private KMap<Player, IrisBiome> b = new KMap<>();
public IrisChunkGenerator(String dimensionName, int threads) {
public IrisChunkGenerator(String dimensionName, int threads)
{
super(dimensionName, threads);
lock = new IrisLock("IrisChunkGenerator");
}
public IrisChunkGenerator(String dimensionName) {
public IrisChunkGenerator(String dimensionName)
{
super(dimensionName, 16);
lock = new IrisLock("IrisChunkGenerator");
}
public IrisChunkGenerator(int tc) {
public IrisChunkGenerator(int tc)
{
super("", tc);
lock = new IrisLock("IrisChunkGenerator");
}
public void hotload() {
public void hotload()
{
onHotload();
}
public void retry() {
if (failing) {
public void retry()
{
if(failing)
{
failing = false;
hotload();
}
}
@Override
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid) {
protected void onGenerate(RNG random, int x, int z, ChunkData data, BiomeGrid grid)
{
lock.lock();
super.onGenerate(random, x, z, data, grid);
lock.unlock();
}
public void onInit(World world, RNG rng) {
try {
public void onInit(World world, RNG rng)
{
try
{
super.onInit(world, rng);
}
catch (Throwable e) {
catch(Throwable e)
{
fail(e);
}
}
@Override
public BiomeResult getBiome(int x, int z) {
public BiomeResult getBiome(int x, int z)
{
return sampleBiome(x, z);
}
@Override
public IrisRegion getRegion(int x, int z) {
public IrisRegion getRegion(int x, int z)
{
return sampleRegion(x, z);
}
@Override
public int getHeight(int x, int z) {
public int getHeight(int x, int z)
{
return sampleHeight(x, z);
}
@Override
public void onTick(int ticks) {
public void onTick(int ticks)
{
super.onTick(ticks);
for (Player i : getWorld().getPlayers()) {
for(Player i : getWorld().getPlayers())
{
Location l = i.getLocation();
IrisRegion r = sampleRegion(l.getBlockX(), l.getBlockZ());
IrisBiome b = sampleTrueBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ()).getBiome();
for (IrisEffect j : r.getEffects()) {
for(IrisEffect j : r.getEffects())
{
j.apply(i, this);
}
for (IrisEffect j : b.getEffects()) {
for(IrisEffect j : b.getEffects())
{
j.apply(i, this);
}
}
}
@Override
protected void onClose() {
protected void onClose()
{
super.onClose();
try {
try
{
parallaxMap.saveAll();
ceilingParallaxMap.saveAll();
parallaxMap.getLoadedChunks().clear();
@@ -124,7 +145,8 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
ceilingParallaxMap.getLoadedRegions().clear();
}
catch (IOException e) {
catch(IOException e)
{
e.printStackTrace();
}
@@ -135,45 +157,61 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
}
@Override
protected void onFailure(Throwable e) {
protected void onFailure(Throwable e)
{
}
@Override
protected void onChunkLoaded(Chunk c) {
protected void onChunkLoaded(Chunk c)
{
}
@Override
protected void onChunkUnloaded(Chunk c) {
protected void onChunkUnloaded(Chunk c)
{
}
@Override
protected void onPlayerJoin(Player p) {
protected void onPlayerJoin(Player p)
{
}
@Override
public void onPlayerLeft(Player p) {
public void onPlayerLeft(Player p)
{
super.onPlayerLeft(p);
}
@Override
public void onHotloaded() {
public void onHotloaded()
{
if(!isHotloadable())
{
Iris.warn("Hotload skipped (During Chunk Gen). Retrying.");
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, this::onHotloaded);
return;
}
CNG.creates = 0;
getData().dump();
onHotload();
}
public long guessMemoryUsage() {
public long guessMemoryUsage()
{
long bytes = 1024 * 1024 * (8 + (getThreads() / 3));
for (AtomicRegionData i : parallaxMap.getLoadedRegions().values()) {
for(AtomicRegionData i : parallaxMap.getLoadedRegions().values())
{
bytes += i.guessMemoryUsage();
}
for (AtomicRegionData i : ceilingParallaxMap.getLoadedRegions().values()) {
for(AtomicRegionData i : ceilingParallaxMap.getLoadedRegions().values())
{
bytes += i.guessMemoryUsage();
}
@@ -186,34 +224,41 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
}
@Override
public boolean shouldGenerateCaves() {
public boolean shouldGenerateCaves()
{
return false;
}
@Override
public boolean shouldGenerateDecorations() {
public boolean shouldGenerateDecorations()
{
return false;
}
@Override
public boolean shouldGenerateMobs() {
public boolean shouldGenerateMobs()
{
return true;
}
@Override
public boolean shouldGenerateStructures() {
if (!isInitialized()) {
public boolean shouldGenerateStructures()
{
if(!isInitialized())
{
return false;
}
return getDimension().isVanillaStructures();
}
public Function2<Double, Double, Color> createRenderer() {
public Function2<Double, Double, Color> createRenderer()
{
return (x, z) -> render(x, z);
}
private Color render(double x, double z) {
private Color render(double x, double z)
{
int ix = (int) x;
int iz = (int) z;
double height = getTerrainHeight(ix, iz);
@@ -225,22 +270,24 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
shift -= shift2;
float sat = 0;
if (hr.getLoadKey().equals(region.getLoadKey())) {
if(hr.getLoadKey().equals(region.getLoadKey()))
{
sat += 0.2;
}
if (hb.getLoadKey().equals(biome.getLoadKey())) {
if(hb.getLoadKey().equals(biome.getLoadKey()))
{
sat += 0.3;
}
Color c = Color.getHSBColor((biome.isLand() ? 0.233f : 0.644f) - shift, 0.25f + shift + sat,
(float) (Math.max(0, Math.min(height + getFluidHeight(), 255)) / 255));
Color c = Color.getHSBColor((biome.isLand() ? 0.233f : 0.644f) - shift, 0.25f + shift + sat, (float) (Math.max(0, Math.min(height + getFluidHeight(), 255)) / 255));
return c;
}
public String textFor(double x, double z) {
public String textFor(double x, double z)
{
int ix = (int) x;
int iz = (int) z;
@@ -249,8 +296,6 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
IrisBiome biome = sampleTrueBiome(ix, iz, height).getBiome();
hb = biome;
hr = region;
return biome.getName() + " ("
+ Form.capitalizeWords(biome.getInferredType().name().toLowerCase().replaceAll("\\Q_\\E", " ") + ") in "
+ region.getName() + "\nY: " + (int) height);
return biome.getName() + " (" + Form.capitalizeWords(biome.getInferredType().name().toLowerCase().replaceAll("\\Q_\\E", " ") + ") in " + region.getName() + "\nY: " + (int) height);
}
}

View File

@@ -4,7 +4,6 @@ import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.noise.CNG;
import com.volmit.iris.object.InferredType;
import com.volmit.iris.object.IrisRegion;
import com.volmit.iris.object.NoiseStyle;
import com.volmit.iris.util.BiomeResult;
import com.volmit.iris.util.RNG;
@@ -21,7 +20,7 @@ public class BiomeDataProvider
{
this.type = type;
this.layer = layer;
generator = NoiseStyle.CELLULAR_IRIS_DOUBLE.create(rng.nextParallelRNG(4645079 + (type.ordinal() * 23845)));
generator = layer.getIris().getDimension().getBiomeStyle(type).create(rng.nextParallelRNG(4645079 + (type.ordinal() * 23845)));
}
public BiomeResult generatePureData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)