9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 11:09:06 +00:00

Loads of bugfixes & Seed cohesion

This commit is contained in:
Daniel Mills
2020-07-29 22:31:16 -04:00
parent 84e81e9ce0
commit 36e5fec284
26 changed files with 739 additions and 118 deletions

View File

@@ -5,11 +5,13 @@ import java.util.concurrent.locks.ReentrantLock;
import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.Iris;
import com.volmit.iris.util.CNG;
import com.volmit.iris.util.CellGenerator;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KSet;
import com.volmit.iris.util.RNG;
import lombok.Data;
@@ -103,6 +105,7 @@ public class IrisBiome extends IrisRegistrant
private transient KList<CNG> layerSeaHeightGenerators;
private transient KList<CNG> layerSurfaceGenerators;
private transient KList<CNG> layerSeaSurfaceGenerators;
private transient KList<IrisBiome> realChildren;
public IrisBiome()
{
@@ -125,7 +128,7 @@ public class IrisBiome extends IrisRegistrant
{
if(biomeGenerator == null)
{
biomeGenerator = CNG.signature(random.nextParallelRNG(213949 + hashCode())).scale(biomeDispersion.equals(Dispersion.SCATTER) ? 1000D : 0.1D);
biomeGenerator = CNG.signature(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())).scale(biomeDispersion.equals(Dispersion.SCATTER) ? 1000D : 0.1D);
}
return biomeGenerator;
@@ -389,6 +392,44 @@ public class IrisBiome extends IrisRegistrant
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
}
public KList<IrisBiome> getRealChildren()
{
lock.lock();
if(realChildren == null)
{
realChildren = new KList<>();
for(String i : getChildren())
{
realChildren.add(Iris.data.getBiomeLoader().load(i));
}
}
lock.unlock();
return realChildren;
}
public KList<String> getAllChildren(int limit)
{
KSet<String> m = new KSet<>();
m.addAll(getChildren());
limit--;
if(limit > 0)
{
for(String i : getChildren())
{
IrisBiome b = Iris.data.getBiomeLoader().load(i);
int l = limit;
m.addAll(b.getAllChildren(l));
}
}
return new KList<String>(m);
}
public Biome getGroundBiome(RNG rng, double x, double y, double z)
{
if(biomeSkyScatter.isEmpty())

View File

@@ -59,7 +59,6 @@ public class IrisBiomeDecorator
private transient KMap<Long, CNG> layerGenerators;
private transient CNG heightGenerator;
private transient KList<BlockData> blockData;
private transient RNG nrng;
public int getHeight(RNG rng, double x, double z)
{
@@ -121,19 +120,15 @@ public class IrisBiomeDecorator
return null;
}
if(nrng == null)
{
nrng = rng.nextParallelRNG(2398552 + hashCode());
}
RNG nrng = rng.nextParallelRNG((int) (z - (int) ((x + 34856) * (int) (x + z + (int) (28835521 + (getChance() * 1000) + getStackMin() + getStackMax() + (getZoom() * 556))))));
double xx = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-100000, 100000) : x;
double zz = dispersion.equals(Dispersion.SCATTER) ? nrng.i(-100000, 100000) : z;
if(getGenerator(rng).fitDoubleD(0D, 1D, xx, zz) <= chance)
if(getGenerator(nrng).fitDoubleD(0D, 1D, xx, zz) <= chance)
{
try
{
return getBlockData().get(getGenerator(rng.nextParallelRNG(53)).fit(0, getBlockData().size() - 1, xx, zz));
return getBlockData().get(getGenerator(rng.nextParallelRNG((int) (5369431 + z + x + xx + zz))).fit(0, getBlockData().size() - 1, xx, zz));
}
catch(Throwable e)

View File

@@ -0,0 +1,97 @@
package com.volmit.iris.object;
import com.volmit.iris.Iris;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KSet;
import lombok.Data;
@Desc("A biome mutation if a condition is met")
@Data
public class IrisBiomeMutation
{
@DontObfuscate
@Desc("One of The following biomes or regions must show up")
private KList<String> sideA = new KList<>();
@DontObfuscate
@Desc("One of The following biomes or regions must show up")
private KList<String> sideB = new KList<>();
@DontObfuscate
@Desc("The scan radius for placing this mutator")
private int radius = 1;
@DontObfuscate
@Desc("How many tries per chunk to check for this mutation")
private int checks = 2;
@DontObfuscate
@Desc("Objects define what schematics (iob files) iris will place in this biome mutation")
private KList<IrisObjectPlacement> objects = new KList<IrisObjectPlacement>();
private transient KList<String> sideACache;
private transient KList<String> sideBCache;
public KList<String> getRealSideA()
{
if(sideACache == null)
{
sideACache = processList(getSideA());
}
return sideACache;
}
public KList<String> getRealSideB()
{
if(sideBCache == null)
{
sideBCache = processList(getSideB());
}
return sideBCache;
}
public KList<String> processList(KList<String> s)
{
KSet<String> r = new KSet<>();
for(String i : s)
{
String q = i;
if(q.startsWith("^"))
{
r.addAll(Iris.data.getRegionLoader().load(q.substring(1)).getLandBiomes());
continue;
}
else if(q.startsWith("*"))
{
String name = q.substring(1);
r.addAll(Iris.data.getBiomeLoader().load(name).getAllChildren(7));
}
else if(q.startsWith("!"))
{
r.remove(q.substring(1));
}
else if(q.startsWith("!*"))
{
String name = q.substring(2);
r.removeAll(Iris.data.getBiomeLoader().load(name).getAllChildren(7));
}
else
{
r.add(q);
}
}
return new KList<String>(r);
}
}

View File

@@ -97,6 +97,11 @@ public class IrisDepositGenerator
return p;
}
public int getMaxDimension()
{
return (int) Math.round(Math.pow(maxSize, 1D / 3D));
}
private IrisObject generateClumpObject(RNG rngv)
{
int s = rngv.i(minSize, maxSize);

View File

@@ -4,15 +4,18 @@ import java.util.concurrent.locks.ReentrantLock;
import org.bukkit.World.Environment;
import org.bukkit.block.data.BlockData;
import org.bukkit.util.BlockVector;
import com.volmit.iris.Iris;
import com.volmit.iris.generator.PostBlockChunkGenerator;
import com.volmit.iris.util.BlockDataTools;
import com.volmit.iris.util.CNG;
import com.volmit.iris.util.ChunkPosition;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.IrisPostBlockFilter;
import com.volmit.iris.util.KList;
import com.volmit.iris.util.KSet;
import com.volmit.iris.util.RNG;
import lombok.Data;
@@ -171,7 +174,13 @@ public class IrisDimension extends IrisRegistrant
@Desc("The palette of blocks for 'water'")
private KList<String> fluidPalette = new KList<String>().qadd("WATER");
@DontObfuscate
@Desc("Define biome mutations for this dimension")
private KList<IrisBiomeMutation> mutations = new KList<>();
private transient ChunkPosition parallaxSize;
private transient ReentrantLock rockLock = new ReentrantLock();
private transient ReentrantLock parLock = new ReentrantLock();
private transient ReentrantLock fluidLock = new ReentrantLock();
private transient KList<BlockData> rockData;
private transient KList<BlockData> fluidData;
@@ -265,7 +274,7 @@ public class IrisDimension extends IrisRegistrant
public void cacheRockGenerator(RNG rng)
{
RNG rngx = rng.nextParallelRNG(getRockData().size() * hashCode());
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
switch(dispersion)
{
@@ -330,7 +339,7 @@ public class IrisDimension extends IrisRegistrant
public void cacheFluidGenerator(RNG rng)
{
RNG rngx = rng.nextParallelRNG(getFluidData().size() * hashCode());
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
switch(dispersion)
{
@@ -394,4 +403,103 @@ public class IrisDimension extends IrisRegistrant
return cosr;
}
public KList<IrisRegion> getAllRegions()
{
KList<IrisRegion> r = new KList<>();
for(String i : getRegions())
{
r.add(Iris.data.getRegionLoader().load(i));
}
return r;
}
public KList<IrisBiome> getAllBiomes()
{
KList<IrisBiome> r = new KList<>();
for(IrisRegion i : getAllRegions())
{
r.addAll(i.getAllBiomes());
}
return r;
}
public ChunkPosition getParallaxSize()
{
parLock.lock();
if(parallaxSize == null)
{
int x = 0;
int z = 0;
KSet<String> objects = new KSet<>();
KList<IrisRegion> r = getAllRegions();
KList<IrisBiome> b = getAllBiomes();
for(IrisBiome i : b)
{
for(IrisObjectPlacement j : i.getObjects())
{
objects.addAll(j.getPlace());
}
}
for(String i : objects)
{
try
{
BlockVector bv = IrisObject.sampleSize(Iris.data.getObjectLoader().findFile(i));
x = bv.getBlockX() > x ? bv.getBlockX() : x;
z = bv.getBlockZ() > z ? bv.getBlockZ() : z;
}
catch(Throwable e)
{
}
}
for(IrisDepositGenerator i : getDeposits())
{
int max = i.getMaxDimension();
x = max > x ? max : x;
z = max > z ? max : z;
}
for(IrisRegion v : r)
{
for(IrisDepositGenerator i : v.getDeposits())
{
int max = i.getMaxDimension();
x = max > x ? max : x;
z = max > z ? max : z;
}
}
for(IrisBiome v : b)
{
for(IrisDepositGenerator i : v.getDeposits())
{
int max = i.getMaxDimension();
x = max > x ? max : x;
z = max > z ? max : z;
}
}
x = (Math.max(x, 16) + 16) >> 4;
z = (Math.max(z, 16) + 16) >> 4;
x = x % 2 == 0 ? x + 1 : x;
z = z % 2 == 0 ? z + 1 : z;
parallaxSize = new ChunkPosition(x, z);
Iris.info("Parallax Size: " + x + ", " + z);
}
parLock.unlock();
return parallaxSize;
}
}

View File

@@ -76,7 +76,7 @@ public class IrisGenerator extends IrisRegistrant
return 0;
}
int hc = hashCode();
int hc = (int) ((cliffHeightMin * 10) + 10 + cliffHeightMax + interpolationScale * seed + offsetX + offsetZ);
double h = 0;
double tp = 0;
@@ -93,12 +93,12 @@ public class IrisGenerator extends IrisRegistrant
Iris.warn("Nan value on gen: " + getLoadKey() + ": H = " + h + " TP = " + tp + " OPACITY = " + opacity + " ZOOM = " + zoom);
}
return hasCliffs() ? cliff(rx, rz, v, superSeed + 294596) : v;
return hasCliffs() ? cliff(rx, rz, v, superSeed + 294596 + hc) : v;
}
public double getCliffHeight(double rx, double rz, double superSeed)
{
int hc = hashCode();
int hc = (int) ((cliffHeightMin * 10) + 10 + cliffHeightMax + interpolationScale * seed + offsetX + offsetZ);
double h = cliffHeightGenerator.getNoise((long) (seed + superSeed + hc), (rx + offsetX) / zoom, (rz + offsetZ) / zoom);
return IrisInterpolation.lerp(cliffHeightMin, cliffHeightMax, h);
}

