mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Fixes
This commit is contained in:
parent
da79b4e2ea
commit
86be84b015
File diff suppressed because it is too large
Load Diff
@ -25,7 +25,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
|
public abstract class BiomeChunkGenerator extends DimensionChunkGenerator
|
||||||
|
{
|
||||||
protected IrisLock regLock;
|
protected IrisLock regLock;
|
||||||
private KMap<String, IrisGenerator> generators;
|
private KMap<String, IrisGenerator> generators;
|
||||||
private KMap<String, IrisGenerator> ceilingGenerators;
|
private KMap<String, IrisGenerator> ceilingGenerators;
|
||||||
@ -33,14 +34,16 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
|
|||||||
protected CNG masterFracture;
|
protected CNG masterFracture;
|
||||||
protected ChronoLatch cwarn = new ChronoLatch(1000);
|
protected ChronoLatch cwarn = new ChronoLatch(1000);
|
||||||
|
|
||||||
public BiomeChunkGenerator(String dimensionName) {
|
public BiomeChunkGenerator(String dimensionName)
|
||||||
|
{
|
||||||
super(dimensionName);
|
super(dimensionName);
|
||||||
generators = new KMap<>();
|
generators = new KMap<>();
|
||||||
ceilingGenerators = new KMap<>();
|
ceilingGenerators = new KMap<>();
|
||||||
regLock = new IrisLock("BiomeChunkGenerator");
|
regLock = new IrisLock("BiomeChunkGenerator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInit(World world, RNG rng) {
|
public void onInit(World world, RNG rng)
|
||||||
|
{
|
||||||
super.onInit(world, rng);
|
super.onInit(world, rng);
|
||||||
loadGenerators();
|
loadGenerators();
|
||||||
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
||||||
@ -48,17 +51,20 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onHotload() {
|
public void onHotload()
|
||||||
|
{
|
||||||
super.onHotload();
|
super.onHotload();
|
||||||
loadGenerators();
|
loadGenerators();
|
||||||
glBiome = new GenLayerBiome(this, masterRandom.nextParallelRNG(1));
|
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;
|
KMap<String, IrisGenerator> generators = dim.isInverted() ? ceilingGenerators : this.generators;
|
||||||
|
|
||||||
regLock.lock();
|
regLock.lock();
|
||||||
if (g.getLoadKey() == null || generators.containsKey(g.getLoadKey())) {
|
if(g.getLoadKey() == null || generators.containsKey(g.getLoadKey()))
|
||||||
|
{
|
||||||
regLock.unlock();
|
regLock.unlock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -67,83 +73,100 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
|
|||||||
generators.put(g.getLoadKey(), g);
|
generators.put(g.getLoadKey(), g);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected KMap<String, IrisGenerator> getGenerators() {
|
protected KMap<String, IrisGenerator> getGenerators()
|
||||||
|
{
|
||||||
return getDimension().isInverted() ? ceilingGenerators : generators;
|
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;
|
double h = 0;
|
||||||
|
|
||||||
for (IrisGenerator i : getGenerators().values()) {
|
for(IrisGenerator i : getGenerators().values())
|
||||||
|
{
|
||||||
h += interpolateGenerator(rx, rz, i);
|
h += interpolateGenerator(rx, rz, i);
|
||||||
}
|
}
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected double interpolateGenerator(double rx, double rz, IrisGenerator gen) {
|
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) -> {
|
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();
|
try
|
||||||
|
{
|
||||||
for (IrisBiomeGeneratorLink i : b.getGenerators()) {
|
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
|
||||||
if (i.getGenerator().equals(gen.getLoadKey())) {
|
|
||||||
return i.getMax();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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),
|
catch(Throwable e)
|
||||||
(int) Math.round(rz), gen.getInterpolationScale(), (xx, zz) -> {
|
{
|
||||||
try {
|
e.printStackTrace();
|
||||||
IrisBiome b = sampleBiome((int) xx, (int) zz).getBiome();
|
Iris.warn("Failed to sample lo biome at " + rx + " " + rz + " using the generator " + gen.getLoadKey());
|
||||||
|
}
|
||||||
|
|
||||||
for (IrisBiomeGeneratorLink i : b.getGenerators()) {
|
return 0;
|
||||||
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 M.lerp(lo, hi, gen.getHeight(rx, rz, world.getSeed() + 239945));
|
return M.lerp(lo, hi, gen.getHeight(rx, rz, world.getSeed() + 239945));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadGenerators() {
|
protected void loadGenerators()
|
||||||
|
{
|
||||||
generators.clear();
|
generators.clear();
|
||||||
ceilingGenerators.clear();
|
ceilingGenerators.clear();
|
||||||
loadGenerators(((CeilingChunkGenerator) this).getFloorDimension());
|
loadGenerators(((CeilingChunkGenerator) this).getFloorDimension());
|
||||||
loadGenerators(((CeilingChunkGenerator) this).getCeilingDimension());
|
loadGenerators(((CeilingChunkGenerator) this).getCeilingDimension());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void loadGenerators(IrisDimension dim) {
|
protected void loadGenerators(IrisDimension dim)
|
||||||
if (dim == null) {
|
{
|
||||||
|
if(dim == null)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<String> touch = new KList<>();
|
KList<String> touch = new KList<>();
|
||||||
KList<String> loadQueue = new KList<>();
|
KList<String> loadQueue = new KList<>();
|
||||||
|
|
||||||
for (String i : dim.getRegions()) {
|
for(String i : dim.getRegions())
|
||||||
|
{
|
||||||
IrisRegion r = loadRegion(i);
|
IrisRegion r = loadRegion(i);
|
||||||
|
|
||||||
if (r != null) {
|
if(r != null)
|
||||||
|
{
|
||||||
loadQueue.addAll(r.getLandBiomes());
|
loadQueue.addAll(r.getLandBiomes());
|
||||||
loadQueue.addAll(r.getSeaBiomes());
|
loadQueue.addAll(r.getSeaBiomes());
|
||||||
loadQueue.addAll(r.getShoreBiomes());
|
loadQueue.addAll(r.getShoreBiomes());
|
||||||
@ -152,10 +175,12 @@ public abstract class BiomeChunkGenerator extends DimensionChunkGenerator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!loadQueue.isEmpty()) {
|
while(!loadQueue.isEmpty())
|
||||||
|
{
|
||||||
String next = loadQueue.pop();
|
String next = loadQueue.pop();
|
||||||
|
|
||||||
if (!touch.contains(next)) {
|
if(!touch.contains(next))
|
||||||
|
{
|
||||||
touch.add(next);
|
touch.add(next);
|
||||||
IrisBiome biome = loadBiome(next);
|
IrisBiome biome = loadBiome(next);
|
||||||
biome.getGenerators().forEach((i) -> registerGenerator(i.getCachedGenerator(this), dim));
|
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 wx = getModifiedX(x, z);
|
||||||
double wz = getModifiedZ(x, z);
|
double wz = getModifiedZ(x, z);
|
||||||
return glBiome.getRegion(wx, wz);
|
return glBiome.getRegion(wx, wz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeResult sampleBiome(int x, int z) {
|
public BiomeResult sampleBiome(int x, int z)
|
||||||
return getCache().getRawBiome(x, z, () -> {
|
{
|
||||||
if (!getDimension().getFocus().equals("")) {
|
return getCache().getRawBiome(x, z, () ->
|
||||||
|
{
|
||||||
|
if(!getDimension().getFocus().equals(""))
|
||||||
|
{
|
||||||
IrisBiome biome = loadBiome(getDimension().getFocus());
|
IrisBiome biome = loadBiome(getDimension().getFocus());
|
||||||
|
|
||||||
for (String i : getDimension().getRegions()) {
|
for(String i : getDimension().getRegions())
|
||||||
|
{
|
||||||
IrisRegion reg = loadRegion(i);
|
IrisRegion reg = loadRegion(i);
|
||||||
|
|
||||||
if (reg.getLandBiomes().contains(biome.getLoadKey())) {
|
if(reg.getLandBiomes().contains(biome.getLoadKey()))
|
||||||
|
{
|
||||||
biome.setInferredType(InferredType.LAND);
|
biome.setInferredType(InferredType.LAND);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.getSeaBiomes().contains(biome.getLoadKey())) {
|
if(reg.getSeaBiomes().contains(biome.getLoadKey()))
|
||||||
|
{
|
||||||
biome.setInferredType(InferredType.SEA);
|
biome.setInferredType(InferredType.SEA);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reg.getShoreBiomes().contains(biome.getLoadKey())) {
|
if(reg.getShoreBiomes().contains(biome.getLoadKey()))
|
||||||
|
{
|
||||||
biome.setInferredType(InferredType.SHORE);
|
biome.setInferredType(InferredType.SHORE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -46,7 +46,8 @@ import net.md_5.bungee.api.ChatColor;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public abstract class ContextualChunkGenerator extends ChunkGenerator implements Listener {
|
public abstract class ContextualChunkGenerator extends ChunkGenerator implements Listener
|
||||||
|
{
|
||||||
private AtomicMulticache cache;
|
private AtomicMulticache cache;
|
||||||
private IrisDataManager data;
|
private IrisDataManager data;
|
||||||
protected boolean failing;
|
protected boolean failing;
|
||||||
@ -65,8 +66,10 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
protected long hlast;
|
protected long hlast;
|
||||||
private boolean fastPregen = false;
|
private boolean fastPregen = false;
|
||||||
protected boolean pregenDone;
|
protected boolean pregenDone;
|
||||||
|
private volatile boolean hotloadable = false;
|
||||||
|
|
||||||
public ContextualChunkGenerator() {
|
public ContextualChunkGenerator()
|
||||||
|
{
|
||||||
pushLatch = new ChronoLatch(3000);
|
pushLatch = new ChronoLatch(3000);
|
||||||
tickLatch = new ChronoLatch(650);
|
tickLatch = new ChronoLatch(650);
|
||||||
perSecond = new ChronoLatch(1000);
|
perSecond = new ChronoLatch(1000);
|
||||||
@ -101,57 +104,72 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
|
|
||||||
protected abstract void onPlayerLeft(Player p);
|
protected abstract void onPlayerLeft(Player p);
|
||||||
|
|
||||||
public IrisRegion loadRegion(String i) {
|
public IrisRegion loadRegion(String i)
|
||||||
|
{
|
||||||
return getData().getRegionLoader().load(i);
|
return getData().getRegionLoader().load(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisBiome loadBiome(String i) {
|
public IrisBiome loadBiome(String i)
|
||||||
|
{
|
||||||
return getData().getBiomeLoader().load(i);
|
return getData().getBiomeLoader().load(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisStructure loadStructure(String i) {
|
public IrisStructure loadStructure(String i)
|
||||||
|
{
|
||||||
return getData().getStructureLoader().load(i);
|
return getData().getStructureLoader().load(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisObject loadObject(String i) {
|
public IrisObject loadObject(String i)
|
||||||
|
{
|
||||||
return getData().getObjectLoader().load(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);
|
return (getData() == null ? Iris.globaldata : getData()).getDimensionLoader().load(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisGenerator loadGenerator(String i) {
|
public IrisGenerator loadGenerator(String i)
|
||||||
|
{
|
||||||
return getData().getGeneratorLoader().load(i);
|
return getData().getGeneratorLoader().load(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisDataManager getData() {
|
public IrisDataManager getData()
|
||||||
|
{
|
||||||
return isDev() ? Iris.globaldata : data;
|
return isDev() ? Iris.globaldata : data;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void init(World world, RNG rng) {
|
private void init(World world, RNG rng)
|
||||||
if (initialized) {
|
{
|
||||||
|
if(initialized)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = new IrisDataManager(getWorld().getWorldFolder());
|
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
data = new IrisDataManager(getWorld().getWorldFolder());
|
||||||
this.masterRandom = new RNG(world.getSeed());
|
this.masterRandom = new RNG(world.getSeed());
|
||||||
metrics = new IrisMetrics(128);
|
metrics = new IrisMetrics(128);
|
||||||
initialized = true;
|
initialized = true;
|
||||||
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
|
Bukkit.getServer().getPluginManager().registerEvents(this, Iris.instance);
|
||||||
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::tick, 0, 0);
|
task = Bukkit.getScheduler().scheduleSyncRepeatingTask(Iris.instance, this::tick, 0, 0);
|
||||||
onInit(world, masterRandom);
|
onInit(world, masterRandom);
|
||||||
|
setHotloadable(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void tick() {
|
private void tick()
|
||||||
if (dev) {
|
{
|
||||||
if (perSecond.flip()) {
|
if(dev)
|
||||||
if (generated > (fastPregen ? 1950 : 770)) {
|
{
|
||||||
|
if(perSecond.flip())
|
||||||
|
{
|
||||||
|
if(generated > (fastPregen ? 1950 : 770))
|
||||||
|
{
|
||||||
pregenDone = true;
|
pregenDone = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pregenDone) {
|
if(pregenDone)
|
||||||
|
{
|
||||||
metrics.getPerSecond().put(generated);
|
metrics.getPerSecond().put(generated);
|
||||||
generated = 0;
|
generated = 0;
|
||||||
}
|
}
|
||||||
@ -160,7 +178,8 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
pregenDone = true;
|
pregenDone = true;
|
||||||
fastPregen = false;
|
fastPregen = false;
|
||||||
}
|
}
|
||||||
@ -169,80 +188,100 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(PlayerTeleportEvent e) {
|
public void on(PlayerTeleportEvent e)
|
||||||
if (e.getFrom().getWorld().equals(world) && !e.getTo().getWorld().equals(world)) {
|
{
|
||||||
|
if(e.getFrom().getWorld().equals(world) && !e.getTo().getWorld().equals(world))
|
||||||
|
{
|
||||||
tick();
|
tick();
|
||||||
onPlayerLeft(e.getPlayer());
|
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();
|
tick();
|
||||||
onPlayerJoin(e.getPlayer());
|
onPlayerJoin(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(PlayerQuitEvent e) {
|
public void on(PlayerQuitEvent e)
|
||||||
if (e.getPlayer().getWorld().equals(world)) {
|
{
|
||||||
|
if(e.getPlayer().getWorld().equals(world))
|
||||||
|
{
|
||||||
tick();
|
tick();
|
||||||
onPlayerLeft(e.getPlayer());
|
onPlayerLeft(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(PlayerJoinEvent e) {
|
public void on(PlayerJoinEvent e)
|
||||||
if (e.getPlayer().getWorld().equals(world)) {
|
{
|
||||||
|
if(e.getPlayer().getWorld().equals(world))
|
||||||
|
{
|
||||||
tick();
|
tick();
|
||||||
onPlayerJoin(e.getPlayer());
|
onPlayerJoin(e.getPlayer());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(ChunkLoadEvent e) {
|
public void on(ChunkLoadEvent e)
|
||||||
if (e.getWorld().equals(world)) {
|
{
|
||||||
|
if(e.getWorld().equals(world))
|
||||||
|
{
|
||||||
tick();
|
tick();
|
||||||
onChunkLoaded(e.getChunk());
|
onChunkLoaded(e.getChunk());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(ChunkUnloadEvent e) {
|
public void on(ChunkUnloadEvent e)
|
||||||
if (e.getWorld().equals(world)) {
|
{
|
||||||
|
if(e.getWorld().equals(world))
|
||||||
|
{
|
||||||
tick();
|
tick();
|
||||||
onChunkUnloaded(e.getChunk());
|
onChunkUnloaded(e.getChunk());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void on(WorldUnloadEvent e) {
|
public void on(WorldUnloadEvent e)
|
||||||
if (world != null && e.getWorld().equals(world)) {
|
{
|
||||||
|
if(world != null && e.getWorld().equals(world))
|
||||||
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void close() {
|
public void close()
|
||||||
|
{
|
||||||
HandlerList.unregisterAll(this);
|
HandlerList.unregisterAll(this);
|
||||||
Bukkit.getScheduler().cancelTask(getTask());
|
Bukkit.getScheduler().cancelTask(getTask());
|
||||||
onClose();
|
onClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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);
|
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);
|
ChunkData c = Bukkit.createChunkData(world);
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for(int i = 0; i < 16; i++)
|
||||||
for (int j = 0; j < 16; j++) {
|
{
|
||||||
|
for(int j = 0; j < 16; j++)
|
||||||
|
{
|
||||||
int h = 0;
|
int h = 0;
|
||||||
|
|
||||||
if (j == i || j + i == 16) {
|
if(j == i || j + i == 16)
|
||||||
|
{
|
||||||
c.setBlock(i, h, j, B.getBlockData("RED_TERRACOTTA"));
|
c.setBlock(i, h, j, B.getBlockData("RED_TERRACOTTA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
c.setBlock(i, h, j, B.getBlockData("BLACK_TERRACOTTA"));
|
c.setBlock(i, h, j, B.getBlockData("BLACK_TERRACOTTA"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -251,18 +290,23 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
return c;
|
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);
|
ChunkData c = Bukkit.createChunkData(world);
|
||||||
|
|
||||||
for (int i = 0; i < 16; i++) {
|
for(int i = 0; i < 16; i++)
|
||||||
for (int j = 0; j < 16; j++) {
|
{
|
||||||
|
for(int j = 0; j < 16; j++)
|
||||||
|
{
|
||||||
int h = 0;
|
int h = 0;
|
||||||
|
|
||||||
if (j == i || j + i == 16) {
|
if(j == i || j + i == 16)
|
||||||
|
{
|
||||||
c.setBlock(i, h, j, B.getBlockData("BLUE_TERRACOTTA"));
|
c.setBlock(i, h, j, B.getBlockData("BLUE_TERRACOTTA"));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
c.setBlock(i, h, j, B.getBlockData("WHITE_TERRACOTTA"));
|
c.setBlock(i, h, j, B.getBlockData("WHITE_TERRACOTTA"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -272,33 +316,39 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
hlock.lock();
|
||||||
if (!dev) {
|
setHotloadable(false);
|
||||||
|
if(!dev)
|
||||||
|
{
|
||||||
pregenDone = true;
|
pregenDone = true;
|
||||||
fastPregen = false;
|
fastPregen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
PrecisionStopwatch sx = PrecisionStopwatch.start();
|
PrecisionStopwatch sx = PrecisionStopwatch.start();
|
||||||
|
|
||||||
if (failing) {
|
if(failing)
|
||||||
|
{
|
||||||
hlock.unlock();
|
hlock.unlock();
|
||||||
return generateChunkDataFailure(world, no, x, z, biomeGrid);
|
return generateChunkDataFailure(world, no, x, z, biomeGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
checkHotload(world);
|
{
|
||||||
PrecisionStopwatch s = PrecisionStopwatch.start();
|
PrecisionStopwatch s = PrecisionStopwatch.start();
|
||||||
RNG random = new RNG(world.getSeed());
|
RNG random = new RNG(world.getSeed());
|
||||||
init(world, random.nextParallelRNG(0));
|
init(world, random.nextParallelRNG(0));
|
||||||
|
|
||||||
ChunkData c = Bukkit.createChunkData(world);
|
ChunkData c = Bukkit.createChunkData(world);
|
||||||
|
|
||||||
if (!pregenDone && fastPregen) {
|
if(!pregenDone && fastPregen)
|
||||||
|
{
|
||||||
c = generateChunkFastPregen(world, no, x, z, biomeGrid);
|
c = generateChunkFastPregen(world, no, x, z, biomeGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
onGenerate(random, x, z, c, biomeGrid);
|
onGenerate(random, x, z, c, biomeGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,69 +358,85 @@ public abstract class ContextualChunkGenerator extends ChunkGenerator implements
|
|||||||
CNG.hits = 0;
|
CNG.hits = 0;
|
||||||
Iris.instance.hit(hits);
|
Iris.instance.hit(hits);
|
||||||
metrics.getLoss().put(sx.getMilliseconds() - s.getMilliseconds());
|
metrics.getLoss().put(sx.getMilliseconds() - s.getMilliseconds());
|
||||||
|
setHotloadable(true);
|
||||||
hlock.unlock();
|
hlock.unlock();
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch(Throwable e)
|
||||||
|
{
|
||||||
fail(e);
|
fail(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setHotloadable(true);
|
||||||
hlock.unlock();
|
hlock.unlock();
|
||||||
return generateChunkDataFailure(world, no, x, z, biomeGrid);
|
return generateChunkDataFailure(world, no, x, z, biomeGrid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkHotload() {
|
public void checkHotload()
|
||||||
if (M.ms() - hlast < 1000) {
|
{
|
||||||
|
if(M.ms() - hlast < 1000)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hlock.lock();
|
hlock.lock();
|
||||||
if (world != null) {
|
if(world != null)
|
||||||
|
{
|
||||||
checkHotload(world);
|
checkHotload(world);
|
||||||
}
|
}
|
||||||
hlock.unlock();
|
hlock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkHotload(World world) {
|
private void checkHotload(World world)
|
||||||
if (pushLatch.flip()) {
|
{
|
||||||
|
if(!isHotloadable())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (this.world == null) {
|
if(pushLatch.flip())
|
||||||
|
{
|
||||||
|
if(this.world == null)
|
||||||
|
{
|
||||||
this.world = world;
|
this.world = world;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iris.hotloader.check((IrisContext) this);
|
Iris.hotloader.check((IrisContext) this);
|
||||||
|
|
||||||
if (this instanceof IrisContext) {
|
if(this instanceof IrisContext)
|
||||||
|
{
|
||||||
IrisContext.pushContext((IrisContext) this);
|
IrisContext.pushContext((IrisContext) this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onHotload() {
|
public void onHotload()
|
||||||
|
{
|
||||||
hlast = M.ms();
|
hlast = M.ms();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fail(Throwable e) {
|
protected void fail(Throwable e)
|
||||||
if (failing) {
|
{
|
||||||
|
if(failing)
|
||||||
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
failing = true;
|
failing = true;
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
J.a(() -> {
|
J.a(() ->
|
||||||
|
{
|
||||||
J.sleep(1000);
|
J.sleep(1000);
|
||||||
Iris.error(
|
Iris.error("---------------------------------------------------------------------------------------------------------");
|
||||||
"---------------------------------------------------------------------------------------------------------");
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
Iris.error(
|
Iris.error("---------------------------------------------------------------------------------------------------------");
|
||||||
"---------------------------------------------------------------------------------------------------------");
|
|
||||||
Iris.error("ERROR! Failed to generate chunk! Iris has entered a failed state!");
|
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.DARK_RED + "Iris Generator has crashed!");
|
||||||
Iris.instance.imsg(i, ChatColor.RED + "- Check the console for the error.");
|
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>");
|
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
|
@Override
|
||||||
public List<BlockPopulator> getDefaultPopulators(World world) {
|
public List<BlockPopulator> getDefaultPopulators(World world)
|
||||||
|
{
|
||||||
return super.getDefaultPopulators(world);
|
return super.getDefaultPopulators(world);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Location getFixedSpawnLocation(World world, Random random) {
|
public Location getFixedSpawnLocation(World world, Random random)
|
||||||
|
{
|
||||||
return super.getFixedSpawnLocation(world, random);
|
return super.getFixedSpawnLocation(world, random);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isParallelCapable() {
|
public boolean isParallelCapable()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import java.awt.Color;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Chunk;
|
import org.bukkit.Chunk;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
@ -28,94 +29,114 @@ import lombok.EqualsAndHashCode;
|
|||||||
|
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext {
|
public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisContext
|
||||||
|
{
|
||||||
private Method initLighting;
|
private Method initLighting;
|
||||||
private IrisLock lock;
|
private IrisLock lock;
|
||||||
private IrisBiome hb = null;
|
private IrisBiome hb = null;
|
||||||
private IrisRegion hr = null;
|
private IrisRegion hr = null;
|
||||||
private KMap<Player, IrisBiome> b = new KMap<>();
|
private KMap<Player, IrisBiome> b = new KMap<>();
|
||||||
|
|
||||||
public IrisChunkGenerator(String dimensionName, int threads) {
|
public IrisChunkGenerator(String dimensionName, int threads)
|
||||||
|
{
|
||||||
super(dimensionName, threads);
|
super(dimensionName, threads);
|
||||||
lock = new IrisLock("IrisChunkGenerator");
|
lock = new IrisLock("IrisChunkGenerator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisChunkGenerator(String dimensionName) {
|
public IrisChunkGenerator(String dimensionName)
|
||||||
|
{
|
||||||
super(dimensionName, 16);
|
super(dimensionName, 16);
|
||||||
lock = new IrisLock("IrisChunkGenerator");
|
lock = new IrisLock("IrisChunkGenerator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisChunkGenerator(int tc) {
|
public IrisChunkGenerator(int tc)
|
||||||
|
{
|
||||||
super("", tc);
|
super("", tc);
|
||||||
lock = new IrisLock("IrisChunkGenerator");
|
lock = new IrisLock("IrisChunkGenerator");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hotload() {
|
public void hotload()
|
||||||
|
{
|
||||||
onHotload();
|
onHotload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void retry() {
|
public void retry()
|
||||||
if (failing) {
|
{
|
||||||
|
if(failing)
|
||||||
|
{
|
||||||
failing = false;
|
failing = false;
|
||||||
hotload();
|
hotload();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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();
|
lock.lock();
|
||||||
super.onGenerate(random, x, z, data, grid);
|
super.onGenerate(random, x, z, data, grid);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onInit(World world, RNG rng) {
|
public void onInit(World world, RNG rng)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
super.onInit(world, rng);
|
super.onInit(world, rng);
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch(Throwable e)
|
||||||
|
{
|
||||||
fail(e);
|
fail(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeResult getBiome(int x, int z) {
|
public BiomeResult getBiome(int x, int z)
|
||||||
|
{
|
||||||
return sampleBiome(x, z);
|
return sampleBiome(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IrisRegion getRegion(int x, int z) {
|
public IrisRegion getRegion(int x, int z)
|
||||||
|
{
|
||||||
return sampleRegion(x, z);
|
return sampleRegion(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getHeight(int x, int z) {
|
public int getHeight(int x, int z)
|
||||||
|
{
|
||||||
return sampleHeight(x, z);
|
return sampleHeight(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onTick(int ticks) {
|
public void onTick(int ticks)
|
||||||
|
{
|
||||||
super.onTick(ticks);
|
super.onTick(ticks);
|
||||||
for (Player i : getWorld().getPlayers()) {
|
for(Player i : getWorld().getPlayers())
|
||||||
|
{
|
||||||
Location l = i.getLocation();
|
Location l = i.getLocation();
|
||||||
IrisRegion r = sampleRegion(l.getBlockX(), l.getBlockZ());
|
IrisRegion r = sampleRegion(l.getBlockX(), l.getBlockZ());
|
||||||
IrisBiome b = sampleTrueBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ()).getBiome();
|
IrisBiome b = sampleTrueBiome(l.getBlockX(), l.getBlockY(), l.getBlockZ()).getBiome();
|
||||||
|
|
||||||
for (IrisEffect j : r.getEffects()) {
|
for(IrisEffect j : r.getEffects())
|
||||||
|
{
|
||||||
j.apply(i, this);
|
j.apply(i, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisEffect j : b.getEffects()) {
|
for(IrisEffect j : b.getEffects())
|
||||||
|
{
|
||||||
j.apply(i, this);
|
j.apply(i, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onClose() {
|
protected void onClose()
|
||||||
|
{
|
||||||
super.onClose();
|
super.onClose();
|
||||||
|
|
||||||
try {
|
try
|
||||||
|
{
|
||||||
parallaxMap.saveAll();
|
parallaxMap.saveAll();
|
||||||
ceilingParallaxMap.saveAll();
|
ceilingParallaxMap.saveAll();
|
||||||
parallaxMap.getLoadedChunks().clear();
|
parallaxMap.getLoadedChunks().clear();
|
||||||
@ -124,7 +145,8 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
|
|||||||
ceilingParallaxMap.getLoadedRegions().clear();
|
ceilingParallaxMap.getLoadedRegions().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (IOException e) {
|
catch(IOException e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -135,45 +157,61 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onFailure(Throwable e) {
|
protected void onFailure(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onChunkLoaded(Chunk c) {
|
protected void onChunkLoaded(Chunk c)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onChunkUnloaded(Chunk c) {
|
protected void onChunkUnloaded(Chunk c)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onPlayerJoin(Player p) {
|
protected void onPlayerJoin(Player p)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPlayerLeft(Player p) {
|
public void onPlayerLeft(Player p)
|
||||||
|
{
|
||||||
super.onPlayerLeft(p);
|
super.onPlayerLeft(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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;
|
CNG.creates = 0;
|
||||||
getData().dump();
|
getData().dump();
|
||||||
onHotload();
|
onHotload();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long guessMemoryUsage() {
|
public long guessMemoryUsage()
|
||||||
|
{
|
||||||
long bytes = 1024 * 1024 * (8 + (getThreads() / 3));
|
long bytes = 1024 * 1024 * (8 + (getThreads() / 3));
|
||||||
|
|
||||||
for (AtomicRegionData i : parallaxMap.getLoadedRegions().values()) {
|
for(AtomicRegionData i : parallaxMap.getLoadedRegions().values())
|
||||||
|
{
|
||||||
bytes += i.guessMemoryUsage();
|
bytes += i.guessMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (AtomicRegionData i : ceilingParallaxMap.getLoadedRegions().values()) {
|
for(AtomicRegionData i : ceilingParallaxMap.getLoadedRegions().values())
|
||||||
|
{
|
||||||
bytes += i.guessMemoryUsage();
|
bytes += i.guessMemoryUsage();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -186,34 +224,41 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateCaves() {
|
public boolean shouldGenerateCaves()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateDecorations() {
|
public boolean shouldGenerateDecorations()
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateMobs() {
|
public boolean shouldGenerateMobs()
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean shouldGenerateStructures() {
|
public boolean shouldGenerateStructures()
|
||||||
if (!isInitialized()) {
|
{
|
||||||
|
if(!isInitialized())
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDimension().isVanillaStructures();
|
return getDimension().isVanillaStructures();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Function2<Double, Double, Color> createRenderer() {
|
public Function2<Double, Double, Color> createRenderer()
|
||||||
|
{
|
||||||
return (x, z) -> render(x, z);
|
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 ix = (int) x;
|
||||||
int iz = (int) z;
|
int iz = (int) z;
|
||||||
double height = getTerrainHeight(ix, iz);
|
double height = getTerrainHeight(ix, iz);
|
||||||
@ -225,22 +270,24 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
|
|||||||
shift -= shift2;
|
shift -= shift2;
|
||||||
float sat = 0;
|
float sat = 0;
|
||||||
|
|
||||||
if (hr.getLoadKey().equals(region.getLoadKey())) {
|
if(hr.getLoadKey().equals(region.getLoadKey()))
|
||||||
|
{
|
||||||
sat += 0.2;
|
sat += 0.2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hb.getLoadKey().equals(biome.getLoadKey())) {
|
if(hb.getLoadKey().equals(biome.getLoadKey()))
|
||||||
|
{
|
||||||
sat += 0.3;
|
sat += 0.3;
|
||||||
}
|
}
|
||||||
|
|
||||||
Color c = Color.getHSBColor((biome.isLand() ? 0.233f : 0.644f) - shift, 0.25f + shift + sat,
|
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));
|
||||||
(float) (Math.max(0, Math.min(height + getFluidHeight(), 255)) / 255));
|
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String textFor(double x, double z) {
|
public String textFor(double x, double z)
|
||||||
|
{
|
||||||
|
|
||||||
int ix = (int) x;
|
int ix = (int) x;
|
||||||
int iz = (int) z;
|
int iz = (int) z;
|
||||||
@ -249,8 +296,6 @@ public class IrisChunkGenerator extends CeilingChunkGenerator implements IrisCon
|
|||||||
IrisBiome biome = sampleTrueBiome(ix, iz, height).getBiome();
|
IrisBiome biome = sampleTrueBiome(ix, iz, height).getBiome();
|
||||||
hb = biome;
|
hb = biome;
|
||||||
hr = region;
|
hr = region;
|
||||||
return biome.getName() + " ("
|
return biome.getName() + " (" + Form.capitalizeWords(biome.getInferredType().name().toLowerCase().replaceAll("\\Q_\\E", " ") + ") in " + region.getName() + "\nY: " + (int) height);
|
||||||
+ Form.capitalizeWords(biome.getInferredType().name().toLowerCase().replaceAll("\\Q_\\E", " ") + ") in "
|
|
||||||
+ region.getName() + "\nY: " + (int) height);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.volmit.iris.gen.ContextualChunkGenerator;
|
|||||||
import com.volmit.iris.noise.CNG;
|
import com.volmit.iris.noise.CNG;
|
||||||
import com.volmit.iris.object.InferredType;
|
import com.volmit.iris.object.InferredType;
|
||||||
import com.volmit.iris.object.IrisRegion;
|
import com.volmit.iris.object.IrisRegion;
|
||||||
import com.volmit.iris.object.NoiseStyle;
|
|
||||||
import com.volmit.iris.util.BiomeResult;
|
import com.volmit.iris.util.BiomeResult;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
@ -21,7 +20,7 @@ public class BiomeDataProvider
|
|||||||
{
|
{
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.layer = layer;
|
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)
|
public BiomeResult generatePureData(ContextualChunkGenerator g, double bx, double bz, int rawX, int rawZ, IrisRegion regionData)
|
||||||
|
@ -8,19 +8,20 @@ import com.volmit.iris.util.KList;
|
|||||||
import com.volmit.iris.util.NoiseInjector;
|
import com.volmit.iris.util.NoiseInjector;
|
||||||
import com.volmit.iris.util.RNG;
|
import com.volmit.iris.util.RNG;
|
||||||
|
|
||||||
public class CNG {
|
public class CNG
|
||||||
|
{
|
||||||
public static long hits = 0;
|
public static long hits = 0;
|
||||||
public static long creates = 0;
|
public static long creates = 0;
|
||||||
public static final NoiseInjector ADD = (s, v) -> new double[] { s + v, 1 };
|
public static final NoiseInjector ADD = (s, v) -> new double[] {s + v, 1};
|
||||||
public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[] { s - v < 0 ? 0 : s - v, -1 };
|
public static final NoiseInjector SRC_SUBTRACT = (s, v) -> new double[] {s - v < 0 ? 0 : s - v, -1};
|
||||||
public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[] { v - s < 0 ? 0 : s - v, -1 };
|
public static final NoiseInjector DST_SUBTRACT = (s, v) -> new double[] {v - s < 0 ? 0 : s - v, -1};
|
||||||
public static final NoiseInjector MULTIPLY = (s, v) -> new double[] { s * v, 0 };
|
public static final NoiseInjector MULTIPLY = (s, v) -> new double[] {s * v, 0};
|
||||||
public static final NoiseInjector MAX = (s, v) -> new double[] { Math.max(s, v), 0 };
|
public static final NoiseInjector MAX = (s, v) -> new double[] {Math.max(s, v), 0};
|
||||||
public static final NoiseInjector MIN = (s, v) -> new double[] { Math.min(s, v), 0 };
|
public static final NoiseInjector MIN = (s, v) -> new double[] {Math.min(s, v), 0};
|
||||||
public static final NoiseInjector SRC_MOD = (s, v) -> new double[] { s % v, 0 };
|
public static final NoiseInjector SRC_MOD = (s, v) -> new double[] {s % v, 0};
|
||||||
public static final NoiseInjector SRC_POW = (s, v) -> new double[] { Math.pow(s, v), 0 };
|
public static final NoiseInjector SRC_POW = (s, v) -> new double[] {Math.pow(s, v), 0};
|
||||||
public static final NoiseInjector DST_MOD = (s, v) -> new double[] { v % s, 0 };
|
public static final NoiseInjector DST_MOD = (s, v) -> new double[] {v % s, 0};
|
||||||
public static final NoiseInjector DST_POW = (s, v) -> new double[] { Math.pow(v, s), 0 };
|
public static final NoiseInjector DST_POW = (s, v) -> new double[] {Math.pow(v, s), 0};
|
||||||
private double scale;
|
private double scale;
|
||||||
private double bakedScale;
|
private double bakedScale;
|
||||||
private double fscale;
|
private double fscale;
|
||||||
@ -36,31 +37,38 @@ public class CNG {
|
|||||||
private double down;
|
private double down;
|
||||||
private double power;
|
private double power;
|
||||||
|
|
||||||
public NoiseGenerator getGen() {
|
public NoiseGenerator getGen()
|
||||||
|
{
|
||||||
return generator;
|
return generator;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signature(RNG rng) {
|
public static CNG signature(RNG rng)
|
||||||
|
{
|
||||||
return signature(rng, NoiseType.SIMPLEX);
|
return signature(rng, NoiseType.SIMPLEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signatureHalf(RNG rng) {
|
public static CNG signatureHalf(RNG rng)
|
||||||
|
{
|
||||||
return signatureHalf(rng, NoiseType.SIMPLEX);
|
return signatureHalf(rng, NoiseType.SIMPLEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signatureThick(RNG rng) {
|
public static CNG signatureThick(RNG rng)
|
||||||
|
{
|
||||||
return signatureThick(rng, NoiseType.SIMPLEX);
|
return signatureThick(rng, NoiseType.SIMPLEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signatureDouble(RNG rng) {
|
public static CNG signatureDouble(RNG rng)
|
||||||
|
{
|
||||||
return signatureDouble(rng, NoiseType.SIMPLEX);
|
return signatureDouble(rng, NoiseType.SIMPLEX);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signatureDouble(RNG rng, NoiseType t) {
|
public static CNG signatureDouble(RNG rng, NoiseType t)
|
||||||
|
{
|
||||||
return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93);
|
return signatureThick(rng, t).fractureWith(signature(rng.nextParallelRNG(4956)), 93);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signature(RNG rng, NoiseType t) {
|
public static CNG signature(RNG rng, NoiseType t)
|
||||||
|
{
|
||||||
// @builder
|
// @builder
|
||||||
return new CNG(rng.nextParallelRNG(17), t, 1D, 1)
|
return new CNG(rng.nextParallelRNG(17), t, 1D, 1)
|
||||||
.fractureWith(
|
.fractureWith(
|
||||||
@ -72,7 +80,8 @@ public class CNG {
|
|||||||
// @done
|
// @done
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signatureThick(RNG rng, NoiseType t) {
|
public static CNG signatureThick(RNG rng, NoiseType t)
|
||||||
|
{
|
||||||
// @builder
|
// @builder
|
||||||
return new CNG(rng.nextParallelRNG(133), t, 1D, 1)
|
return new CNG(rng.nextParallelRNG(133), t, 1D, 1)
|
||||||
.fractureWith(
|
.fractureWith(
|
||||||
@ -84,7 +93,8 @@ public class CNG {
|
|||||||
// @done
|
// @done
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CNG signatureHalf(RNG rng, NoiseType t) {
|
public static CNG signatureHalf(RNG rng, NoiseType t)
|
||||||
|
{
|
||||||
// @builder
|
// @builder
|
||||||
return new CNG(rng.nextParallelRNG(127), t, 1D, 1)
|
return new CNG(rng.nextParallelRNG(127), t, 1D, 1)
|
||||||
.fractureWith(
|
.fractureWith(
|
||||||
@ -96,19 +106,23 @@ public class CNG {
|
|||||||
// @done
|
// @done
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG(RNG random) {
|
public CNG(RNG random)
|
||||||
|
{
|
||||||
this(random, 1);
|
this(random, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG(RNG random, int octaves) {
|
public CNG(RNG random, int octaves)
|
||||||
|
{
|
||||||
this(random, 1D, octaves);
|
this(random, 1D, octaves);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG(RNG random, double opacity, int octaves) {
|
public CNG(RNG random, double opacity, int octaves)
|
||||||
|
{
|
||||||
this(random, NoiseType.SIMPLEX, opacity, octaves);
|
this(random, NoiseType.SIMPLEX, opacity, octaves);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG(RNG random, NoiseType t, double opacity, int octaves) {
|
public CNG(RNG random, NoiseType t, double opacity, int octaves)
|
||||||
|
{
|
||||||
creates++;
|
creates++;
|
||||||
this.oct = octaves;
|
this.oct = octaves;
|
||||||
this.rng = random;
|
this.rng = random;
|
||||||
@ -124,19 +138,23 @@ public class CNG {
|
|||||||
this.opacity = opacity;
|
this.opacity = opacity;
|
||||||
this.injector = ADD;
|
this.injector = ADD;
|
||||||
|
|
||||||
if (generator instanceof OctaveNoise) {
|
if(generator instanceof OctaveNoise)
|
||||||
|
{
|
||||||
((OctaveNoise) generator).setOctaves(octaves);
|
((OctaveNoise) generator).setOctaves(octaves);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG bake() {
|
public CNG bake()
|
||||||
|
{
|
||||||
bakedScale *= scale;
|
bakedScale *= scale;
|
||||||
scale = 1;
|
scale = 1;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG child(CNG c) {
|
public CNG child(CNG c)
|
||||||
if (children == null) {
|
{
|
||||||
|
if(children == null)
|
||||||
|
{
|
||||||
children = new KList<>();
|
children = new KList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -145,114 +163,141 @@ public class CNG {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public RNG nextRNG() {
|
public RNG nextRNG()
|
||||||
|
{
|
||||||
return getRNG().nextRNG();
|
return getRNG().nextRNG();
|
||||||
}
|
}
|
||||||
|
|
||||||
public RNG getRNG() {
|
public RNG getRNG()
|
||||||
|
{
|
||||||
return rng;
|
return rng;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG fractureWith(CNG c, double scale) {
|
public CNG fractureWith(CNG c, double scale)
|
||||||
|
{
|
||||||
fracture = c;
|
fracture = c;
|
||||||
fscale = scale;
|
fscale = scale;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG scale(double c) {
|
public CNG scale(double c)
|
||||||
|
{
|
||||||
scale = c;
|
scale = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG patch(double c) {
|
public CNG patch(double c)
|
||||||
|
{
|
||||||
patch = c;
|
patch = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG up(double c) {
|
public CNG up(double c)
|
||||||
|
{
|
||||||
up = c;
|
up = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG down(double c) {
|
public CNG down(double c)
|
||||||
|
{
|
||||||
down = c;
|
down = c;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG injectWith(NoiseInjector i) {
|
public CNG injectWith(NoiseInjector i)
|
||||||
|
{
|
||||||
injector = i;
|
injector = i;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T extends IRare> T fitRarity(KList<T> b, double... dim) {
|
public <T extends IRare> T fitRarity(KList<T> b, double... dim)
|
||||||
if (b.size() == 0) {
|
{
|
||||||
|
if(b.size() == 0)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (b.size() == 1) {
|
if(b.size() == 1)
|
||||||
|
{
|
||||||
return b.get(0);
|
return b.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<T> rarityMapped = new KList<>();
|
KList<T> rarityMapped = new KList<>();
|
||||||
boolean o = false;
|
boolean o = false;
|
||||||
int max = 1;
|
int max = 1;
|
||||||
for (T i : b) {
|
for(T i : b)
|
||||||
if (i.getRarity() > max) {
|
{
|
||||||
|
if(i.getRarity() > max)
|
||||||
|
{
|
||||||
max = i.getRarity();
|
max = i.getRarity();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
max++;
|
max++;
|
||||||
|
|
||||||
for (T i : b) {
|
for(T i : b)
|
||||||
for (int j = 0; j < max - i.getRarity(); j++) {
|
{
|
||||||
if (o = !o) {
|
for(int j = 0; j < max - i.getRarity(); j++)
|
||||||
|
{
|
||||||
|
if(o = !o)
|
||||||
|
{
|
||||||
rarityMapped.add(i);
|
rarityMapped.add(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else
|
||||||
|
{
|
||||||
rarityMapped.add(0, i);
|
rarityMapped.add(0, i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rarityMapped.size() == 1) {
|
if(rarityMapped.size() == 1)
|
||||||
|
{
|
||||||
return rarityMapped.get(0);
|
return rarityMapped.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rarityMapped.isEmpty()) {
|
if(rarityMapped.isEmpty())
|
||||||
|
{
|
||||||
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
|
throw new RuntimeException("BAD RARITY MAP! RELATED TO: " + b.toString(", or possibly "));
|
||||||
}
|
}
|
||||||
|
|
||||||
return fit(rarityMapped, dim);
|
return fit(rarityMapped, dim);
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T fit(T[] v, double... dim) {
|
public <T> T fit(T[] v, double... dim)
|
||||||
if (v.length == 0) {
|
{
|
||||||
|
if(v.length == 0)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v.length == 1) {
|
if(v.length == 1)
|
||||||
|
{
|
||||||
return v[0];
|
return v[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
return v[fit(0, v.length - 1, dim)];
|
return v[fit(0, v.length - 1, dim)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public <T> T fit(List<T> v, double... dim) {
|
public <T> T fit(List<T> v, double... dim)
|
||||||
if (v.size() == 0) {
|
{
|
||||||
|
if(v.size() == 0)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v.size() == 1) {
|
if(v.size() == 1)
|
||||||
|
{
|
||||||
return v.get(0);
|
return v.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return v.get(fit(0, v.size() - 1, dim));
|
return v.get(fit(0, v.size() - 1, dim));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fit(int min, int max, double... dim) {
|
public int fit(int min, int max, double... dim)
|
||||||
if (min == max) {
|
{
|
||||||
|
if(min == max)
|
||||||
|
{
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -261,8 +306,10 @@ public class CNG {
|
|||||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||||
}
|
}
|
||||||
|
|
||||||
public int fit(double min, double max, double... dim) {
|
public int fit(double min, double max, double... dim)
|
||||||
if (min == max) {
|
{
|
||||||
|
if(min == max)
|
||||||
|
{
|
||||||
return (int) Math.round(min);
|
return (int) Math.round(min);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -271,8 +318,10 @@ public class CNG {
|
|||||||
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
return (int) Math.round(IrisInterpolation.lerp(min, max, noise));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double fitDouble(double min, double max, double... dim) {
|
public double fitDouble(double min, double max, double... dim)
|
||||||
if (min == max) {
|
{
|
||||||
|
if(min == max)
|
||||||
|
{
|
||||||
return min;
|
return min;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,21 +330,24 @@ public class CNG {
|
|||||||
return IrisInterpolation.lerp(min, max, noise);
|
return IrisInterpolation.lerp(min, max, noise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double noise(double... dim) {
|
public double noise(double... dim)
|
||||||
|
{
|
||||||
double scale = this.bakedScale * this.scale;
|
double scale = this.bakedScale * this.scale;
|
||||||
double f = fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D;
|
double f = (fracture != null ? (fracture.noise(dim) - 0.5) * fscale : 0D);
|
||||||
double x = dim.length > 0 ? dim[0] + f : 0D;
|
double x = dim.length > 0 ? dim[0] + f : 0D;
|
||||||
double y = dim.length > 1 ? dim[1] - f : 0D;
|
double z = dim.length > 1 ? dim[1] - f : 0D;
|
||||||
double z = dim.length > 2 ? dim[2] + f : 0D;
|
double y = dim.length > 2 ? dim[2] + f : 0D;
|
||||||
double n = generator.noise(x * scale, y * scale, z * scale) * opacity;
|
double n = generator.noise(x * scale, y * scale, z * scale) * opacity;
|
||||||
n = power != 1D ? Math.pow(n, power) : n;
|
n = power != 1D ? Math.pow(n, power) : n;
|
||||||
double m = 1;
|
double m = 1;
|
||||||
hits += oct;
|
hits += oct;
|
||||||
if (children == null) {
|
if(children == null)
|
||||||
|
{
|
||||||
return (n - down + up) * patch;
|
return (n - down + up) * patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (CNG i : children) {
|
for(CNG i : children)
|
||||||
|
{
|
||||||
double[] r = injector.combine(n, i.noise(dim));
|
double[] r = injector.combine(n, i.noise(dim));
|
||||||
n = r[0];
|
n = r[0];
|
||||||
m += r[1];
|
m += r[1];
|
||||||
@ -304,17 +356,20 @@ public class CNG {
|
|||||||
return ((n / m) - down + up) * patch;
|
return ((n / m) - down + up) * patch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG pow(double power) {
|
public CNG pow(double power)
|
||||||
|
{
|
||||||
this.power = power;
|
this.power = power;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG oct(int octaves) {
|
public CNG oct(int octaves)
|
||||||
|
{
|
||||||
oct = octaves;
|
oct = octaves;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getScale() {
|
public double getScale()
|
||||||
|
{
|
||||||
return scale;
|
return scale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
@Desc("Represents a biome in iris. Biomes are placed inside of regions and hold objects.")
|
@Desc("Represents a biome in iris. Biomes are placed inside of regions and hold objects.")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class IrisBiome extends IrisRegistrant implements IRare {
|
public class IrisBiome extends IrisRegistrant implements IRare
|
||||||
|
{
|
||||||
@MinNumber(2)
|
@MinNumber(2)
|
||||||
@Required
|
@Required
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -39,13 +40,13 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
private KList<IrisEffect> effects = new KList<>();
|
private KList<IrisEffect> effects = new KList<>();
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@DependsOn({ "biomeStyle", "biomeZoom", "biomeScatter" })
|
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})
|
||||||
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
@Desc("This changes the dispersion of the biome colors if multiple derivatives are chosen.")
|
||||||
private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style();
|
private IrisGeneratorStyle biomeStyle = NoiseStyle.SIMPLEX.style();
|
||||||
|
|
||||||
@MinNumber(0.0001)
|
@MinNumber(0.0001)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@DependsOn({ "biomeStyle", "biomeZoom", "biomeScatter" })
|
@DependsOn({"biomeStyle", "biomeZoom", "biomeScatter"})
|
||||||
@Desc("This zooms in the biome colors if multiple derivatives are chosen")
|
@Desc("This zooms in the biome colors if multiple derivatives are chosen")
|
||||||
private double biomeZoom = 1;
|
private double biomeZoom = 1;
|
||||||
|
|
||||||
@ -75,12 +76,12 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
private KList<Biome> biomeSkyScatter = new KList<>();
|
private KList<Biome> biomeSkyScatter = new KList<>();
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@DependsOn({ "children" })
|
@DependsOn({"children"})
|
||||||
@Desc("If this biome has children biomes, and the gen layer chooses one of this biomes children, how much smaller will it be (inside of this biome). Higher values means a smaller biome relative to this biome's size. Set higher than 1.0 and below 3.0 for best results.")
|
@Desc("If this biome has children biomes, and the gen layer chooses one of this biomes children, how much smaller will it be (inside of this biome). Higher values means a smaller biome relative to this biome's size. Set higher than 1.0 and below 3.0 for best results.")
|
||||||
private double childShrinkFactor = 1.5;
|
private double childShrinkFactor = 1.5;
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@DependsOn({ "children" })
|
@DependsOn({"children"})
|
||||||
@Desc("If this biome has children biomes, and the gen layer chooses one of this biomes children, How will it be shaped?")
|
@Desc("If this biome has children biomes, and the gen layer chooses one of this biomes children, How will it be shaped?")
|
||||||
private IrisGeneratorStyle childStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
private IrisGeneratorStyle childStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
@ -122,8 +123,7 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
@ArrayType(min = 1, type = IrisBiomeGeneratorLink.class)
|
@ArrayType(min = 1, type = IrisBiomeGeneratorLink.class)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("Generators for this biome. Multiple generators with different interpolation sizes will mix with other biomes how you would expect. This defines your biome height relative to the fluid height. Use negative for oceans.")
|
@Desc("Generators for this biome. Multiple generators with different interpolation sizes will mix with other biomes how you would expect. This defines your biome height relative to the fluid height. Use negative for oceans.")
|
||||||
private KList<IrisBiomeGeneratorLink> generators = new KList<IrisBiomeGeneratorLink>()
|
private KList<IrisBiomeGeneratorLink> generators = new KList<IrisBiomeGeneratorLink>().qadd(new IrisBiomeGeneratorLink());
|
||||||
.qadd(new IrisBiomeGeneratorLink());
|
|
||||||
|
|
||||||
@ArrayType(min = 1, type = IrisStructurePlacement.class)
|
@ArrayType(min = 1, type = IrisStructurePlacement.class)
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -143,67 +143,80 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
private transient AtomicCache<KList<CNG>> layerHeightGenerators = new AtomicCache<>();
|
private transient AtomicCache<KList<CNG>> layerHeightGenerators = new AtomicCache<>();
|
||||||
private transient AtomicCache<KList<CNG>> layerSeaHeightGenerators = new AtomicCache<>();
|
private transient AtomicCache<KList<CNG>> layerSeaHeightGenerators = new AtomicCache<>();
|
||||||
|
|
||||||
public IrisBiome() {
|
public IrisBiome()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed) {
|
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed)
|
||||||
|
{
|
||||||
double height = 0;
|
double height = 0;
|
||||||
|
|
||||||
for (IrisBiomeGeneratorLink i : generators) {
|
for(IrisBiomeGeneratorLink i : generators)
|
||||||
|
{
|
||||||
height += i.getHeight(xg, x, z, seed);
|
height += i.getHeight(xg, x, z, seed);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Math.max(0, Math.min(height, 255));
|
return Math.max(0, Math.min(height, 255));
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getBiomeGenerator(RNG random) {
|
public CNG getBiomeGenerator(RNG random)
|
||||||
return biomeGenerator.aquire(() -> {
|
{
|
||||||
|
return biomeGenerator.aquire(() ->
|
||||||
|
{
|
||||||
return biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()));
|
return biomeStyle.create(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length()));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getChildrenGenerator(RNG random, int sig, double scale) {
|
public CNG getChildrenGenerator(RNG random, int sig, double scale)
|
||||||
return childrenCell
|
{
|
||||||
.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137)).bake().scale(scale).bake());
|
return childrenCell.aquire(() -> getChildStyle().create(random.nextParallelRNG(sig * 2137)).bake().scale(scale).bake());
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth, int height) {
|
public KList<BlockData> generateLayers(double wx, double wz, RNG random, int maxDepth, int height)
|
||||||
if (isLockLayers()) {
|
{
|
||||||
|
if(isLockLayers())
|
||||||
|
{
|
||||||
return generateLockedLayers(wx, wz, random, maxDepth, height);
|
return generateLockedLayers(wx, wz, random, maxDepth, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<BlockData> data = new KList<>();
|
KList<BlockData> data = new KList<>();
|
||||||
|
|
||||||
if (maxDepth <= 0) {
|
if(maxDepth <= 0)
|
||||||
|
{
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < layers.size(); i++) {
|
for(int i = 0; i < layers.size(); i++)
|
||||||
|
{
|
||||||
CNG hgen = getLayerHeightGenerators(random).get(i);
|
CNG hgen = getLayerHeightGenerators(random).get(i);
|
||||||
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(),
|
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
|
||||||
wz / layers.get(i).getZoom());
|
|
||||||
|
|
||||||
if (d < 0) {
|
if(d < 0)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < d; j++) {
|
for(int j = 0; j < d; j++)
|
||||||
if (data.size() >= maxDepth) {
|
{
|
||||||
|
if(data.size() >= maxDepth)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(),
|
{
|
||||||
j, (wz - j) / layers.get(i).getZoom()));
|
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom()));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch(Throwable e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.size() >= maxDepth) {
|
if(data.size() >= maxDepth)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -211,40 +224,47 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> generateLockedLayers(double wx, double wz, RNG random, int maxDepth, int height) {
|
public KList<BlockData> generateLockedLayers(double wx, double wz, RNG random, int maxDepth, int height)
|
||||||
|
{
|
||||||
KList<BlockData> data = new KList<>();
|
KList<BlockData> data = new KList<>();
|
||||||
KList<BlockData> real = new KList<>();
|
KList<BlockData> real = new KList<>();
|
||||||
|
|
||||||
if (maxDepth <= 0) {
|
if(maxDepth <= 0)
|
||||||
|
{
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < layers.size(); i++) {
|
for(int i = 0; i < layers.size(); i++)
|
||||||
|
{
|
||||||
CNG hgen = getLayerHeightGenerators(random).get(i);
|
CNG hgen = getLayerHeightGenerators(random).get(i);
|
||||||
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(),
|
int d = hgen.fit(layers.get(i).getMinHeight(), layers.get(i).getMaxHeight(), wx / layers.get(i).getZoom(), wz / layers.get(i).getZoom());
|
||||||
wz / layers.get(i).getZoom());
|
|
||||||
|
|
||||||
if (d < 0) {
|
if(d < 0)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < d; j++) {
|
for(int j = 0; j < d; j++)
|
||||||
try {
|
{
|
||||||
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(),
|
try
|
||||||
j, (wz - j) / layers.get(i).getZoom()));
|
{
|
||||||
|
data.add(getLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / layers.get(i).getZoom(), j, (wz - j) / layers.get(i).getZoom()));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch(Throwable e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.isEmpty()) {
|
if(data.isEmpty())
|
||||||
|
{
|
||||||
return real;
|
return real;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < maxDepth; i++) {
|
for(int i = 0; i < maxDepth; i++)
|
||||||
|
{
|
||||||
int offset = (getMaxHeight() - height) - i;
|
int offset = (getMaxHeight() - height) - i;
|
||||||
int index = offset % data.size();
|
int index = offset % data.size();
|
||||||
real.add(data.get(index < 0 ? 0 : index));
|
real.add(data.get(index < 0 ? 0 : index));
|
||||||
@ -253,11 +273,14 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
return real;
|
return real;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getMaxHeight() {
|
private int getMaxHeight()
|
||||||
return maxHeight.aquire(() -> {
|
{
|
||||||
|
return maxHeight.aquire(() ->
|
||||||
|
{
|
||||||
int maxHeight = 0;
|
int maxHeight = 0;
|
||||||
|
|
||||||
for (IrisBiomeGeneratorLink i : getGenerators()) {
|
for(IrisBiomeGeneratorLink i : getGenerators())
|
||||||
|
{
|
||||||
maxHeight += i.getMax();
|
maxHeight += i.getMax();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -265,39 +288,46 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisBiome infer(InferredType t, InferredType type) {
|
public IrisBiome infer(InferredType t, InferredType type)
|
||||||
|
{
|
||||||
setInferredType(t.equals(InferredType.DEFER) ? type : t);
|
setInferredType(t.equals(InferredType.DEFER) ? type : t);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> generateSeaLayers(double wx, double wz, RNG random, int maxDepth) {
|
public KList<BlockData> generateSeaLayers(double wx, double wz, RNG random, int maxDepth)
|
||||||
|
{
|
||||||
KList<BlockData> data = new KList<>();
|
KList<BlockData> data = new KList<>();
|
||||||
|
|
||||||
for (int i = 0; i < seaLayers.size(); i++) {
|
for(int i = 0; i < seaLayers.size(); i++)
|
||||||
|
{
|
||||||
CNG hgen = getLayerSeaHeightGenerators(random).get(i);
|
CNG hgen = getLayerSeaHeightGenerators(random).get(i);
|
||||||
int d = hgen.fit(seaLayers.get(i).getMinHeight(), seaLayers.get(i).getMaxHeight(),
|
int d = hgen.fit(seaLayers.get(i).getMinHeight(), seaLayers.get(i).getMaxHeight(), wx / seaLayers.get(i).getZoom(), wz / seaLayers.get(i).getZoom());
|
||||||
wx / seaLayers.get(i).getZoom(), wz / seaLayers.get(i).getZoom());
|
|
||||||
|
|
||||||
if (d < 0) {
|
if(d < 0)
|
||||||
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int j = 0; j < d; j++) {
|
for(int j = 0; j < d; j++)
|
||||||
if (data.size() >= maxDepth) {
|
{
|
||||||
|
if(data.size() >= maxDepth)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try
|
||||||
data.add(getSeaLayers().get(i).get(random.nextParallelRNG(i + j),
|
{
|
||||||
(wx + j) / seaLayers.get(i).getZoom(), j, (wz - j) / seaLayers.get(i).getZoom()));
|
data.add(getSeaLayers().get(i).get(random.nextParallelRNG(i + j), (wx + j) / seaLayers.get(i).getZoom(), j, (wz - j) / seaLayers.get(i).getZoom()));
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch(Throwable e)
|
||||||
|
{
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data.size() >= maxDepth) {
|
if(data.size() >= maxDepth)
|
||||||
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -305,13 +335,16 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<CNG> getLayerHeightGenerators(RNG rng) {
|
public KList<CNG> getLayerHeightGenerators(RNG rng)
|
||||||
return layerHeightGenerators.aquire(() -> {
|
{
|
||||||
|
return layerHeightGenerators.aquire(() ->
|
||||||
|
{
|
||||||
KList<CNG> layerHeightGenerators = new KList<>();
|
KList<CNG> layerHeightGenerators = new KList<>();
|
||||||
|
|
||||||
int m = 7235;
|
int m = 7235;
|
||||||
|
|
||||||
for (IrisBiomePaletteLayer i : getLayers()) {
|
for(IrisBiomePaletteLayer i : getLayers())
|
||||||
|
{
|
||||||
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,13 +352,16 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<CNG> getLayerSeaHeightGenerators(RNG rng) {
|
public KList<CNG> getLayerSeaHeightGenerators(RNG rng)
|
||||||
return layerSeaHeightGenerators.aquire(() -> {
|
{
|
||||||
|
return layerSeaHeightGenerators.aquire(() ->
|
||||||
|
{
|
||||||
KList<CNG> layerSeaHeightGenerators = new KList<>();
|
KList<CNG> layerSeaHeightGenerators = new KList<>();
|
||||||
|
|
||||||
int m = 7735;
|
int m = 7735;
|
||||||
|
|
||||||
for (IrisBiomePaletteLayer i : getSeaLayers()) {
|
for(IrisBiomePaletteLayer i : getSeaLayers())
|
||||||
|
{
|
||||||
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,45 +369,57 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLand() {
|
public boolean isLand()
|
||||||
if (inferredType == null) {
|
{
|
||||||
|
if(inferredType == null)
|
||||||
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return inferredType.equals(InferredType.LAND);
|
return inferredType.equals(InferredType.LAND);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSea() {
|
public boolean isSea()
|
||||||
if (inferredType == null) {
|
{
|
||||||
|
if(inferredType == null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return inferredType.equals(InferredType.SEA);
|
return inferredType.equals(InferredType.SEA);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShore() {
|
public boolean isShore()
|
||||||
if (inferredType == null) {
|
{
|
||||||
|
if(inferredType == null)
|
||||||
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return inferredType.equals(InferredType.SHORE);
|
return inferredType.equals(InferredType.SHORE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Biome getSkyBiome(RNG rng, double x, double y, double z) {
|
public Biome getSkyBiome(RNG rng, double x, double y, double z)
|
||||||
if (biomeSkyScatter.size() == 1) {
|
{
|
||||||
|
if(biomeSkyScatter.size() == 1)
|
||||||
|
{
|
||||||
return biomeSkyScatter.get(0);
|
return biomeSkyScatter.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biomeSkyScatter.isEmpty()) {
|
if(biomeSkyScatter.isEmpty())
|
||||||
|
{
|
||||||
return getGroundBiome(rng, x, y, z);
|
return getGroundBiome(rng, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
|
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getRealChildren(ContextualChunkGenerator g) {
|
public KList<IrisBiome> getRealChildren(ContextualChunkGenerator g)
|
||||||
return realChildren.aquire(() -> {
|
{
|
||||||
|
return realChildren.aquire(() ->
|
||||||
|
{
|
||||||
KList<IrisBiome> realChildren = new KList<>();
|
KList<IrisBiome> realChildren = new KList<>();
|
||||||
|
|
||||||
for (String i : getChildren()) {
|
for(String i : getChildren())
|
||||||
|
{
|
||||||
realChildren.add(g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i));
|
realChildren.add(g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,13 +427,16 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> getAllChildren(ContextualChunkGenerator g, int limit) {
|
public KList<String> getAllChildren(ContextualChunkGenerator g, int limit)
|
||||||
|
{
|
||||||
KSet<String> m = new KSet<>();
|
KSet<String> m = new KSet<>();
|
||||||
m.addAll(getChildren());
|
m.addAll(getChildren());
|
||||||
limit--;
|
limit--;
|
||||||
|
|
||||||
if (limit > 0) {
|
if(limit > 0)
|
||||||
for (String i : getChildren()) {
|
{
|
||||||
|
for(String i : getChildren())
|
||||||
|
{
|
||||||
IrisBiome b = g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i);
|
IrisBiome b = g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i);
|
||||||
int l = limit;
|
int l = limit;
|
||||||
m.addAll(b.getAllChildren(g, l));
|
m.addAll(b.getAllChildren(g, l));
|
||||||
@ -395,12 +446,15 @@ public class IrisBiome extends IrisRegistrant implements IRare {
|
|||||||
return new KList<String>(m);
|
return new KList<String>(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Biome getGroundBiome(RNG rng, double x, double y, double z) {
|
public Biome getGroundBiome(RNG rng, double x, double y, double z)
|
||||||
if (biomeSkyScatter.isEmpty()) {
|
{
|
||||||
|
if(biomeSkyScatter.isEmpty())
|
||||||
|
{
|
||||||
return getDerivative();
|
return getDerivative();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biomeScatter.size() == 1) {
|
if(biomeScatter.size() == 1)
|
||||||
|
{
|
||||||
return biomeScatter.get(0);
|
return biomeScatter.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,14 +20,15 @@ import lombok.Data;
|
|||||||
|
|
||||||
@Desc("A biome decorator is used for placing flowers, grass, cacti and so on")
|
@Desc("A biome decorator is used for placing flowers, grass, cacti and so on")
|
||||||
@Data
|
@Data
|
||||||
public class IrisBiomeDecorator {
|
public class IrisBiomeDecorator
|
||||||
|
{
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The varience dispersion is used when multiple blocks are put in the palette. Scatter scrambles them, Wispy shows streak-looking varience")
|
@Desc("The varience dispersion is used when multiple blocks are put in the palette. Scatter scrambles them, Wispy shows streak-looking varience")
|
||||||
private IrisGeneratorStyle variance = NoiseStyle.STATIC.style();
|
private IrisGeneratorStyle variance = NoiseStyle.STATIC.style();
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.")
|
@Desc("Dispersion is used to pick places to spawn. Scatter randomly places them (vanilla) or Wispy for a streak like patch system.")
|
||||||
private IrisGeneratorStyle dispersion = NoiseStyle.STATIC.style();
|
private IrisGeneratorStyle style = NoiseStyle.STATIC.style();
|
||||||
|
|
||||||
@DependsOn({"stackMin", "stackMax"})
|
@DependsOn({"stackMin", "stackMax"})
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@ -86,64 +87,78 @@ public class IrisBiomeDecorator {
|
|||||||
private transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
|
private transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
|
||||||
private transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
|
private transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
|
||||||
|
|
||||||
public int getHeight(RNG rng, double x, double z) {
|
public int getHeight(RNG rng, double x, double z)
|
||||||
if (stackMin == stackMax) {
|
{
|
||||||
|
if(stackMin == stackMax)
|
||||||
|
{
|
||||||
return stackMin;
|
return stackMin;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getHeightGenerator(rng).fit(stackMin, stackMax, x / verticalZoom, z / verticalZoom);
|
return getHeightGenerator(rng).fit(stackMin, stackMax, x / verticalZoom, z / verticalZoom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getHeightGenerator(RNG rng) {
|
public CNG getHeightGenerator(RNG rng)
|
||||||
return heightGenerator.aquire(() -> {
|
{
|
||||||
|
return heightGenerator.aquire(() ->
|
||||||
|
{
|
||||||
return heightVariance.create(rng.nextParallelRNG(getBlockData().size() + stackMax + stackMin));
|
return heightVariance.create(rng.nextParallelRNG(getBlockData().size() + stackMax + stackMin));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getGenerator(RNG rng) {
|
public CNG getGenerator(RNG rng)
|
||||||
|
{
|
||||||
long key = rng.nextParallelRNG(1).nextLong();
|
long key = rng.nextParallelRNG(1).nextLong();
|
||||||
|
|
||||||
if (layerGenerators == null) {
|
if(layerGenerators == null)
|
||||||
|
{
|
||||||
layerGenerators = new KMap<>();
|
layerGenerators = new KMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!layerGenerators.containsKey(key)) {
|
if(!layerGenerators.containsKey(key))
|
||||||
layerGenerators.put(key, dispersion.create(rng.nextParallelRNG((int) (getBlockData().size() + key))));
|
{
|
||||||
|
layerGenerators.put(key, style.create(rng.nextParallelRNG((int) (getBlockData().size() + key))));
|
||||||
}
|
}
|
||||||
|
|
||||||
return layerGenerators.get(key);
|
return layerGenerators.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getVarianceGenerator(RNG rng) {
|
public CNG getVarianceGenerator(RNG rng)
|
||||||
|
{
|
||||||
long key = rng.nextParallelRNG(4).nextLong();
|
long key = rng.nextParallelRNG(4).nextLong();
|
||||||
|
|
||||||
if (layerVarianceGenerators == null) {
|
if(layerVarianceGenerators == null)
|
||||||
|
{
|
||||||
layerVarianceGenerators = new KMap<>();
|
layerVarianceGenerators = new KMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!layerVarianceGenerators.containsKey(key)) {
|
if(!layerVarianceGenerators.containsKey(key))
|
||||||
layerVarianceGenerators.put(key,
|
{
|
||||||
variance.create(rng.nextParallelRNG((int) (getBlockData().size() + key))).scale(1D / varianceZoom));
|
layerVarianceGenerators.put(key, variance.create(rng.nextParallelRNG((int) (getBlockData().size() + key))).scale(1D / varianceZoom));
|
||||||
}
|
}
|
||||||
|
|
||||||
return layerVarianceGenerators.get(key);
|
return layerVarianceGenerators.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> add(String b) {
|
public KList<String> add(String b)
|
||||||
|
{
|
||||||
palette.add(b);
|
palette.add(b);
|
||||||
return palette;
|
return palette;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getBlockData(RNG rng, double x, double z) {
|
public BlockData getBlockData(RNG rng, double x, double z)
|
||||||
if (getGenerator(rng) == null) {
|
{
|
||||||
|
if(getGenerator(rng) == null)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBlockData() == null) {
|
if(getBlockData() == null)
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getBlockData().isEmpty()) {
|
if(getBlockData().isEmpty())
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,8 +167,10 @@ public class IrisBiomeDecorator {
|
|||||||
xx /= getZoom();
|
xx /= getZoom();
|
||||||
zz /= getZoom();
|
zz /= getZoom();
|
||||||
|
|
||||||
if (getGenerator(rng).fitDouble(0D, 1D, xx, zz) <= chance) {
|
if(getGenerator(rng).fitDouble(0D, 1D, xx, zz) <= chance)
|
||||||
if (getBlockData().size() == 1) {
|
{
|
||||||
|
if(getBlockData().size() == 1)
|
||||||
|
{
|
||||||
return getBlockData().get(0);
|
return getBlockData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -163,12 +180,16 @@ public class IrisBiomeDecorator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> getBlockData() {
|
public KList<BlockData> getBlockData()
|
||||||
return blockData.aquire(() -> {
|
{
|
||||||
|
return blockData.aquire(() ->
|
||||||
|
{
|
||||||
KList<BlockData> blockData = new KList<>();
|
KList<BlockData> blockData = new KList<>();
|
||||||
for (String i : palette) {
|
for(String i : palette)
|
||||||
|
{
|
||||||
BlockData bx = B.getBlockData(i);
|
BlockData bx = B.getBlockData(i);
|
||||||
if (bx != null) {
|
if(bx != null)
|
||||||
|
{
|
||||||
blockData.add(bx);
|
blockData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@ import lombok.EqualsAndHashCode;
|
|||||||
@Desc("Represents a dimension")
|
@Desc("Represents a dimension")
|
||||||
@Data
|
@Data
|
||||||
@EqualsAndHashCode(callSuper = false)
|
@EqualsAndHashCode(callSuper = false)
|
||||||
public class IrisDimension extends IrisRegistrant {
|
public class IrisDimension extends IrisRegistrant
|
||||||
|
{
|
||||||
public static final BlockData STONE = Material.STONE.createBlockData();
|
public static final BlockData STONE = Material.STONE.createBlockData();
|
||||||
public static final BlockData WATER = Material.WATER.createBlockData();
|
public static final BlockData WATER = Material.WATER.createBlockData();
|
||||||
|
|
||||||
@ -66,8 +67,28 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
private IrisGeneratorStyle continentalStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
private IrisGeneratorStyle continentalStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The placement style of land/sea")
|
@Desc("The placement style of biomes")
|
||||||
private IrisGeneratorStyle coordinateFracture = NoiseStyle.FLAT.style();
|
private IrisGeneratorStyle landBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The placement style of biomes")
|
||||||
|
private IrisGeneratorStyle shoreBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The placement style of biomes")
|
||||||
|
private IrisGeneratorStyle seaBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The placement style of biomes")
|
||||||
|
private IrisGeneratorStyle caveBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The placement style of biomes")
|
||||||
|
private IrisGeneratorStyle islandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
|
@DontObfuscate
|
||||||
|
@Desc("The placement style of biomes")
|
||||||
|
private IrisGeneratorStyle skylandBiomeStyle = NoiseStyle.CELLULAR_IRIS_DOUBLE.style();
|
||||||
|
|
||||||
@MinNumber(-256)
|
@MinNumber(-256)
|
||||||
@MaxNumber(256)
|
@MaxNumber(256)
|
||||||
@ -277,29 +298,33 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
private transient AtomicCache<Double> rad = new AtomicCache<>();
|
private transient AtomicCache<Double> rad = new AtomicCache<>();
|
||||||
private transient boolean inverted = false;
|
private transient boolean inverted = false;
|
||||||
|
|
||||||
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g) {
|
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g)
|
||||||
return cacheFilters.aquire(() -> {
|
{
|
||||||
|
return cacheFilters.aquire(() ->
|
||||||
|
{
|
||||||
KList<IrisPostBlockFilter> cacheFilters = new KList<>();
|
KList<IrisPostBlockFilter> cacheFilters = new KList<>();
|
||||||
|
|
||||||
for (IrisPostProcessor i : getPostProcessors()) {
|
for(IrisPostProcessor i : getPostProcessors())
|
||||||
|
{
|
||||||
cacheFilters.add(g.createProcessor(i.getProcessor(), i.getPhase()));
|
cacheFilters.add(g.createProcessor(i.getProcessor(), i.getPhase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
g.setMinPhase(0);
|
g.setMinPhase(0);
|
||||||
g.setMaxPhase(0);
|
g.setMaxPhase(0);
|
||||||
|
|
||||||
for (IrisPostBlockFilter i : cacheFilters) {
|
for(IrisPostBlockFilter i : cacheFilters)
|
||||||
|
{
|
||||||
g.setMinPhase(Math.min(g.getMinPhase(), i.getPhase()));
|
g.setMinPhase(Math.min(g.getMinPhase(), i.getPhase()));
|
||||||
g.setMaxPhase(Math.max(g.getMaxPhase(), i.getPhase()));
|
g.setMaxPhase(Math.max(g.getMaxPhase(), i.getPhase()));
|
||||||
}
|
}
|
||||||
|
|
||||||
Iris.info("Post Processing: " + cacheFilters.size() + " filters. Phases: " + g.getMinPhase() + " - "
|
Iris.info("Post Processing: " + cacheFilters.size() + " filters. Phases: " + g.getMinPhase() + " - " + g.getMaxPhase());
|
||||||
+ g.getMaxPhase());
|
|
||||||
return cacheFilters;
|
return cacheFilters;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KList<IrisCompatabilityFilter> getDefaultCompatability() {
|
public static KList<IrisCompatabilityFilter> getDefaultCompatability()
|
||||||
|
{
|
||||||
KList<IrisCompatabilityFilter> filters = new KList<>();
|
KList<IrisCompatabilityFilter> filters = new KList<>();
|
||||||
|
|
||||||
// Below 1.16
|
// Below 1.16
|
||||||
@ -438,15 +463,18 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
return filters;
|
return filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getCoordFracture(RNG rng, int signature) {
|
public CNG getCoordFracture(RNG rng, int signature)
|
||||||
return coordFracture.aquire(() -> {
|
{
|
||||||
|
return coordFracture.aquire(() ->
|
||||||
|
{
|
||||||
CNG coordFracture = CNG.signature(rng.nextParallelRNG(signature));
|
CNG coordFracture = CNG.signature(rng.nextParallelRNG(signature));
|
||||||
coordFracture.scale(0.012 / coordFractureZoom);
|
coordFracture.scale(0.012 / coordFractureZoom);
|
||||||
return coordFracture;
|
return coordFracture;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private KList<IrisPostProcessor> getDefaultPostProcessors() {
|
private KList<IrisPostProcessor> getDefaultPostProcessors()
|
||||||
|
{
|
||||||
KList<IrisPostProcessor> p = new KList<IrisPostProcessor>();
|
KList<IrisPostProcessor> p = new KList<IrisPostProcessor>();
|
||||||
|
|
||||||
p.add(new IrisPostProcessor("wall-painter"));
|
p.add(new IrisPostProcessor("wall-painter"));
|
||||||
@ -456,32 +484,40 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getRock(RNG rng, double x, double y, double z) {
|
public BlockData getRock(RNG rng, double x, double y, double z)
|
||||||
if (getRockData().isEmpty()) {
|
{
|
||||||
|
if(getRockData().isEmpty())
|
||||||
|
{
|
||||||
return STONE;
|
return STONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getRockData().size() == 1) {
|
if(getRockData().size() == 1)
|
||||||
|
{
|
||||||
return getRockData().get(0);
|
return getRockData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getRockGenerator(rng).fit(getRockData(), x, y, z);
|
return getRockGenerator(rng).fit(getRockData(), x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getRockGenerator(RNG rng) {
|
public CNG getRockGenerator(RNG rng)
|
||||||
return rockLayerGenerator.aquire(() -> {
|
{
|
||||||
RNG rngx = rng.nextParallelRNG(
|
return rockLayerGenerator.aquire(() ->
|
||||||
(int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
{
|
||||||
|
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||||
return rockStyle.create(rngx);
|
return rockStyle.create(rngx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> getRockData() {
|
public KList<BlockData> getRockData()
|
||||||
return rockData.aquire(() -> {
|
{
|
||||||
|
return rockData.aquire(() ->
|
||||||
|
{
|
||||||
KList<BlockData> rockData = new KList<>();
|
KList<BlockData> rockData = new KList<>();
|
||||||
for (String ix : rockPalette) {
|
for(String ix : rockPalette)
|
||||||
|
{
|
||||||
BlockData bx = B.getBlockData(ix);
|
BlockData bx = B.getBlockData(ix);
|
||||||
if (bx != null) {
|
if(bx != null)
|
||||||
|
{
|
||||||
rockData.add(bx);
|
rockData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -490,32 +526,40 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getFluid(RNG rng, double x, double y, double z) {
|
public BlockData getFluid(RNG rng, double x, double y, double z)
|
||||||
if (getFluidData().isEmpty()) {
|
{
|
||||||
|
if(getFluidData().isEmpty())
|
||||||
|
{
|
||||||
return WATER;
|
return WATER;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getFluidData().size() == 1) {
|
if(getFluidData().size() == 1)
|
||||||
|
{
|
||||||
return getFluidData().get(0);
|
return getFluidData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return getFluidGenerator(rng).fit(getFluidData(), x, y, z);
|
return getFluidGenerator(rng).fit(getFluidData(), x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getFluidGenerator(RNG rng) {
|
public CNG getFluidGenerator(RNG rng)
|
||||||
return fluidLayerGenerator.aquire(() -> {
|
{
|
||||||
RNG rngx = rng.nextParallelRNG(getFluidData().size()
|
return fluidLayerGenerator.aquire(() ->
|
||||||
* (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
{
|
||||||
|
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||||
return fluidStyle.create(rngx);
|
return fluidStyle.create(rngx);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> getFluidData() {
|
public KList<BlockData> getFluidData()
|
||||||
return fluidData.aquire(() -> {
|
{
|
||||||
|
return fluidData.aquire(() ->
|
||||||
|
{
|
||||||
KList<BlockData> fluidData = new KList<>();
|
KList<BlockData> fluidData = new KList<>();
|
||||||
for (String ix : fluidPalette) {
|
for(String ix : fluidPalette)
|
||||||
|
{
|
||||||
BlockData bx = B.getBlockData(ix);
|
BlockData bx = B.getBlockData(ix);
|
||||||
if (bx != null) {
|
if(bx != null)
|
||||||
|
{
|
||||||
fluidData.add(bx);
|
fluidData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -524,40 +568,49 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDimensionAngle() {
|
public double getDimensionAngle()
|
||||||
|
{
|
||||||
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
|
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double sinRotate() {
|
public double sinRotate()
|
||||||
|
{
|
||||||
return sinr.aquire(() -> Math.sin(getDimensionAngle()));
|
return sinr.aquire(() -> Math.sin(getDimensionAngle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public double cosRotate() {
|
public double cosRotate()
|
||||||
|
{
|
||||||
return cosr.aquire(() -> Math.cos(getDimensionAngle()));
|
return cosr.aquire(() -> Math.cos(getDimensionAngle()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisRegion> getAllRegions(ContextualChunkGenerator g) {
|
public KList<IrisRegion> getAllRegions(ContextualChunkGenerator g)
|
||||||
|
{
|
||||||
KList<IrisRegion> r = new KList<>();
|
KList<IrisRegion> r = new KList<>();
|
||||||
|
|
||||||
for (String i : getRegions()) {
|
for(String i : getRegions())
|
||||||
|
{
|
||||||
r.add(g != null ? g.loadRegion(i) : Iris.globaldata.getRegionLoader().load(i));
|
r.add(g != null ? g.loadRegion(i) : Iris.globaldata.getRegionLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g) {
|
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g)
|
||||||
|
{
|
||||||
KList<IrisBiome> r = new KList<>();
|
KList<IrisBiome> r = new KList<>();
|
||||||
|
|
||||||
for (IrisRegion i : getAllRegions(g)) {
|
for(IrisRegion i : getAllRegions(g))
|
||||||
|
{
|
||||||
r.addAll(i.getAllBiomes(g));
|
r.addAll(i.getAllBiomes(g));
|
||||||
}
|
}
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChunkPosition getParallaxSize(ContextualChunkGenerator g) {
|
public ChunkPosition getParallaxSize(ContextualChunkGenerator g)
|
||||||
return parallaxSize.aquire(() -> {
|
{
|
||||||
|
return parallaxSize.aquire(() ->
|
||||||
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
|
|
||||||
@ -565,40 +618,50 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
KList<IrisRegion> r = getAllRegions(g);
|
KList<IrisRegion> r = getAllRegions(g);
|
||||||
KList<IrisBiome> b = getAllBiomes(g);
|
KList<IrisBiome> b = getAllBiomes(g);
|
||||||
|
|
||||||
for (IrisBiome i : b) {
|
for(IrisBiome i : b)
|
||||||
for (IrisObjectPlacement j : i.getObjects()) {
|
{
|
||||||
|
for(IrisObjectPlacement j : i.getObjects())
|
||||||
|
{
|
||||||
objects.addAll(j.getPlace());
|
objects.addAll(j.getPlace());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (String i : objects) {
|
for(String i : objects)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
|
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
|
||||||
x = bv.getBlockX() > x ? bv.getBlockX() : x;
|
x = bv.getBlockX() > x ? bv.getBlockX() : x;
|
||||||
z = bv.getBlockZ() > z ? bv.getBlockZ() : z;
|
z = bv.getBlockZ() > z ? bv.getBlockZ() : z;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch(Throwable e)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisDepositGenerator i : getDeposits()) {
|
for(IrisDepositGenerator i : getDeposits())
|
||||||
|
{
|
||||||
int max = i.getMaxDimension();
|
int max = i.getMaxDimension();
|
||||||
x = max > x ? max : x;
|
x = max > x ? max : x;
|
||||||
z = max > z ? max : z;
|
z = max > z ? max : z;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisRegion v : r) {
|
for(IrisRegion v : r)
|
||||||
for (IrisDepositGenerator i : v.getDeposits()) {
|
{
|
||||||
|
for(IrisDepositGenerator i : v.getDeposits())
|
||||||
|
{
|
||||||
int max = i.getMaxDimension();
|
int max = i.getMaxDimension();
|
||||||
x = max > x ? max : x;
|
x = max > x ? max : x;
|
||||||
z = max > z ? max : z;
|
z = max > z ? max : z;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisBiome v : b) {
|
for(IrisBiome v : b)
|
||||||
for (IrisDepositGenerator i : v.getDeposits()) {
|
{
|
||||||
|
for(IrisDepositGenerator i : v.getDeposits())
|
||||||
|
{
|
||||||
int max = i.getMaxDimension();
|
int max = i.getMaxDimension();
|
||||||
x = max > x ? max : x;
|
x = max > x ? max : x;
|
||||||
z = max > z ? max : z;
|
z = max > z ? max : z;
|
||||||
@ -614,13 +677,39 @@ public class IrisDimension extends IrisRegistrant {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData resolve(String bd) {
|
public BlockData resolve(String bd)
|
||||||
for (IrisCompatabilityFilter i : getCompatability()) {
|
{
|
||||||
if (i.getWhen().equalsIgnoreCase(bd)) {
|
for(IrisCompatabilityFilter i : getCompatability())
|
||||||
|
{
|
||||||
|
if(i.getWhen().equalsIgnoreCase(bd))
|
||||||
|
{
|
||||||
return i.getReplace();
|
return i.getReplace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public IrisGeneratorStyle getBiomeStyle(InferredType type)
|
||||||
|
{
|
||||||
|
switch(type)
|
||||||
|
{
|
||||||
|
case CAVE:
|
||||||
|
return caveBiomeStyle;
|
||||||
|
case ISLAND:
|
||||||
|
return islandBiomeStyle;
|
||||||
|
case LAND:
|
||||||
|
return landBiomeStyle;
|
||||||
|
case SEA:
|
||||||
|
return seaBiomeStyle;
|
||||||
|
case SHORE:
|
||||||
|
return shoreBiomeStyle;
|
||||||
|
case SKYLAND:
|
||||||
|
return skylandBiomeStyle;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return landBiomeStyle;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,8 @@ import com.volmit.iris.object.IrisRegistrant;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
public class ResourceLoader<T extends IrisRegistrant> {
|
public class ResourceLoader<T extends IrisRegistrant>
|
||||||
|
{
|
||||||
protected File root;
|
protected File root;
|
||||||
protected String folderName;
|
protected String folderName;
|
||||||
protected String resourceTypeName;
|
protected String resourceTypeName;
|
||||||
@ -21,7 +22,8 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
protected IrisLock lock;
|
protected IrisLock lock;
|
||||||
protected String preferredFolder = null;
|
protected String preferredFolder = null;
|
||||||
|
|
||||||
public ResourceLoader(File root, String folderName, String resourceTypeName, Class<? extends T> objectClass) {
|
public ResourceLoader(File root, String folderName, String resourceTypeName, Class<? extends T> objectClass)
|
||||||
|
{
|
||||||
lock = new IrisLock("Res");
|
lock = new IrisLock("Res");
|
||||||
folderMapCache = new KMap<>();
|
folderMapCache = new KMap<>();
|
||||||
this.objectClass = objectClass;
|
this.objectClass = objectClass;
|
||||||
@ -32,12 +34,15 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
loadCache = new KMap<>();
|
loadCache = new KMap<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public long count() {
|
public long count()
|
||||||
|
{
|
||||||
return loadCache.size();
|
return loadCache.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected T loadFile(File j, String key, String name) {
|
protected T loadFile(File j, String key, String name)
|
||||||
try {
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
T t = new Gson().fromJson(IO.readAll(j), objectClass);
|
T t = new Gson().fromJson(IO.readAll(j), objectClass);
|
||||||
loadCache.put(key, t);
|
loadCache.put(key, t);
|
||||||
Iris.hotloader.track(j);
|
Iris.hotloader.track(j);
|
||||||
@ -48,32 +53,39 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
catch (Throwable e) {
|
catch(Throwable e)
|
||||||
|
{
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
Iris.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage());
|
Iris.warn("Couldn't read " + resourceTypeName + " file: " + j.getPath() + ": " + e.getMessage());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public T load(String name) {
|
public T load(String name)
|
||||||
|
{
|
||||||
String key = name + "-" + cname;
|
String key = name + "-" + cname;
|
||||||
|
|
||||||
if (loadCache.containsKey(key)) {
|
if(loadCache.containsKey(key))
|
||||||
|
{
|
||||||
T t = loadCache.get(key);
|
T t = loadCache.get(key);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
for (File i : getFolders(name)) {
|
for(File i : getFolders(name))
|
||||||
for (File j : i.listFiles()) {
|
{
|
||||||
if (j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(name)) {
|
for(File j : i.listFiles())
|
||||||
|
{
|
||||||
|
if(j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(name))
|
||||||
|
{
|
||||||
return loadFile(j, key, name);
|
return loadFile(j, key, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(i, name + ".json");
|
File file = new File(i, name + ".json");
|
||||||
|
|
||||||
if (file.exists()) {
|
if(file.exists())
|
||||||
|
{
|
||||||
return loadFile(file, key, name);
|
return loadFile(file, key, name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -84,15 +96,21 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<File> getFolders() {
|
public KList<File> getFolders()
|
||||||
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
if (folderCache == null) {
|
if(folderCache == null)
|
||||||
|
{
|
||||||
folderCache = new KList<>();
|
folderCache = new KList<>();
|
||||||
|
|
||||||
for (File i : root.listFiles()) {
|
for(File i : root.listFiles())
|
||||||
if (i.isDirectory()) {
|
{
|
||||||
for (File j : i.listFiles()) {
|
if(i.isDirectory())
|
||||||
if (j.isDirectory() && j.getName().equals(folderName)) {
|
{
|
||||||
|
for(File j : i.listFiles())
|
||||||
|
{
|
||||||
|
if(j.isDirectory() && j.getName().equals(folderName))
|
||||||
|
{
|
||||||
folderCache.add(j);
|
folderCache.add(j);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -100,9 +118,12 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (preferredFolder != null) {
|
if(preferredFolder != null)
|
||||||
for (File i : folderCache.copy()) {
|
{
|
||||||
if (i.getParentFile().getName().equals(preferredFolder)) {
|
for(File i : folderCache.copy())
|
||||||
|
{
|
||||||
|
if(i.getParentFile().getName().equals(preferredFolder))
|
||||||
|
{
|
||||||
folderCache.remove(i);
|
folderCache.remove(i);
|
||||||
folderCache.add(0, i);
|
folderCache.add(0, i);
|
||||||
}
|
}
|
||||||
@ -114,12 +135,16 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
return folderCache;
|
return folderCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<File> getFolders(String rc) {
|
public KList<File> getFolders(String rc)
|
||||||
|
{
|
||||||
KList<File> folders = getFolders().copy();
|
KList<File> folders = getFolders().copy();
|
||||||
|
|
||||||
if (rc.contains(":")) {
|
if(rc.contains(":"))
|
||||||
for (File i : folders.copy()) {
|
{
|
||||||
if (!rc.startsWith(i.getName() + ":")) {
|
for(File i : folders.copy())
|
||||||
|
{
|
||||||
|
if(!rc.startsWith(i.getName() + ":"))
|
||||||
|
{
|
||||||
folders.remove(i);
|
folders.remove(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -128,23 +153,28 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
return folders;
|
return folders;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clearCache() {
|
public void clearCache()
|
||||||
|
{
|
||||||
loadCache.clear();
|
loadCache.clear();
|
||||||
folderCache = null;
|
folderCache = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public File fileFor(T b) {
|
public File fileFor(T b)
|
||||||
for (File i : getFolders()) {
|
{
|
||||||
for (File j : i.listFiles()) {
|
for(File i : getFolders())
|
||||||
if (j.isFile() && j.getName().endsWith(".json")
|
{
|
||||||
&& j.getName().split("\\Q.\\E")[0].equals(b.getLoadKey())) {
|
for(File j : i.listFiles())
|
||||||
|
{
|
||||||
|
if(j.isFile() && j.getName().endsWith(".json") && j.getName().split("\\Q.\\E")[0].equals(b.getLoadKey()))
|
||||||
|
{
|
||||||
return j;
|
return j;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(i, b.getLoadKey() + ".json");
|
File file = new File(i, b.getLoadKey() + ".json");
|
||||||
|
|
||||||
if (file.exists()) {
|
if(file.exists())
|
||||||
|
{
|
||||||
return file;
|
return file;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,11 +182,13 @@ public class ResourceLoader<T extends IrisRegistrant> {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoaded(String next) {
|
public boolean isLoaded(String next)
|
||||||
|
{
|
||||||
return loadCache.containsKey(next);
|
return loadCache.containsKey(next);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void preferFolder(String name) {
|
public void preferFolder(String name)
|
||||||
|
{
|
||||||
preferredFolder = name;
|
preferredFolder = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user