mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-12-29 12:09:07 +00:00
Biome implosion
This commit is contained in:
@@ -6,7 +6,6 @@ import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
|
||||
import com.volmit.iris.link.CitizensLink;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
@@ -24,6 +23,7 @@ import com.volmit.iris.gen.provisions.ProvisionBukkit;
|
||||
import com.volmit.iris.gen.scaffold.IrisGenConfiguration;
|
||||
import com.volmit.iris.gen.scaffold.IrisWorlds;
|
||||
import com.volmit.iris.gen.scaffold.TerrainTarget;
|
||||
import com.volmit.iris.link.CitizensLink;
|
||||
import com.volmit.iris.link.MultiverseCoreLink;
|
||||
import com.volmit.iris.link.MythicMobsLink;
|
||||
import com.volmit.iris.manager.EditManager;
|
||||
@@ -85,7 +85,7 @@ public class Iris extends MortarPlugin
|
||||
instance = this;
|
||||
INMS.get();
|
||||
IO.delete(new File("iris"));
|
||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4gb
|
||||
lowMemoryMode = Runtime.getRuntime().maxMemory() < 4000000000L; // 4 * 1000 * 1000 * 1000 // 4g
|
||||
}
|
||||
|
||||
public static int getThreadCount()
|
||||
|
||||
@@ -4,9 +4,11 @@ import org.bukkit.Material;
|
||||
import org.bukkit.block.data.BlockData;
|
||||
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.layer.GenLayerBiome;
|
||||
import com.volmit.iris.gen.v2.scaffold.layer.ProceduralStream;
|
||||
import com.volmit.iris.gen.v2.scaffold.stream.Interpolated;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.object.InferredType;
|
||||
import com.volmit.iris.object.IrisBiome;
|
||||
import com.volmit.iris.object.IrisBiomePaletteLayer;
|
||||
@@ -22,12 +24,14 @@ import lombok.Data;
|
||||
@Data
|
||||
public class IrisComplex implements DataProvider
|
||||
{
|
||||
private RNG rng;
|
||||
private IrisDataManager data;
|
||||
private KList<IrisGenerator> generators;
|
||||
private static final BlockData AIR = Material.AIR.createBlockData();
|
||||
private ProceduralStream<IrisRegion> regionStream;
|
||||
private ProceduralStream<InferredType> bridgeStream;
|
||||
private ProceduralStream<IrisBiome> landBiomeStream;
|
||||
private ProceduralStream<IrisBiome> caveBiomeStream;
|
||||
private ProceduralStream<IrisBiome> seaBiomeStream;
|
||||
private ProceduralStream<IrisBiome> shoreBiomeStream;
|
||||
private ProceduralStream<IrisBiome> baseBiomeStream;
|
||||
@@ -47,7 +51,7 @@ public class IrisComplex implements DataProvider
|
||||
switch(type)
|
||||
{
|
||||
case CAVE:
|
||||
break;
|
||||
return caveBiomeStream;
|
||||
case DEFER:
|
||||
break;
|
||||
case LAKE:
|
||||
@@ -69,6 +73,7 @@ public class IrisComplex implements DataProvider
|
||||
|
||||
public void flash(long seed, IrisDimension dimension, IrisDataManager data)
|
||||
{
|
||||
this.rng = new RNG(seed);
|
||||
this.data = data;
|
||||
double fluidHeight = dimension.getFluidHeight();
|
||||
generators = new KList<>();
|
||||
@@ -89,24 +94,31 @@ public class IrisComplex implements DataProvider
|
||||
.select(dimension.getRegions())
|
||||
.convertCached((s) -> data.getRegionLoader().load(s))
|
||||
.cache2D(1024);
|
||||
caveBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getCaveBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getCaveBiomeZoom())
|
||||
.selectRarity(r.getCaveBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
landBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getLandBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getLandBiomeZoom())
|
||||
.select(r.getLandBiomes())
|
||||
.selectRarity(r.getLandBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
seaBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getSeaBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getSeaBiomeZoom())
|
||||
.select(r.getSeaBiomes())
|
||||
.selectRarity(r.getSeaBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
shoreBiomeStream = regionStream.convertCached((r)
|
||||
-> dimension.getShoreBiomeStyle().create(rng.nextRNG()).stream()
|
||||
.zoom(r.getShoreBiomeZoom())
|
||||
.select(r.getShoreBiomes())
|
||||
.selectRarity(r.getShoreBiomes())
|
||||
.convertCached((s) -> data.getBiomeLoader().load(s))
|
||||
).convertAware2D((str, x, z) -> str.get(x, z))
|
||||
.cache2D(1024);
|
||||
@@ -114,6 +126,7 @@ public class IrisComplex implements DataProvider
|
||||
.convert((v) -> v >= dimension.getLandChance() ? InferredType.SEA : InferredType.LAND);
|
||||
baseBiomeStream = bridgeStream.convertAware2D((t, x, z) -> t.equals(InferredType.SEA)
|
||||
? seaBiomeStream.get(x, z) : landBiomeStream.get(x, z))
|
||||
.convertAware2D(this::implode)
|
||||
.cache2D(1024);
|
||||
heightStream = baseBiomeStream.convertAware2D((b, x, z) -> getHeight(b, x, z, seed))
|
||||
.forceDouble().add(fluidHeight).roundDouble()
|
||||
@@ -163,6 +176,36 @@ public class IrisComplex implements DataProvider
|
||||
//@done
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z)
|
||||
{
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
return implode(b, x, z, 3);
|
||||
}
|
||||
|
||||
private IrisBiome implode(IrisBiome b, Double x, Double z, int max)
|
||||
{
|
||||
if(max < 0)
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
if(b.getChildren().isEmpty())
|
||||
{
|
||||
return b;
|
||||
}
|
||||
|
||||
CNG childCell = b.getChildrenGenerator(rng, 123, b.getChildShrinkFactor());
|
||||
KList<IrisBiome> chx = b.getRealChildren(this).copy();
|
||||
chx.add(b);
|
||||
IrisBiome biome = childCell.fitRarity(chx, x, z);
|
||||
biome.setInferredType(b.getInferredType());
|
||||
return implode(biome, x, z, max - 1);
|
||||
}
|
||||
|
||||
private IrisBiome fixBiomeType(Double height, IrisBiome biome, IrisRegion region, Double x, Double z, double fluidHeight)
|
||||
{
|
||||
double sh = region.getShoreHeight(x, z);
|
||||
|
||||
@@ -30,6 +30,8 @@ import com.volmit.iris.gen.v2.scaffold.stream.ZoomStream;
|
||||
import com.volmit.iris.util.Function2;
|
||||
import com.volmit.iris.util.Function3;
|
||||
import com.volmit.iris.util.Function4;
|
||||
import com.volmit.iris.util.IRare;
|
||||
import com.volmit.iris.util.KList;
|
||||
|
||||
public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
{
|
||||
@@ -218,6 +220,26 @@ public interface ProceduralStream<T> extends ProceduralLayer, Interpolated<T>
|
||||
return new SelectionStream<V>(this, types);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
default <V> ProceduralStream<V> selectRarity(V... types)
|
||||
{
|
||||
KList<V> rarityTypes = new KList<>();
|
||||
|
||||
for(V i : types)
|
||||
{
|
||||
rarityTypes.addMultiple(i, IRare.get(i));
|
||||
}
|
||||
|
||||
return new SelectionStream<V>(this, rarityTypes);
|
||||
}
|
||||
|
||||
default <V> ProceduralStream<V> selectRarity(List<V> types)
|
||||
{
|
||||
KList<V> rarityTypes = new KList<>();
|
||||
types.forEach((i) -> rarityTypes.addMultiple(i, IRare.get(i)));
|
||||
return new SelectionStream<V>(this, rarityTypes);
|
||||
}
|
||||
|
||||
default ProceduralStream<T> clamp(double min, double max)
|
||||
{
|
||||
return new ClampedStream<T>(this, min, max);
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.bukkit.block.Biome;
|
||||
import com.volmit.iris.Iris;
|
||||
import com.volmit.iris.gen.ContextualTerrainProvider;
|
||||
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||
import com.volmit.iris.gen.v2.DataProvider;
|
||||
import com.volmit.iris.manager.IrisDataManager;
|
||||
import com.volmit.iris.noise.CNG;
|
||||
import com.volmit.iris.util.ArrayType;
|
||||
@@ -611,7 +612,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
|
||||
}
|
||||
|
||||
public KList<IrisBiome> getRealChildren(ContextualTerrainProvider g)
|
||||
public KList<IrisBiome> getRealChildren(DataProvider g)
|
||||
{
|
||||
return realChildren.aquire(() ->
|
||||
{
|
||||
@@ -619,7 +620,7 @@ public class IrisBiome extends IrisRegistrant implements IRare
|
||||
|
||||
for(String i : getChildren())
|
||||
{
|
||||
realChildren.add(g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i));
|
||||
realChildren.add(g != null ? g.getData().getBiomeLoader().load(i) : Iris.globaldata.getBiomeLoader().load(i));
|
||||
}
|
||||
|
||||
return realChildren;
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
package com.volmit.iris.util;
|
||||
|
||||
public interface IRare {
|
||||
public interface IRare
|
||||
{
|
||||
public int getRarity();
|
||||
|
||||
public static int get(Object v)
|
||||
{
|
||||
return v instanceof IRare ? ((IRare) v).getRarity() : 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,14 @@ public class KList<T> extends ArrayList<T> implements List<T>
|
||||
return this;
|
||||
}
|
||||
|
||||
public void addMultiple(T t, int c)
|
||||
{
|
||||
for(int i = 0; i < c; i++)
|
||||
{
|
||||
add(t);
|
||||
}
|
||||
}
|
||||
|
||||
private KList<T> add(Enumeration<T> e)
|
||||
{
|
||||
while(e.hasMoreElements())
|
||||
@@ -688,7 +696,7 @@ public class KList<T> extends ArrayList<T> implements List<T>
|
||||
add(t);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user