View File

@@ -157,7 +157,7 @@ public class IrisObject extends IrisRegistrant
for(IrisObjectReplace j : config.getEdit())
{
if(j.getFind().matches(data))
if(j.isExact() ? j.getFind().matches(data) : j.getFind().getMaterial().equals(data.getMaterial()))
{
data = j.getReplace();
}

View File

@@ -20,6 +20,9 @@ public class IrisObjectReplace
@DontObfuscate
private String replace;
@DontObfuscate
private boolean exact = false;
private transient ReentrantLock lock = new ReentrantLock();
private transient BlockData findData;
private transient BlockData replaceData;

View File

@@ -107,6 +107,13 @@ public class IrisRegion extends IrisRegistrant
private transient CNG shoreHeightGenerator;
private transient ReentrantLock lock = new ReentrantLock();
private transient KList<IrisBiome> realLandBiomes;
private transient KList<IrisBiome> realSeaBiomes;
private transient KList<IrisBiome> realShoreBiomes;
private transient KList<IrisBiome> realIslandBiomes;
private transient KList<IrisBiome> realSkylandBiomes;
private transient KList<IrisBiome> realCaveBiomes;
public double getBiomeZoom(InferredType t)
{
switch(t)
@@ -165,7 +172,7 @@ public class IrisRegion extends IrisRegistrant
if(shoreHeightGenerator == null)
{
lock.lock();
shoreHeightGenerator = CNG.signature(new RNG(hashCode()));
shoreHeightGenerator = CNG.signature(new RNG((long) (getName().length() + getIslandBiomes().size() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)));
lock.unlock();
}
@@ -202,38 +209,152 @@ public class IrisRegion extends IrisRegistrant
return b.v();
}
public KList<String> getBiomes(InferredType type)
public KList<IrisBiome> getBiomes(InferredType type)
{
if(type.equals(InferredType.LAND))
{
return getLandBiomes();
return getRealLandBiomes();
}
else if(type.equals(InferredType.SEA))
{
return getSeaBiomes();
return getRealSeaBiomes();
}
else if(type.equals(InferredType.SHORE))
{
return getShoreBiomes();
return getRealShoreBiomes();
}
else if(type.equals(InferredType.CAVE))
{
return getCaveBiomes();
return getRealCaveBiomes();
}
else if(type.equals(InferredType.ISLAND))
{
return getIslandBiomes();
return getRealIslandBiomes();
}
else if(type.equals(InferredType.SKYLAND))
{
return getSkylandBiomes();
return getRealSkylandBiomes();
}
return new KList<>();
}
public KList<IrisBiome> getRealCaveBiomes()
{
lock.lock();
if(realCaveBiomes == null)
{
realCaveBiomes = new KList<>();
for(String i : getCaveBiomes())
{
realCaveBiomes.add(Iris.data.getBiomeLoader().load(i));
}
}
lock.unlock();
return realCaveBiomes;
}
public KList<IrisBiome> getRealSkylandBiomes()
{
lock.lock();
if(realSkylandBiomes == null)
{
realSkylandBiomes = new KList<>();
for(String i : getSkylandBiomes())
{
realSkylandBiomes.add(Iris.data.getBiomeLoader().load(i));
}
}
lock.unlock();
return realSkylandBiomes;
}
public KList<IrisBiome> getRealIslandBiomes()
{
lock.lock();
if(realIslandBiomes == null)
{
realIslandBiomes = new KList<>();
for(String i : getIslandBiomes())
{
realIslandBiomes.add(Iris.data.getBiomeLoader().load(i));
}
}
lock.unlock();
return realIslandBiomes;
}
public KList<IrisBiome> getRealShoreBiomes()
{
lock.lock();
if(realShoreBiomes == null)
{
realShoreBiomes = new KList<>();
for(String i : getShoreBiomes())
{
realShoreBiomes.add(Iris.data.getBiomeLoader().load(i));
}
}
lock.unlock();
return realShoreBiomes;
}
public KList<IrisBiome> getRealSeaBiomes()
{
lock.lock();
if(realSeaBiomes == null)
{
realSeaBiomes = new KList<>();
for(String i : getSeaBiomes())
{
realSeaBiomes.add(Iris.data.getBiomeLoader().load(i));
}
}
lock.unlock();
return realSeaBiomes;
}
public KList<IrisBiome> getRealLandBiomes()
{
lock.lock();
if(realLandBiomes == null)
{
realLandBiomes = new KList<>();
for(String i : getLandBiomes())
{
realLandBiomes.add(Iris.data.getBiomeLoader().load(i));
}
}
lock.unlock();
return realLandBiomes;
}
}

