Massive biome improvements

This commit is contained in:
Daniel Mills
2020-01-18 07:16:33 -05:00
parent 596c3368e0
commit 1b9c7d48e4
11 changed files with 484 additions and 98 deletions

View File

@@ -8,6 +8,7 @@ import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import net.minecraft.server.v1_12_R1.CriterionTriggerBredAnimals.b;
import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.controller.PackController;
import ninja.bytecode.iris.generator.genobject.GenObjectDecorator;
@@ -23,6 +24,7 @@ import ninja.bytecode.iris.pack.CompiledDimension;
import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.pack.IrisRegion;
import ninja.bytecode.iris.util.AtomicChunkData;
import ninja.bytecode.iris.util.BiomeLayer;
import ninja.bytecode.iris.util.ChunkPlan;
import ninja.bytecode.iris.util.IrisInterpolation;
import ninja.bytecode.iris.util.MB;
@@ -126,13 +128,6 @@ public class IrisGenerator extends ParallelChunkGenerator
}
}
}
int m = 0;
for(IrisBiome i : getDimension().getBiomes())
{
i.seal(getRTerrain().nextParallelRNG(3922 - m++));
}
}
@Override
@@ -149,8 +144,10 @@ public class IrisGenerator extends ParallelChunkGenerator
int height = computeHeight(wxx, wzx, new ChunkPlan(), biome);
IrisBiome nbiome = height < 63 ? getOcean(real, height) : biome;
biome = nbiome;
int beach = 65;
biome = height > 61 && height < 65 ? frozen ? biome : getBeach(real) : biome;
biome = height > 63 && biome.getType().equals(BiomeType.FLUID) ? getBeach(real) : biome;
biome = height >= beach && !biome.getType().equals(BiomeType.LAND) ? real : biome;
return biome;
}
@@ -247,7 +244,7 @@ public class IrisGenerator extends ParallelChunkGenerator
boolean frozen = r != null && r.isFrozen();
int height = computeHeight(wxx, wzx, plan, biome);
int max = Math.max(height, seaLevel);
for(int i = 0; i < max; i++)
{
MB mb = ROCK.get(scatterInt(wzx, i, wxx, ROCK.size()));

View File

@@ -1,7 +1,11 @@
package ninja.bytecode.iris.generator.genobject;
import java.lang.Thread.State;
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;
@@ -23,6 +27,7 @@ import ninja.bytecode.iris.util.IPlacer;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.collections.GSet;
import ninja.bytecode.shuriken.execution.ChronoLatch;
import ninja.bytecode.shuriken.execution.J;
import ninja.bytecode.shuriken.logging.L;
import ninja.bytecode.shuriken.math.M;
@@ -30,6 +35,7 @@ public class GenObjectDecorator extends BlockPopulator
{
private GMap<IrisBiome, GMap<GenObjectGroup, Double>> populationCache;
private IPlacer placer;
private Executor ex;
private IrisGenerator g;
private ChronoLatch cl = new ChronoLatch(250);
@@ -37,6 +43,7 @@ public class GenObjectDecorator extends BlockPopulator
{
this.g = generator;
populationCache = new GMap<>();
ex = Executors.newSingleThreadExecutor();
for(IrisBiome i : generator.getDimension().getBiomes())
{
@@ -70,15 +77,15 @@ public class GenObjectDecorator extends BlockPopulator
}
}
}
L.i("Population Cache is " + populationCache.size());
}
@Override
public void populate(World world, Random rnotusingyou, Chunk source)
{
try
{
ex.execute(() -> {
Random random = new Random(((source.getX() - 32) * (source.getZ() + 54)) + world.getSeed());
Iris.getController(TimingsController.class).started("decor");
GSet<IrisBiome> hits = new GSet<>();
for(int i = 0; i < Iris.settings.performance.decorationAccuracy; i++)
@@ -100,21 +107,15 @@ public class GenObjectDecorator extends BlockPopulator
}
hits.add(biome);
populate(world, random, source, biome, objects);
}
Iris.getController(TimingsController.class).stopped("decor");
}
catch(Throwable e)
{
}
if(Iris.settings.performance.verbose)
{
L.flush();
}
if(Iris.settings.performance.verbose)
{
L.flush();
}
});
}
private void populate(World world, Random random, Chunk source, IrisBiome biome, GMap<GenObjectGroup, Double> objects)
@@ -149,12 +150,15 @@ public class GenObjectDecorator extends BlockPopulator
}
GenObject g = i.getSchematics().get(random.nextInt(i.getSchematics().size()));
Location start = g.place(x, b.getY(), z, placer);
if(start != null && Iris.settings.performance.verbose)
Bukkit.getScheduler().scheduleSyncDelayedTask(Iris.instance, () ->
{
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()));
}
Location start = g.place(x, b.getY(), z, placer);
if(start != null && 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()));
}
});
}
}
}

View File