View File

@@ -59,14 +59,14 @@ public class IrisRegionRidge
{
if(ridge == null)
{
ridge = new CellGenerator(rng.nextParallelRNG(165583 * hashCode()));
ridge = new CellGenerator(rng.nextParallelRNG((int) (465583 * getChance())));
ridge.setCellScale(scale);
ridge.setShuffle(shuffle);
}
if(spot == null)
{
spot = new CellGenerator(rng.nextParallelRNG(168523 * hashCode()));
spot = new CellGenerator(rng.nextParallelRNG((int) (198523 * getChance())));
spot.setCellScale(chanceScale);
spot.setShuffle(shuffle);
}

View File

@@ -46,7 +46,7 @@ public class IrisRegionSpot
{
if(spot == null)
{
spot = new CellGenerator(rng.nextParallelRNG(168583 * hashCode()));
spot = new CellGenerator(rng.nextParallelRNG((int) (168583 * (shuffle + 102) + rarity + (scale * 10465) + biome.length() + type.ordinal() + as.ordinal())));
spot.setCellScale(scale);
spot.setShuffle(shuffle);
}

View File

@@ -26,6 +26,11 @@ public class AtomicRegionData
tag = new KMap<>();
}
public int size()
{
return tag.size();
}
public void read(InputStream in) throws IOException
{
NBTInputStream nin = new NBTInputStream(in);

View File

@@ -14,6 +14,7 @@ import com.volmit.iris.object.IrisBiome;
import com.volmit.iris.util.BlockDataTools;
import com.volmit.iris.util.HeightMap;
import com.volmit.iris.util.KMap;
import com.volmit.iris.util.M;
import lombok.Data;
@@ -26,6 +27,7 @@ public class AtomicSliver
private KMap<Integer, Biome> biome;
private int highestBlock = 0;
private int highestBiome = 0;
private long last = M.ms();
private int x;
private int z;
@@ -46,6 +48,7 @@ public class AtomicSliver
public BlockData get(int h)
{
BlockData b = block.get(h);
last = M.ms();
if(b == null)
{
@@ -83,11 +86,13 @@ public class AtomicSliver
public Biome getBiome(int h)
{
last = M.ms();
return biome.containsKey(h) ? biome.get(h) : Biome.THE_VOID;
}
public IrisBiome getTrueBiome(int h)
{
last = M.ms();
return truebiome.get(h);
}
@@ -185,4 +190,9 @@ public class AtomicSliver
}
}
}
public boolean isOlderThan(long m)
{
return M.ms() - last > m;
}
}

View File

@@ -21,7 +21,7 @@ public class AtomicWorldData
private KMap<ChunkPosition, Long> lastRegion;
private KMap<ChunkPosition, Long> lastChunk;
private String prefix;
private ChronoLatch cl = new ChronoLatch(15000);
private ChronoLatch cl = new ChronoLatch(3000);
public AtomicWorldData(World world, String prefix)
{
@@ -102,6 +102,7 @@ public class AtomicWorldData
{
if(!isSectionLoaded(s))
{
Iris.warn("Cant unload because section isnt loaded?");
return false;
}
@@ -111,6 +112,7 @@ public class AtomicWorldData
}
loadedSections.remove(s);
lastRegion.remove(s);
return true;
}
@@ -123,6 +125,8 @@ public class AtomicWorldData
{
if(!isSectionLoaded(s.getX(), s.getZ()))
{
Iris.warn("Cant save section " + s.getX() + " " + s.getZ() + " because section isnt loaded?");
return false;
}
@@ -160,9 +164,10 @@ public class AtomicWorldData
{
int x = i.getX();
int z = i.getZ();
AtomicRegionData dat = loadSection(x >> 5, z >> 5);
AtomicRegionData dat = loadSection(x >> 5, z >> 5, true);
dat.set(x & 31, z & 31, loadedChunks.get(i));
loadedChunks.remove(i);
lastChunk.remove(i);
}
public AtomicSliverMap loadChunk(int x, int z) throws IOException
@@ -186,10 +191,13 @@ public class AtomicWorldData
return loadSection(x >> 5, z >> 5).contains(x & 31, z & 31);
}
public AtomicRegionData loadSection(int x, int z) throws IOException
public AtomicRegionData loadSection(int x, int z, boolean anonymous) throws IOException
{
ChunkPosition pos = new ChunkPosition(x, z);
lastRegion.put(pos, M.ms());
if(!anonymous)
{
lastRegion.put(pos, M.ms());
}
if(isSectionLoaded(x, z))
{
@@ -213,6 +221,11 @@ public class AtomicWorldData
return data;
}
public AtomicRegionData loadSection(int x, int z) throws IOException
{
return loadSection(x, z, false);
}
public AtomicRegionData createSection(int x, int z)
{
if(isSectionLoaded(x, z))