@@ -9,8 +9,8 @@ import ninja.bytecode.iris.Iris;
import ninja.bytecode.iris.generator.IrisGenerator;
import ninja.bytecode.iris.pack.IrisBiome;
import ninja.bytecode.iris.pack.IrisRegion;
import ninja.bytecode.iris.util.BiomeLayer;
import ninja.bytecode.iris.util.GenLayer;
import ninja.bytecode.iris.util.PolygonGenerator.EnumPolygonGenerator;
import ninja.bytecode.shuriken.collections.GList;
import ninja.bytecode.shuriken.collections.GMap;
import ninja.bytecode.shuriken.math.CNG;
@@ -19,11 +19,11 @@ import ninja.bytecode.shuriken.math.RNG;
public class GenLayerBiome extends GenLayer
{
private EnumPolygonGenerator<IrisRegion> regionGenerator;
private GMap<String, IrisRegion> regions;
private Function<CNG, CNG> factory;
private CNG fracture;
private CNG island;
private BiomeLayer master;
public GenLayerBiome(IrisGenerator iris, World world, Random random, RNG rng, GList<IrisBiome> biomes)
{
@@ -31,12 +31,16 @@ public class GenLayerBiome extends GenLayer
//@builder
island = new CNG(rng.nextParallelRNG(10334), 1D, 1)
.scale(0.003 * Iris.settings.gen.landScale)
.fractureWith(new CNG(rng.nextParallelRNG(1211), 1D, 1).scale(0.0001 * Iris.settings.gen.landScale), 600);
.fractureWith(new CNG(rng.nextParallelRNG(1211), 1D, 1)
.scale(0.001 * Iris.settings.gen.landScale), 600);
fracture = new CNG(rng.nextParallelRNG(28), 1D, 4).scale(0.0021)
.fractureWith(new CNG(rng.nextParallelRNG(34), 1D, 2)
.scale(0.01), 12250);
factory = (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(29), 1D, 4)
.scale(0.02), 56);
factory = (g) -> g.fractureWith(new CNG(rng.nextParallelRNG(29), 1D, 3)
.scale(0.005 * Iris.settings.gen.biomeScale), 1024D / Iris.settings.gen.biomeScale)
.fractureWith(new CNG(rng.nextParallelRNG(1212), 1D, 2)
.scale(0.04)
.fractureWith(new CNG(rng.nextParallelRNG(1216), 1D, 3).scale(0.0004), 266), 66);
//@done
regions = new GMap<>();
@@ -60,13 +64,18 @@ public class GenLayerBiome extends GenLayer
i.load();
}
int v = 85034;
regionGenerator = new EnumPolygonGenerator<IrisRegion>(rng.nextParallelRNG(v), 0.00522 * Iris.settings.gen.biomeScale * 0.189, 1, regions.v().toArray(new IrisRegion[regions.v().size()]), factory);
int m = 0;
for(IrisRegion i : regions.v())
for(IrisBiome i : iris.getDimension().getBiomes())
{
v += 13 - i.getName().length();
i.setGen(new EnumPolygonGenerator<IrisBiome>(rng.nextParallelRNG(33 + v), 0.000255 * i.getBiomes().size() * Iris.settings.gen.biomeScale, 1, i.getBiomes().toArray(new IrisBiome[i.getBiomes().size()]), factory));
i.seal(iris.getRTerrain().nextParallelRNG(3922 - m++));
}
master = BiomeLayer.compile(iris, 0.082 * Iris.settings.gen.biomeScale * 0.189, 1, factory);
if(Iris.settings.performance.verbose)
{
master.print(2);
}
}
@@ -117,11 +126,6 @@ public class GenLayerBiome extends GenLayer
return hasHeightBorder(6, range, wx, wz);
}
public EnumPolygonGenerator<IrisBiome> getRegionGenerator(double xx, double zz)
{
return regionGenerator.getChoice(xx, zz).getGen();
}
public IrisBiome getBiome(double wxx, double wzx)
{
return getBiome(wxx, wzx, false);
@@ -136,7 +140,7 @@ public class GenLayerBiome extends GenLayer
if(real)
{
return getRegionGenerator(x, z).getChoice(x, z);
return master.computeBiome(x, z);
}
IrisBiome cbi = iris.biome("Ocean");
@@ -145,7 +149,7 @@ public class GenLayerBiome extends GenLayer
if(land > landChance)
{
cbi = getRegionGenerator(x, z).getChoice(x, z);
cbi = master.computeBiome(x, z);
}
else if(land < 0.1)

View File

@@ -48,19 +48,21 @@ public class NMSPlacer extends Placer
public void flush()
{
for(Chunk i : c)
{
NMP.host.relight(i);
J.a(() ->
J.attempt(() -> {
for(Chunk i : c)
{
for(Player j : i.getWorld().getPlayers())
{
NMP.CHUNK.refreshIgnorePosition(j, i);
}
});
}
NMP.host.relight(i);
c.clear();
J.a(() ->
{
for(Player j : i.getWorld().getPlayers())
{
NMP.CHUNK.refreshIgnorePosition(j, i);
}
});
}
c.clear();
});
}
}