mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 10:43:14 +00:00
ATOMIC MAYHEM
This commit is contained in:
parent
b6592582b3
commit
58a5aaed30
77
src/main/java/com/volmit/iris/gen/atomics/AtomicCache.java
Normal file
77
src/main/java/com/volmit/iris/gen/atomics/AtomicCache.java
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
package com.volmit.iris.gen.atomics;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
import com.volmit.iris.util.IrisLock;
|
||||||
|
import com.volmit.iris.util.M;
|
||||||
|
|
||||||
|
public class AtomicCache<T>
|
||||||
|
{
|
||||||
|
private transient volatile T t;
|
||||||
|
private transient volatile long a;
|
||||||
|
private transient volatile int validations;
|
||||||
|
private final IrisLock check;
|
||||||
|
private final IrisLock time;
|
||||||
|
private final IrisLock write;
|
||||||
|
|
||||||
|
public AtomicCache()
|
||||||
|
{
|
||||||
|
check = new IrisLock("Check");
|
||||||
|
write = new IrisLock("Write");
|
||||||
|
time = new IrisLock("Time");
|
||||||
|
validations = 0;
|
||||||
|
a = -1;
|
||||||
|
t = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reset()
|
||||||
|
{
|
||||||
|
check.lock();
|
||||||
|
write.lock();
|
||||||
|
time.lock();
|
||||||
|
a = -1;
|
||||||
|
t = null;
|
||||||
|
time.unlock();
|
||||||
|
write.unlock();
|
||||||
|
check.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public T aquire(Supplier<T> t)
|
||||||
|
{
|
||||||
|
if(this.t != null && validations > 1000)
|
||||||
|
{
|
||||||
|
return this.t;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(this.t != null && M.ms() - a > 1000)
|
||||||
|
{
|
||||||
|
if(this.t != null)
|
||||||
|
{
|
||||||
|
validations++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.t;
|
||||||
|
}
|
||||||
|
|
||||||
|
check.lock();
|
||||||
|
|
||||||
|
if(this.t == null)
|
||||||
|
{
|
||||||
|
write.lock();
|
||||||
|
this.t = t.get();
|
||||||
|
|
||||||
|
time.lock();
|
||||||
|
|
||||||
|
if(a == -1)
|
||||||
|
{
|
||||||
|
a = M.ms();
|
||||||
|
}
|
||||||
|
|
||||||
|
time.unlock();
|
||||||
|
write.unlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
check.unlock();
|
||||||
|
return this.t;
|
||||||
|
}
|
||||||
|
}
|
@ -3,7 +3,6 @@ package com.volmit.iris.gen.atomics;
|
|||||||
import java.io.DataInputStream;
|
import java.io.DataInputStream;
|
||||||
import java.io.DataOutputStream;
|
import java.io.DataOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
@ -14,6 +13,7 @@ import org.bukkit.generator.ChunkGenerator.ChunkData;
|
|||||||
import com.volmit.iris.object.IrisBiome;
|
import com.volmit.iris.object.IrisBiome;
|
||||||
import com.volmit.iris.util.BlockDataTools;
|
import com.volmit.iris.util.BlockDataTools;
|
||||||
import com.volmit.iris.util.HeightMap;
|
import com.volmit.iris.util.HeightMap;
|
||||||
|
import com.volmit.iris.util.IrisLock;
|
||||||
import com.volmit.iris.util.KList;
|
import com.volmit.iris.util.KList;
|
||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
import com.volmit.iris.util.M;
|
import com.volmit.iris.util.M;
|
||||||
@ -27,7 +27,7 @@ public class AtomicSliver
|
|||||||
private KMap<Integer, BlockData> block;
|
private KMap<Integer, BlockData> block;
|
||||||
private KMap<Integer, IrisBiome> truebiome;
|
private KMap<Integer, IrisBiome> truebiome;
|
||||||
private KMap<Integer, Biome> biome;
|
private KMap<Integer, Biome> biome;
|
||||||
private ReentrantLock lock = new ReentrantLock();
|
private IrisLock lock = new IrisLock("Sliver");
|
||||||
private int highestBlock = 0;
|
private int highestBlock = 0;
|
||||||
private int highestBiome = 0;
|
private int highestBiome = 0;
|
||||||
private long last = M.ms();
|
private long last = M.ms();
|
||||||
@ -37,6 +37,7 @@ public class AtomicSliver
|
|||||||
|
|
||||||
public AtomicSliver(int x, int z)
|
public AtomicSliver(int x, int z)
|
||||||
{
|
{
|
||||||
|
lock.setDisabled(true);
|
||||||
this.x = x;
|
this.x = x;
|
||||||
this.z = z;
|
this.z = z;
|
||||||
this.block = new KMap<>();
|
this.block = new KMap<>();
|
||||||
@ -71,14 +72,15 @@ public class AtomicSliver
|
|||||||
|
|
||||||
lock.lock();
|
lock.lock();
|
||||||
block.put(h, d);
|
block.put(h, d);
|
||||||
|
lock.unlock();
|
||||||
modified = true;
|
modified = true;
|
||||||
|
|
||||||
if(d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR))
|
if(d.getMaterial().equals(Material.AIR) || d.getMaterial().equals(Material.CAVE_AIR))
|
||||||
{
|
{
|
||||||
lock.unlock();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
lock.lock();
|
||||||
highestBlock = h > highestBlock ? h : highestBlock;
|
highestBlock = h > highestBlock ? h : highestBlock;
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public class AtomicWorldData
|
|||||||
|
|
||||||
private int getUnloadBatchSize()
|
private int getUnloadBatchSize()
|
||||||
{
|
{
|
||||||
return Math.max(3, getLoadedRegions().size() / 125);
|
return Math.max(3, getLoadedRegions().size() / 85);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getUnloadBatchSpeed()
|
private int getUnloadBatchSpeed()
|
||||||
|
@ -1,18 +1,17 @@
|
|||||||
package com.volmit.iris.gen.atomics;
|
package com.volmit.iris.gen.atomics;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import com.volmit.iris.util.IrisLock;
|
||||||
|
|
||||||
import com.volmit.iris.util.KMap;
|
import com.volmit.iris.util.KMap;
|
||||||
|
|
||||||
public class MasterLock
|
public class MasterLock
|
||||||
{
|
{
|
||||||
private KMap<String, ReentrantLock> locks;
|
private KMap<String, IrisLock> locks;
|
||||||
private ReentrantLock lock;
|
private IrisLock lock;
|
||||||
|
|
||||||
public MasterLock()
|
public MasterLock()
|
||||||
{
|
{
|
||||||
locks = new KMap<>();
|
locks = new KMap<>();
|
||||||
lock = new ReentrantLock();
|
lock = new IrisLock("MasterLock");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void clear()
|
public void clear()
|
||||||
@ -25,10 +24,10 @@ public class MasterLock
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
if(!locks.containsKey(key))
|
if(!locks.containsKey(key))
|
||||||
{
|
{
|
||||||
locks.put(key, new ReentrantLock());
|
locks.put(key, new IrisLock("Locker"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReentrantLock l = locks.get(key);
|
IrisLock l = locks.get(key);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
l.lock();
|
l.lock();
|
||||||
}
|
}
|
||||||
@ -38,10 +37,10 @@ public class MasterLock
|
|||||||
lock.lock();
|
lock.lock();
|
||||||
if(!locks.containsKey(key))
|
if(!locks.containsKey(key))
|
||||||
{
|
{
|
||||||
locks.put(key, new ReentrantLock());
|
locks.put(key, new IrisLock("Unlocker"));
|
||||||
}
|
}
|
||||||
|
|
||||||
ReentrantLock l = locks.get(key);
|
IrisLock l = locks.get(key);
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
l.unlock();
|
l.unlock();
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.BiomeRarityCellGenerator;
|
import com.volmit.iris.util.BiomeRarityCellGenerator;
|
||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
@ -95,17 +94,13 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
@Desc("Define biome deposit generators that add onto the existing regional and global deposit generators")
|
@Desc("Define biome deposit generators that add onto the existing regional and global deposit generators")
|
||||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||||
|
|
||||||
private transient ReentrantLock lock = new ReentrantLock();
|
|
||||||
private transient BiomeRarityCellGenerator childrenCell;
|
|
||||||
private transient InferredType inferredType;
|
private transient InferredType inferredType;
|
||||||
private transient CNG biomeGenerator;
|
private transient AtomicCache<BiomeRarityCellGenerator> childrenCell = new AtomicCache<>();
|
||||||
private transient int maxHeight = Integer.MIN_VALUE;
|
private transient AtomicCache<CNG> biomeGenerator = new AtomicCache<>();
|
||||||
private transient KList<BlockData> fullLayerSpec;
|
private transient AtomicCache<Integer> maxHeight = new AtomicCache<>();
|
||||||
private transient KList<CNG> layerHeightGenerators;
|
private transient AtomicCache<KList<IrisBiome>> realChildren = new AtomicCache<>();
|
||||||
private transient KList<CNG> layerSeaHeightGenerators;
|
private transient AtomicCache<KList<CNG>> layerHeightGenerators = new AtomicCache<>();
|
||||||
private transient KList<CNG> layerSurfaceGenerators;
|
private transient AtomicCache<KList<CNG>> layerSeaHeightGenerators = new AtomicCache<>();
|
||||||
private transient KList<CNG> layerSeaSurfaceGenerators;
|
|
||||||
private transient KList<IrisBiome> realChildren;
|
|
||||||
|
|
||||||
public IrisBiome()
|
public IrisBiome()
|
||||||
{
|
{
|
||||||
@ -126,23 +121,20 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
|
|
||||||
public CNG getBiomeGenerator(RNG random)
|
public CNG getBiomeGenerator(RNG random)
|
||||||
{
|
{
|
||||||
if(biomeGenerator == null)
|
return biomeGenerator.aquire(() ->
|
||||||
{
|
{
|
||||||
biomeGenerator = CNG.signature(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())).scale(biomeDispersion.equals(Dispersion.SCATTER) ? 1000D : 0.1D);
|
return CNG.signature(random.nextParallelRNG(213949 + 228888 + getRarity() + getName().length())).scale(biomeDispersion.equals(Dispersion.SCATTER) ? 1000D : 0.1D);
|
||||||
}
|
});
|
||||||
|
|
||||||
return biomeGenerator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BiomeRarityCellGenerator getChildrenGenerator(RNG random, int sig, double scale)
|
public BiomeRarityCellGenerator getChildrenGenerator(RNG random, int sig, double scale)
|
||||||
{
|
{
|
||||||
if(childrenCell == null)
|
return childrenCell.aquire(() ->
|
||||||
{
|
{
|
||||||
childrenCell = new BiomeRarityCellGenerator(random.nextParallelRNG(sig * 2137));
|
BiomeRarityCellGenerator childrenCell = new BiomeRarityCellGenerator(random.nextParallelRNG(sig * 2137));
|
||||||
childrenCell.setCellScale(scale);
|
childrenCell.setCellScale(scale);
|
||||||
}
|
|
||||||
|
|
||||||
return childrenCell;
|
return childrenCell;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
||||||
@ -247,21 +239,17 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
|
|
||||||
private int getMaxHeight()
|
private int getMaxHeight()
|
||||||
{
|
{
|
||||||
if(maxHeight == Integer.MIN_VALUE)
|
return maxHeight.aquire(() ->
|
||||||
{
|
{
|
||||||
lock.lock();
|
int maxHeight = 0;
|
||||||
|
|
||||||
maxHeight = 0;
|
|
||||||
|
|
||||||
for(IrisBiomeGeneratorLink i : getGenerators())
|
for(IrisBiomeGeneratorLink i : getGenerators())
|
||||||
{
|
{
|
||||||
maxHeight += i.getMax();
|
maxHeight += i.getMax();
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
return maxHeight;
|
return maxHeight;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisBiome infer(InferredType t, InferredType type)
|
public IrisBiome infer(InferredType t, InferredType type)
|
||||||
@ -313,10 +301,9 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
|
|
||||||
public KList<CNG> getLayerHeightGenerators(RNG rng)
|
public KList<CNG> getLayerHeightGenerators(RNG rng)
|
||||||
{
|
{
|
||||||
lock.lock();
|
return layerHeightGenerators.aquire(() ->
|
||||||
if(layerHeightGenerators == null)
|
|
||||||
{
|
{
|
||||||
layerHeightGenerators = new KList<>();
|
KList<CNG> layerHeightGenerators = new KList<>();
|
||||||
|
|
||||||
int m = 7235;
|
int m = 7235;
|
||||||
|
|
||||||
@ -324,18 +311,16 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
{
|
{
|
||||||
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
layerHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
return layerHeightGenerators;
|
return layerHeightGenerators;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<CNG> getLayerSeaHeightGenerators(RNG rng)
|
public KList<CNG> getLayerSeaHeightGenerators(RNG rng)
|
||||||
{
|
{
|
||||||
lock.lock();
|
return layerSeaHeightGenerators.aquire(() ->
|
||||||
if(layerSeaHeightGenerators == null)
|
|
||||||
{
|
{
|
||||||
layerSeaHeightGenerators = new KList<>();
|
KList<CNG> layerSeaHeightGenerators = new KList<>();
|
||||||
|
|
||||||
int m = 7735;
|
int m = 7735;
|
||||||
|
|
||||||
@ -343,10 +328,9 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
{
|
{
|
||||||
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
layerSeaHeightGenerators.add(i.getHeightGenerator(rng.nextParallelRNG((m++) * m * m * m)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
return layerSeaHeightGenerators;
|
return layerSeaHeightGenerators;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLand()
|
public boolean isLand()
|
||||||
@ -394,21 +378,17 @@ public class IrisBiome extends IrisRegistrant
|
|||||||
|
|
||||||
public KList<IrisBiome> getRealChildren()
|
public KList<IrisBiome> getRealChildren()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return realChildren.aquire(() ->
|
||||||
|
|
||||||
if(realChildren == null)
|
|
||||||
{
|
{
|
||||||
realChildren = new KList<>();
|
KList<IrisBiome> realChildren = new KList<>();
|
||||||
|
|
||||||
for(String i : getChildren())
|
for(String i : getChildren())
|
||||||
{
|
{
|
||||||
realChildren.add(Iris.data.getBiomeLoader().load(i));
|
realChildren.add(Iris.data.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
return realChildren;
|
return realChildren;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> getAllChildren(int limit)
|
public KList<String> getAllChildren(int limit)
|
||||||
|
@ -2,6 +2,7 @@ package com.volmit.iris.object;
|
|||||||
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.BlockDataTools;
|
import com.volmit.iris.util.BlockDataTools;
|
||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
@ -57,8 +58,8 @@ public class IrisBiomeDecorator
|
|||||||
private KList<String> palette = new KList<String>().qadd("GRASS");
|
private KList<String> palette = new KList<String>().qadd("GRASS");
|
||||||
|
|
||||||
private transient KMap<Long, CNG> layerGenerators;
|
private transient KMap<Long, CNG> layerGenerators;
|
||||||
private transient CNG heightGenerator;
|
private transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
|
||||||
private transient KList<BlockData> blockData;
|
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)
|
||||||
{
|
{
|
||||||
@ -72,12 +73,10 @@ public class IrisBiomeDecorator
|
|||||||
|
|
||||||
public CNG getHeightGenerator(RNG rng)
|
public CNG getHeightGenerator(RNG rng)
|
||||||
{
|
{
|
||||||
if(heightGenerator == null)
|
return heightGenerator.aquire(() ->
|
||||||
{
|
{
|
||||||
heightGenerator = CNG.signature(rng.nextParallelRNG(getBlockData().size() + stackMax + stackMin)).scale(1D / verticalZoom);
|
return CNG.signature(rng.nextParallelRNG(getBlockData().size() + stackMax + stackMin)).scale(1D / verticalZoom);
|
||||||
}
|
});
|
||||||
|
|
||||||
return heightGenerator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getGenerator(RNG rng)
|
public CNG getGenerator(RNG rng)
|
||||||
@ -141,9 +140,9 @@ public class IrisBiomeDecorator
|
|||||||
|
|
||||||
public KList<BlockData> getBlockData()
|
public KList<BlockData> getBlockData()
|
||||||
{
|
{
|
||||||
if(blockData == null)
|
return blockData.aquire(() ->
|
||||||
{
|
{
|
||||||
blockData = new KList<>();
|
KList<BlockData> blockData = new KList<>();
|
||||||
for(String i : palette)
|
for(String i : palette)
|
||||||
{
|
{
|
||||||
BlockData bx = BlockDataTools.getBlockData(i);
|
BlockData bx = BlockDataTools.getBlockData(i);
|
||||||
@ -152,8 +151,8 @@ public class IrisBiomeDecorator
|
|||||||
blockData.add(bx);
|
blockData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return blockData;
|
return blockData;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
import com.volmit.iris.util.IrisInterpolation;
|
import com.volmit.iris.util.IrisInterpolation;
|
||||||
@ -23,7 +24,7 @@ public class IrisBiomeGeneratorLink
|
|||||||
@Desc("The max block value (value + fluidHeight)")
|
@Desc("The max block value (value + fluidHeight)")
|
||||||
private int max = 0;
|
private int max = 0;
|
||||||
|
|
||||||
private transient IrisGenerator gen;
|
private transient AtomicCache<IrisGenerator> gen = new AtomicCache<>();
|
||||||
|
|
||||||
public IrisBiomeGeneratorLink()
|
public IrisBiomeGeneratorLink()
|
||||||
{
|
{
|
||||||
@ -32,17 +33,17 @@ public class IrisBiomeGeneratorLink
|
|||||||
|
|
||||||
public IrisGenerator getCachedGenerator()
|
public IrisGenerator getCachedGenerator()
|
||||||
{
|
{
|
||||||
if(gen == null)
|
return gen.aquire(() ->
|
||||||
{
|
{
|
||||||
gen = Iris.data.getGeneratorLoader().load(getGenerator());
|
IrisGenerator gen = Iris.data.getGeneratorLoader().load(getGenerator());
|
||||||
|
|
||||||
if(gen == null)
|
if(gen == null)
|
||||||
{
|
{
|
||||||
gen = new IrisGenerator();
|
gen = new IrisGenerator();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return gen;
|
return gen;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getHeight(double x, double z, long seed)
|
public double getHeight(double x, double z, long seed)
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
import com.volmit.iris.util.KList;
|
import com.volmit.iris.util.KList;
|
||||||
@ -32,27 +33,17 @@ public class IrisBiomeMutation
|
|||||||
@Desc("Objects define what schematics (iob files) iris will place in this biome mutation")
|
@Desc("Objects define what schematics (iob files) iris will place in this biome mutation")
|
||||||
private KList<IrisObjectPlacement> objects = new KList<IrisObjectPlacement>();
|
private KList<IrisObjectPlacement> objects = new KList<IrisObjectPlacement>();
|
||||||
|
|
||||||
private transient KList<String> sideACache;
|
private transient AtomicCache<KList<String>> sideACache = new AtomicCache<>();
|
||||||
private transient KList<String> sideBCache;
|
private transient AtomicCache<KList<String>> sideBCache = new AtomicCache<>();
|
||||||
|
|
||||||
public KList<String> getRealSideA()
|
public KList<String> getRealSideA()
|
||||||
{
|
{
|
||||||
if(sideACache == null)
|
return sideACache.aquire(() -> processList(getSideA()));
|
||||||
{
|
|
||||||
sideACache = processList(getSideA());
|
|
||||||
}
|
|
||||||
|
|
||||||
return sideACache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> getRealSideB()
|
public KList<String> getRealSideB()
|
||||||
{
|
{
|
||||||
if(sideBCache == null)
|
return sideBCache.aquire(() -> processList(getSideB()));
|
||||||
{
|
|
||||||
sideBCache = processList(getSideB());
|
|
||||||
}
|
|
||||||
|
|
||||||
return sideBCache;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> processList(KList<String> s)
|
public KList<String> processList(KList<String> s)
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.BlockDataTools;
|
import com.volmit.iris.util.BlockDataTools;
|
||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
@ -37,28 +36,17 @@ public class IrisBiomePaletteLayer
|
|||||||
@Desc("The palette of blocks to be used in this layer")
|
@Desc("The palette of blocks to be used in this layer")
|
||||||
private KList<String> palette = new KList<String>().qadd("GRASS_BLOCK");
|
private KList<String> palette = new KList<String>().qadd("GRASS_BLOCK");
|
||||||
|
|
||||||
private transient ReentrantLock lock = new ReentrantLock();
|
private transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
|
||||||
private transient KList<BlockData> blockData;
|
private transient AtomicCache<CNG> layerGenerator = new AtomicCache<>();
|
||||||
private transient CNG layerGenerator;
|
private transient AtomicCache<CNG> heightGenerator = new AtomicCache<>();
|
||||||
private transient CNG heightGenerator;
|
|
||||||
|
|
||||||
public CNG getHeightGenerator(RNG rng)
|
public CNG getHeightGenerator(RNG rng)
|
||||||
{
|
{
|
||||||
if(heightGenerator == null)
|
return heightGenerator.aquire(() -> CNG.signature(rng.nextParallelRNG(minHeight * maxHeight + getBlockData().size())));
|
||||||
{
|
|
||||||
heightGenerator = CNG.signature(rng.nextParallelRNG(minHeight * maxHeight + getBlockData().size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return heightGenerator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData get(RNG rng, double x, double y, double z)
|
public BlockData get(RNG rng, double x, double y, double z)
|
||||||
{
|
{
|
||||||
if(layerGenerator == null)
|
|
||||||
{
|
|
||||||
cacheGenerator(rng);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(getBlockData().isEmpty())
|
if(getBlockData().isEmpty())
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
@ -69,24 +57,22 @@ public class IrisBiomePaletteLayer
|
|||||||
return getBlockData().get(0);
|
return getBlockData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(layerGenerator != null)
|
|
||||||
{
|
|
||||||
if(dispersion.equals(Dispersion.SCATTER))
|
if(dispersion.equals(Dispersion.SCATTER))
|
||||||
{
|
{
|
||||||
return getBlockData().get(layerGenerator.fit(0, 30000000, x, y, z) % getBlockData().size());
|
return getBlockData().get(getLayerGenerator(rng).fit(0, 30000000, x, y, z) % getBlockData().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return getBlockData().get(layerGenerator.fit(0, getBlockData().size() - 1, x, y, z));
|
return getBlockData().get(getLayerGenerator(rng).fit(0, getBlockData().size() - 1, x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getBlockData().get(0);
|
public CNG getLayerGenerator(RNG rng)
|
||||||
}
|
|
||||||
|
|
||||||
public void cacheGenerator(RNG rng)
|
|
||||||
{
|
{
|
||||||
|
return layerGenerator.aquire(() ->
|
||||||
|
{
|
||||||
|
CNG layerGenerator = new CNG(rng);
|
||||||
RNG rngx = rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size());
|
RNG rngx = rng.nextParallelRNG(minHeight + maxHeight + getBlockData().size());
|
||||||
|
|
||||||
switch(dispersion)
|
switch(dispersion)
|
||||||
@ -98,6 +84,9 @@ public class IrisBiomePaletteLayer
|
|||||||
layerGenerator = CNG.signature(rngx);
|
layerGenerator = CNG.signature(rngx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return layerGenerator;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> add(String b)
|
public KList<String> add(String b)
|
||||||
@ -109,10 +98,9 @@ public class IrisBiomePaletteLayer
|
|||||||
|
|
||||||
public KList<BlockData> getBlockData()
|
public KList<BlockData> getBlockData()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return blockData.aquire(() ->
|
||||||
if(blockData == null)
|
|
||||||
{
|
{
|
||||||
blockData = new KList<>();
|
KList<BlockData> blockData = new KList<>();
|
||||||
for(String ix : palette)
|
for(String ix : palette)
|
||||||
{
|
{
|
||||||
BlockData bx = BlockDataTools.getBlockData(ix);
|
BlockData bx = BlockDataTools.getBlockData(ix);
|
||||||
@ -121,10 +109,9 @@ public class IrisBiomePaletteLayer
|
|||||||
blockData.add(bx);
|
blockData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
return blockData;
|
return blockData;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisBiomePaletteLayer zero()
|
public IrisBiomePaletteLayer zero()
|
||||||
|
@ -1,13 +1,12 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
import org.bukkit.generator.ChunkGenerator.ChunkData;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
import com.volmit.iris.gen.TerrainChunkGenerator;
|
import com.volmit.iris.gen.TerrainChunkGenerator;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.BlockDataTools;
|
import com.volmit.iris.util.BlockDataTools;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
@ -51,54 +50,26 @@ public class IrisDepositGenerator
|
|||||||
@Desc("Ore varience is how many different objects clumps iris will create")
|
@Desc("Ore varience is how many different objects clumps iris will create")
|
||||||
private int varience = 8;
|
private int varience = 8;
|
||||||
|
|
||||||
private transient IrisObjectPlacement config = createDepositConfig();
|
private transient AtomicCache<KList<IrisObject>> objects = new AtomicCache<>();
|
||||||
private transient ReentrantLock lock = new ReentrantLock();
|
private transient AtomicCache<KList<BlockData>> blockData = new AtomicCache<>();
|
||||||
private transient KList<IrisObject> objects;
|
|
||||||
private transient KList<BlockData> blockData;
|
|
||||||
|
|
||||||
public IrisObject getClump(RNG rng)
|
public IrisObject getClump(RNG rng)
|
||||||
{
|
{
|
||||||
lock.lock();
|
KList<IrisObject> objects = this.objects.aquire(() ->
|
||||||
|
|
||||||
if(objects == null)
|
|
||||||
{
|
{
|
||||||
RNG rngv = rng.nextParallelRNG(3957778);
|
RNG rngv = rng.nextParallelRNG(3957778);
|
||||||
objects = new KList<>();
|
KList<IrisObject> objectsf = new KList<>();
|
||||||
|
|
||||||
for(int i = 0; i < varience; i++)
|
for(int i = 0; i < varience; i++)
|
||||||
{
|
{
|
||||||
objects.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598)));
|
objectsf.add(generateClumpObject(rngv.nextParallelRNG(2349 * i + 3598)));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.unlock();
|
return objectsf;
|
||||||
|
});
|
||||||
return objects.get(rng.i(0, objects.size() - 1));
|
return objects.get(rng.i(0, objects.size() - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisObjectPlacement createDepositConfig()
|
|
||||||
{
|
|
||||||
IrisObjectPlacement p = new IrisObjectPlacement();
|
|
||||||
IrisObjectRotation rot = new IrisObjectRotation();
|
|
||||||
rot.setEnabled(true);
|
|
||||||
IrisAxisRotationClamp xc = new IrisAxisRotationClamp();
|
|
||||||
IrisAxisRotationClamp yc = new IrisAxisRotationClamp();
|
|
||||||
IrisAxisRotationClamp zc = new IrisAxisRotationClamp();
|
|
||||||
xc.setEnabled(true);
|
|
||||||
xc.setInterval(45);
|
|
||||||
yc.setEnabled(true);
|
|
||||||
yc.setInterval(45);
|
|
||||||
zc.setEnabled(true);
|
|
||||||
zc.setInterval(45);
|
|
||||||
rot.setXAxis(xc);
|
|
||||||
rot.setYAxis(yc);
|
|
||||||
rot.setZAxis(zc);
|
|
||||||
p.setRotation(rot);
|
|
||||||
p.setUnderwater(true);
|
|
||||||
p.setMeld(true);
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxDimension()
|
public int getMaxDimension()
|
||||||
{
|
{
|
||||||
return Math.min(11, (int) Math.round(Math.pow(maxSize, 1D / 3D)));
|
return Math.min(11, (int) Math.round(Math.pow(maxSize, 1D / 3D)));
|
||||||
@ -137,11 +108,9 @@ public class IrisDepositGenerator
|
|||||||
|
|
||||||
public KList<BlockData> getBlockData()
|
public KList<BlockData> getBlockData()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return blockData.aquire(() ->
|
||||||
|
|
||||||
if(blockData == null)
|
|
||||||
{
|
{
|
||||||
blockData = new KList<>();
|
KList<BlockData> blockData = new KList<>();
|
||||||
|
|
||||||
for(String ix : palette)
|
for(String ix : palette)
|
||||||
{
|
{
|
||||||
@ -152,11 +121,9 @@ public class IrisDepositGenerator
|
|||||||
blockData.add(bx);
|
blockData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
return blockData;
|
return blockData;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate(ChunkData data, RNG rng, TerrainChunkGenerator g)
|
public void generate(ChunkData data, RNG rng, TerrainChunkGenerator g)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import org.bukkit.Material;
|
||||||
|
|
||||||
import org.bukkit.World.Environment;
|
import org.bukkit.World.Environment;
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
import org.bukkit.util.BlockVector;
|
import org.bukkit.util.BlockVector;
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
import com.volmit.iris.gen.PostBlockChunkGenerator;
|
import com.volmit.iris.gen.PostBlockChunkGenerator;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.BlockDataTools;
|
import com.volmit.iris.util.BlockDataTools;
|
||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.ChunkPosition;
|
import com.volmit.iris.util.ChunkPosition;
|
||||||
@ -26,6 +26,9 @@ import lombok.EqualsAndHashCode;
|
|||||||
@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 WATER = Material.WATER.createBlockData();
|
||||||
|
|
||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
@Desc("The human readable name of this dimension")
|
@Desc("The human readable name of this dimension")
|
||||||
private String name = "A Dimension";
|
private String name = "A Dimension";
|
||||||
@ -206,26 +209,23 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
@Desc("Define biome mutations for this dimension")
|
@Desc("Define biome mutations for this dimension")
|
||||||
private KList<IrisBiomeMutation> mutations = new KList<>();
|
private KList<IrisBiomeMutation> mutations = new KList<>();
|
||||||
|
|
||||||
private transient ChunkPosition parallaxSize;
|
private transient AtomicCache<ChunkPosition> parallaxSize = new AtomicCache<>();
|
||||||
private transient ReentrantLock rockLock = new ReentrantLock();
|
private transient AtomicCache<KList<BlockData>> rockData = new AtomicCache<>();
|
||||||
private transient ReentrantLock parLock = new ReentrantLock();
|
private transient AtomicCache<KList<BlockData>> fluidData = new AtomicCache<>();
|
||||||
private transient ReentrantLock fluidLock = new ReentrantLock();
|
private transient AtomicCache<KList<IrisPostBlockFilter>> cacheFilters = new AtomicCache<>();
|
||||||
private transient KList<BlockData> rockData;
|
private transient AtomicCache<CNG> rockLayerGenerator = new AtomicCache<>();
|
||||||
private transient KList<BlockData> fluidData;
|
private transient AtomicCache<CNG> fluidLayerGenerator = new AtomicCache<>();
|
||||||
private transient KList<IrisPostBlockFilter> cacheFilters;
|
private transient AtomicCache<CNG> coordFracture = new AtomicCache<>();
|
||||||
private transient CNG rockLayerGenerator;
|
private transient AtomicCache<Double> sinr = new AtomicCache<>();
|
||||||
private transient CNG fluidLayerGenerator;
|
private transient AtomicCache<Double> cosr = new AtomicCache<>();
|
||||||
private transient CNG coordFracture;
|
private transient AtomicCache<Double> rad = new AtomicCache<>();
|
||||||
private transient Double sinr;
|
private transient boolean inverted = false;
|
||||||
private transient Double cosr;
|
|
||||||
private transient Double rad;
|
|
||||||
private transient boolean inverted;
|
|
||||||
|
|
||||||
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g)
|
public KList<IrisPostBlockFilter> getPostBlockProcessors(PostBlockChunkGenerator g)
|
||||||
{
|
{
|
||||||
if(cacheFilters == null)
|
return cacheFilters.aquire(() ->
|
||||||
{
|
{
|
||||||
cacheFilters = new KList<>();
|
KList<IrisPostBlockFilter> cacheFilters = new KList<>();
|
||||||
|
|
||||||
for(IrisPostProcessor i : getPostProcessors())
|
for(IrisPostProcessor i : getPostProcessors())
|
||||||
{
|
{
|
||||||
@ -242,20 +242,18 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
}
|
}
|
||||||
|
|
||||||
Iris.info("Post Processing: " + cacheFilters.size() + " filters. Phases: " + g.getMinPhase() + " - " + g.getMaxPhase());
|
Iris.info("Post Processing: " + cacheFilters.size() + " filters. Phases: " + g.getMinPhase() + " - " + g.getMaxPhase());
|
||||||
}
|
|
||||||
|
|
||||||
return cacheFilters;
|
return cacheFilters;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public CNG getCoordFracture(RNG rng, int signature)
|
public CNG getCoordFracture(RNG rng, int signature)
|
||||||
{
|
{
|
||||||
if(coordFracture == null)
|
return coordFracture.aquire(() ->
|
||||||
{
|
{
|
||||||
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()
|
||||||
@ -274,36 +272,33 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
|
|
||||||
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())
|
||||||
|
{
|
||||||
|
return STONE;
|
||||||
|
}
|
||||||
|
|
||||||
if(getRockData().size() == 1)
|
if(getRockData().size() == 1)
|
||||||
{
|
{
|
||||||
return getRockData().get(0);
|
return getRockData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(rockLayerGenerator == null)
|
|
||||||
{
|
|
||||||
cacheRockGenerator(rng);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(rockLayerGenerator != null)
|
|
||||||
{
|
|
||||||
if(dispersion.equals(Dispersion.SCATTER))
|
if(dispersion.equals(Dispersion.SCATTER))
|
||||||
{
|
{
|
||||||
return getRockData().get(rockLayerGenerator.fit(0, 30000000, x, y, z) % getRockData().size());
|
return getRockData().get(getRockGenerator(rng).fit(0, 30000000, x, y, z) % getRockData().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return getRockData().get(rockLayerGenerator.fit(0, getRockData().size() - 1, x, y, z));
|
return getRockData().get(getRockGenerator(rng).fit(0, getRockData().size() - 1, x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getRockData().get(0);
|
public CNG getRockGenerator(RNG rng)
|
||||||
}
|
{
|
||||||
|
return rockLayerGenerator.aquire(() ->
|
||||||
public void cacheRockGenerator(RNG rng)
|
|
||||||
{
|
{
|
||||||
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
RNG rngx = rng.nextParallelRNG((int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||||
|
CNG rockLayerGenerator = new CNG(rng);
|
||||||
switch(dispersion)
|
switch(dispersion)
|
||||||
{
|
{
|
||||||
case SCATTER:
|
case SCATTER:
|
||||||
@ -313,15 +308,16 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
rockLayerGenerator = CNG.signature(rngx);
|
rockLayerGenerator = CNG.signature(rngx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return rockLayerGenerator;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> getRockData()
|
public KList<BlockData> getRockData()
|
||||||
{
|
{
|
||||||
rockLock.lock();
|
return rockData.aquire(() ->
|
||||||
|
|
||||||
if(rockData == null)
|
|
||||||
{
|
{
|
||||||
rockData = new KList<>();
|
KList<BlockData> rockData = new KList<>();
|
||||||
for(String ix : rockPalette)
|
for(String ix : rockPalette)
|
||||||
{
|
{
|
||||||
BlockData bx = BlockDataTools.getBlockData(ix);
|
BlockData bx = BlockDataTools.getBlockData(ix);
|
||||||
@ -330,45 +326,40 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
rockData.add(bx);
|
rockData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
rockLock.unlock();
|
|
||||||
|
|
||||||
return rockData;
|
return rockData;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
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())
|
||||||
|
{
|
||||||
|
return WATER;
|
||||||
|
}
|
||||||
|
|
||||||
if(getFluidData().size() == 1)
|
if(getFluidData().size() == 1)
|
||||||
{
|
{
|
||||||
return getFluidData().get(0);
|
return getFluidData().get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(fluidLayerGenerator == null)
|
|
||||||
{
|
|
||||||
cacheFluidGenerator(rng);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(fluidLayerGenerator != null)
|
|
||||||
{
|
|
||||||
if(dispersion.equals(Dispersion.SCATTER))
|
if(dispersion.equals(Dispersion.SCATTER))
|
||||||
{
|
{
|
||||||
return getFluidData().get(fluidLayerGenerator.fit(0, 30000000, x, y, z) % getFluidData().size());
|
return getFluidData().get(getFluidGenerator(rng).fit(0, 30000000, x, y, z) % getFluidData().size());
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return getFluidData().get(fluidLayerGenerator.fit(0, getFluidData().size() - 1, x, y, z));
|
return getFluidData().get(getFluidGenerator(rng).fit(0, getFluidData().size() - 1, x, y, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return getFluidData().get(0);
|
public CNG getFluidGenerator(RNG rng)
|
||||||
}
|
{
|
||||||
|
return fluidLayerGenerator.aquire(() ->
|
||||||
public void cacheFluidGenerator(RNG rng)
|
|
||||||
{
|
{
|
||||||
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
RNG rngx = rng.nextParallelRNG(getFluidData().size() * (int) (getRockData().size() * getRegions().size() * getCaveScale() * getLandZoom() * 10357));
|
||||||
|
CNG fluidLayerGenerator = new CNG(rng);
|
||||||
switch(dispersion)
|
switch(dispersion)
|
||||||
{
|
{
|
||||||
case SCATTER:
|
case SCATTER:
|
||||||
@ -378,15 +369,16 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
fluidLayerGenerator = CNG.signature(rngx);
|
fluidLayerGenerator = CNG.signature(rngx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return fluidLayerGenerator;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<BlockData> getFluidData()
|
public KList<BlockData> getFluidData()
|
||||||
{
|
{
|
||||||
fluidLock.lock();
|
return fluidData.aquire(() ->
|
||||||
|
|
||||||
if(fluidData == null)
|
|
||||||
{
|
{
|
||||||
fluidData = new KList<>();
|
KList<BlockData> fluidData = new KList<>();
|
||||||
for(String ix : fluidPalette)
|
for(String ix : fluidPalette)
|
||||||
{
|
{
|
||||||
BlockData bx = BlockDataTools.getBlockData(ix);
|
BlockData bx = BlockDataTools.getBlockData(ix);
|
||||||
@ -395,41 +387,24 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
fluidData.add(bx);
|
fluidData.add(bx);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fluidLock.unlock();
|
|
||||||
|
|
||||||
return fluidData;
|
return fluidData;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getDimensionAngle()
|
public double getDimensionAngle()
|
||||||
{
|
{
|
||||||
if(rad == null)
|
return rad.aquire(() -> Math.toRadians(dimensionAngleDeg));
|
||||||
{
|
|
||||||
rad = Math.toRadians(dimensionAngleDeg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return rad;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double sinRotate()
|
public double sinRotate()
|
||||||
{
|
{
|
||||||
if(sinr == null)
|
return sinr.aquire(() -> Math.sin(getDimensionAngle()));
|
||||||
{
|
|
||||||
sinr = Math.sin(getDimensionAngle());
|
|
||||||
}
|
|
||||||
|
|
||||||
return sinr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double cosRotate()
|
public double cosRotate()
|
||||||
{
|
{
|
||||||
if(cosr == null)
|
return cosr.aquire(() -> Math.cos(getDimensionAngle()));
|
||||||
{
|
|
||||||
cosr = Math.cos(getDimensionAngle());
|
|
||||||
}
|
|
||||||
|
|
||||||
return cosr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisRegion> getAllRegions()
|
public KList<IrisRegion> getAllRegions()
|
||||||
@ -458,9 +433,7 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
|
|
||||||
public ChunkPosition getParallaxSize()
|
public ChunkPosition getParallaxSize()
|
||||||
{
|
{
|
||||||
parLock.lock();
|
return parallaxSize.aquire(() ->
|
||||||
|
|
||||||
if(parallaxSize == null)
|
|
||||||
{
|
{
|
||||||
int x = 0;
|
int x = 0;
|
||||||
int z = 0;
|
int z = 0;
|
||||||
@ -523,11 +496,8 @@ public class IrisDimension extends IrisRegistrant
|
|||||||
z = (Math.max(z, 16) + 16) >> 4;
|
z = (Math.max(z, 16) + 16) >> 4;
|
||||||
x = x % 2 == 0 ? x + 1 : x;
|
x = x % 2 == 0 ? x + 1 : x;
|
||||||
z = z % 2 == 0 ? z + 1 : z;
|
z = z % 2 == 0 ? z + 1 : z;
|
||||||
parallaxSize = new ChunkPosition(x, z);
|
|
||||||
Iris.info("Parallax Size: " + x + ", " + z);
|
Iris.info("Parallax Size: " + x + ", " + z);
|
||||||
}
|
return new ChunkPosition(x, z);
|
||||||
|
});
|
||||||
parLock.unlock();
|
|
||||||
return parallaxSize;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
|
|
||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
@ -71,12 +70,11 @@ public class IrisNoiseGenerator
|
|||||||
@Desc("Apply a child noise generator to fracture the input coordinates of this generator")
|
@Desc("Apply a child noise generator to fracture the input coordinates of this generator")
|
||||||
private KList<IrisNoiseGenerator> fracture = new KList<>();
|
private KList<IrisNoiseGenerator> fracture = new KList<>();
|
||||||
|
|
||||||
private transient ReentrantLock lock;
|
private transient AtomicCache<CNG> generator = new AtomicCache<>();
|
||||||
private transient CNG generator;
|
|
||||||
|
|
||||||
public IrisNoiseGenerator()
|
public IrisNoiseGenerator()
|
||||||
{
|
{
|
||||||
lock = new ReentrantLock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public IrisNoiseGenerator(boolean enabled)
|
public IrisNoiseGenerator(boolean enabled)
|
||||||
@ -87,14 +85,7 @@ public class IrisNoiseGenerator
|
|||||||
|
|
||||||
protected CNG getGenerator(long superSeed)
|
protected CNG getGenerator(long superSeed)
|
||||||
{
|
{
|
||||||
if(generator == null)
|
return generator.aquire(() -> irisBased ? CNG.signature(new RNG(superSeed + 33955677 - seed)) : new CNG(new RNG(superSeed + 33955677 - seed), 1D, octaves));
|
||||||
{
|
|
||||||
lock.lock();
|
|
||||||
generator = irisBased ? CNG.signature(new RNG(superSeed + 33955677 - seed)) : new CNG(new RNG(superSeed + 33955677 - seed), 1D, octaves);
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
return generator;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMax()
|
public double getMax()
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import org.bukkit.block.data.BlockData;
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.BlockDataTools;
|
import com.volmit.iris.util.BlockDataTools;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
@ -23,9 +22,8 @@ public class IrisObjectReplace
|
|||||||
@DontObfuscate
|
@DontObfuscate
|
||||||
private boolean exact = false;
|
private boolean exact = false;
|
||||||
|
|
||||||
private transient ReentrantLock lock = new ReentrantLock();
|
private transient AtomicCache<BlockData> findData = new AtomicCache<>();
|
||||||
private transient BlockData findData;
|
private transient AtomicCache<BlockData> replaceData = new AtomicCache<>();
|
||||||
private transient BlockData replaceData;
|
|
||||||
|
|
||||||
public IrisObjectReplace()
|
public IrisObjectReplace()
|
||||||
{
|
{
|
||||||
@ -34,21 +32,11 @@ public class IrisObjectReplace
|
|||||||
|
|
||||||
public BlockData getFind()
|
public BlockData getFind()
|
||||||
{
|
{
|
||||||
if(findData == null)
|
return findData.aquire(() -> BlockDataTools.getBlockData(find));
|
||||||
{
|
|
||||||
findData = BlockDataTools.getBlockData(find);
|
|
||||||
}
|
|
||||||
|
|
||||||
return findData;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockData getReplace()
|
public BlockData getReplace()
|
||||||
{
|
{
|
||||||
if(replaceData == null)
|
return replaceData.aquire(() -> BlockDataTools.getBlockData(replace));
|
||||||
{
|
|
||||||
replaceData = BlockDataTools.getBlockData(replace);
|
|
||||||
}
|
|
||||||
|
|
||||||
return replaceData;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
|
|
||||||
import com.volmit.iris.Iris;
|
import com.volmit.iris.Iris;
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.CNG;
|
import com.volmit.iris.util.CNG;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
@ -102,17 +101,15 @@ public class IrisRegion extends IrisRegistrant
|
|||||||
@Desc("Define regional deposit generators that add onto the global deposit generators")
|
@Desc("Define regional deposit generators that add onto the global deposit generators")
|
||||||
private KList<IrisDepositGenerator> deposits = new KList<>();
|
private KList<IrisDepositGenerator> deposits = new KList<>();
|
||||||
|
|
||||||
private transient KList<String> cacheRidge;
|
private transient AtomicCache<KList<String>> cacheRidge = new AtomicCache<>();
|
||||||
private transient KList<String> cacheSpot;
|
private transient AtomicCache<KList<String>> cacheSpot = new AtomicCache<>();
|
||||||
private transient CNG shoreHeightGenerator;
|
private transient AtomicCache<CNG> shoreHeightGenerator = new AtomicCache<>();
|
||||||
private transient ReentrantLock lock = new ReentrantLock();
|
private transient AtomicCache<KList<IrisBiome>> realLandBiomes = new AtomicCache<>();
|
||||||
|
private transient AtomicCache<KList<IrisBiome>> realSeaBiomes = new AtomicCache<>();
|
||||||
private transient KList<IrisBiome> realLandBiomes;
|
private transient AtomicCache<KList<IrisBiome>> realShoreBiomes = new AtomicCache<>();
|
||||||
private transient KList<IrisBiome> realSeaBiomes;
|
private transient AtomicCache<KList<IrisBiome>> realIslandBiomes = new AtomicCache<>();
|
||||||
private transient KList<IrisBiome> realShoreBiomes;
|
private transient AtomicCache<KList<IrisBiome>> realSkylandBiomes = new AtomicCache<>();
|
||||||
private transient KList<IrisBiome> realIslandBiomes;
|
private transient AtomicCache<KList<IrisBiome>> realCaveBiomes = new AtomicCache<>();
|
||||||
private transient KList<IrisBiome> realSkylandBiomes;
|
|
||||||
private transient KList<IrisBiome> realCaveBiomes;
|
|
||||||
|
|
||||||
public double getBiomeZoom(InferredType t)
|
public double getBiomeZoom(InferredType t)
|
||||||
{
|
{
|
||||||
@ -139,44 +136,36 @@ public class IrisRegion extends IrisRegistrant
|
|||||||
|
|
||||||
public KList<String> getRidgeBiomeKeys()
|
public KList<String> getRidgeBiomeKeys()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return cacheRidge.aquire(() ->
|
||||||
|
|
||||||
if(cacheRidge == null)
|
|
||||||
{
|
{
|
||||||
cacheRidge = new KList<String>();
|
KList<String> cacheRidge = new KList<String>();
|
||||||
ridgeBiomes.forEach((i) -> cacheRidge.add(i.getBiome()));
|
ridgeBiomes.forEach((i) -> cacheRidge.add(i.getBiome()));
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
|
|
||||||
return cacheRidge;
|
return cacheRidge;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<String> getSpotBiomeKeys()
|
public KList<String> getSpotBiomeKeys()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return cacheSpot.aquire(() ->
|
||||||
|
|
||||||
if(cacheSpot == null)
|
|
||||||
{
|
{
|
||||||
cacheSpot = new KList<String>();
|
KList<String> cacheSpot = new KList<String>();
|
||||||
spotBiomes.forEach((i) -> cacheSpot.add(i.getBiome()));
|
spotBiomes.forEach((i) -> cacheSpot.add(i.getBiome()));
|
||||||
|
return cacheSpot;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
lock.unlock();
|
public CNG getShoreHeightGenerator()
|
||||||
|
{
|
||||||
return cacheSpot;
|
return shoreHeightGenerator.aquire(() ->
|
||||||
|
{
|
||||||
|
return CNG.signature(new RNG((long) (getName().length() + getIslandBiomes().size() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getShoreHeight(double x, double z)
|
public double getShoreHeight(double x, double z)
|
||||||
{
|
{
|
||||||
if(shoreHeightGenerator == null)
|
return getShoreHeightGenerator().fitDoubleD(shoreHeightMin, shoreHeightMax, x / shoreHeightZoom, z / shoreHeightZoom);
|
||||||
{
|
|
||||||
lock.lock();
|
|
||||||
shoreHeightGenerator = CNG.signature(new RNG((long) (getName().length() + getIslandBiomes().size() + getLandBiomeZoom() + getLandBiomes().size() + 3458612)));
|
|
||||||
lock.unlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
return shoreHeightGenerator.fitDoubleD(shoreHeightMin, shoreHeightMax, x / shoreHeightZoom, z / shoreHeightZoom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getAllBiomes()
|
public KList<IrisBiome> getAllBiomes()
|
||||||
@ -246,115 +235,91 @@ public class IrisRegion extends IrisRegistrant
|
|||||||
|
|
||||||
public KList<IrisBiome> getRealCaveBiomes()
|
public KList<IrisBiome> getRealCaveBiomes()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return realCaveBiomes.aquire(() ->
|
||||||
|
|
||||||
if(realCaveBiomes == null)
|
|
||||||
{
|
{
|
||||||
realCaveBiomes = new KList<>();
|
KList<IrisBiome> realCaveBiomes = new KList<>();
|
||||||
|
|
||||||
for(String i : getCaveBiomes())
|
for(String i : getCaveBiomes())
|
||||||
{
|
{
|
||||||
realCaveBiomes.add(Iris.data.getBiomeLoader().load(i));
|
realCaveBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
return realCaveBiomes;
|
return realCaveBiomes;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getRealSkylandBiomes()
|
public KList<IrisBiome> getRealSkylandBiomes()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return realSkylandBiomes.aquire(() ->
|
||||||
|
|
||||||
if(realSkylandBiomes == null)
|
|
||||||
{
|
{
|
||||||
realSkylandBiomes = new KList<>();
|
KList<IrisBiome> realSkylandBiomes = new KList<>();
|
||||||
|
|
||||||
for(String i : getSkylandBiomes())
|
for(String i : getSkylandBiomes())
|
||||||
{
|
{
|
||||||
realSkylandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
realSkylandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
return realSkylandBiomes;
|
return realSkylandBiomes;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getRealIslandBiomes()
|
public KList<IrisBiome> getRealIslandBiomes()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return realIslandBiomes.aquire(() ->
|
||||||
|
|
||||||
if(realIslandBiomes == null)
|
|
||||||
{
|
{
|
||||||
realIslandBiomes = new KList<>();
|
KList<IrisBiome> realIslandBiomes = new KList<>();
|
||||||
|
|
||||||
for(String i : getIslandBiomes())
|
for(String i : getIslandBiomes())
|
||||||
{
|
{
|
||||||
realIslandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
realIslandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
return realIslandBiomes;
|
return realIslandBiomes;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getRealShoreBiomes()
|
public KList<IrisBiome> getRealShoreBiomes()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return realShoreBiomes.aquire(() ->
|
||||||
|
|
||||||
if(realShoreBiomes == null)
|
|
||||||
{
|
{
|
||||||
realShoreBiomes = new KList<>();
|
KList<IrisBiome> realShoreBiomes = new KList<>();
|
||||||
|
|
||||||
for(String i : getShoreBiomes())
|
for(String i : getShoreBiomes())
|
||||||
{
|
{
|
||||||
realShoreBiomes.add(Iris.data.getBiomeLoader().load(i));
|
realShoreBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
return realShoreBiomes;
|
return realShoreBiomes;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getRealSeaBiomes()
|
public KList<IrisBiome> getRealSeaBiomes()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return realSeaBiomes.aquire(() ->
|
||||||
|
|
||||||
if(realSeaBiomes == null)
|
|
||||||
{
|
{
|
||||||
realSeaBiomes = new KList<>();
|
KList<IrisBiome> realSeaBiomes = new KList<>();
|
||||||
|
|
||||||
for(String i : getSeaBiomes())
|
for(String i : getSeaBiomes())
|
||||||
{
|
{
|
||||||
realSeaBiomes.add(Iris.data.getBiomeLoader().load(i));
|
realSeaBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
return realSeaBiomes;
|
return realSeaBiomes;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public KList<IrisBiome> getRealLandBiomes()
|
public KList<IrisBiome> getRealLandBiomes()
|
||||||
{
|
{
|
||||||
lock.lock();
|
return realLandBiomes.aquire(() ->
|
||||||
|
|
||||||
if(realLandBiomes == null)
|
|
||||||
{
|
{
|
||||||
realLandBiomes = new KList<>();
|
KList<IrisBiome> realLandBiomes = new KList<>();
|
||||||
|
|
||||||
for(String i : getLandBiomes())
|
for(String i : getLandBiomes())
|
||||||
{
|
{
|
||||||
realLandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
realLandBiomes.add(Iris.data.getBiomeLoader().load(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
|
||||||
return realLandBiomes;
|
return realLandBiomes;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.CellGenerator;
|
import com.volmit.iris.util.CellGenerator;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
@ -55,14 +56,36 @@ public class IrisRegionRidge
|
|||||||
@Desc("If the noise multiplier is below zero, what should the air be filled with?")
|
@Desc("If the noise multiplier is below zero, what should the air be filled with?")
|
||||||
private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero();
|
private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero();
|
||||||
|
|
||||||
private transient CellGenerator spot;
|
private transient AtomicCache<CellGenerator> spot = new AtomicCache<>();
|
||||||
private transient CellGenerator ridge;
|
private transient AtomicCache<CellGenerator> ridge = new AtomicCache<>();
|
||||||
|
|
||||||
public IrisRegionRidge()
|
public IrisRegionRidge()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CellGenerator getSpotGenerator(RNG rng)
|
||||||
|
{
|
||||||
|
return spot.aquire(() ->
|
||||||
|
{
|
||||||
|
CellGenerator spot = new CellGenerator(rng.nextParallelRNG((int) (198523 * getChance())));
|
||||||
|
spot.setCellScale(chanceScale);
|
||||||
|
spot.setShuffle(shuffle);
|
||||||
|
return spot;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public CellGenerator getRidgeGenerator(RNG rng)
|
||||||
|
{
|
||||||
|
return spot.aquire(() ->
|
||||||
|
{
|
||||||
|
CellGenerator ridge = new CellGenerator(rng.nextParallelRNG((int) (465583 * getChance())));
|
||||||
|
ridge.setCellScale(scale);
|
||||||
|
ridge.setShuffle(shuffle);
|
||||||
|
return ridge;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public double getRidgeHeight(RNG rng, double x, double z)
|
public double getRidgeHeight(RNG rng, double x, double z)
|
||||||
{
|
{
|
||||||
if(getNoiseMultiplier() == 0)
|
if(getNoiseMultiplier() == 0)
|
||||||
@ -70,48 +93,20 @@ public class IrisRegionRidge
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ridge == null)
|
return getSpotGenerator(rng).getDistance(x, z) * getRidgeGenerator(rng).getDistance(x, z) * getNoiseMultiplier();
|
||||||
{
|
|
||||||
ridge = new CellGenerator(rng.nextParallelRNG((int) (465583 * getChance())));
|
|
||||||
ridge.setCellScale(scale);
|
|
||||||
ridge.setShuffle(shuffle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(spot == null)
|
|
||||||
{
|
|
||||||
spot = new CellGenerator(rng.nextParallelRNG((int) (198523 * getChance())));
|
|
||||||
spot.setCellScale(chanceScale);
|
|
||||||
spot.setShuffle(shuffle);
|
|
||||||
}
|
|
||||||
|
|
||||||
return spot.getDistance(x, z) * ridge.getDistance(x, z) * getNoiseMultiplier();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRidge(RNG rng, double x, double z)
|
public boolean isRidge(RNG rng, double x, double z)
|
||||||
{
|
{
|
||||||
if(ridge == null)
|
|
||||||
{
|
|
||||||
ridge = new CellGenerator(rng.nextParallelRNG((int) (465583 * getChance())));
|
|
||||||
ridge.setCellScale(scale);
|
|
||||||
ridge.setShuffle(shuffle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(spot == null)
|
|
||||||
{
|
|
||||||
spot = new CellGenerator(rng.nextParallelRNG((int) (198523 * getChance())));
|
|
||||||
spot.setCellScale(chanceScale);
|
|
||||||
spot.setShuffle(shuffle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(chance < 1)
|
if(chance < 1)
|
||||||
{
|
{
|
||||||
if(spot.getIndex(x, z, 1000) > chance * 1000)
|
if(getSpotGenerator(rng).getIndex(x, z, 1000) > chance * 1000)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ridge.getDistance(x, z) <= thickness)
|
if(getRidgeGenerator(rng).getDistance(x, z) <= thickness)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.volmit.iris.object;
|
package com.volmit.iris.object;
|
||||||
|
|
||||||
|
import com.volmit.iris.gen.atomics.AtomicCache;
|
||||||
import com.volmit.iris.util.CellGenerator;
|
import com.volmit.iris.util.CellGenerator;
|
||||||
import com.volmit.iris.util.Desc;
|
import com.volmit.iris.util.Desc;
|
||||||
import com.volmit.iris.util.DontObfuscate;
|
import com.volmit.iris.util.DontObfuscate;
|
||||||
@ -43,13 +44,24 @@ public class IrisRegionSpot
|
|||||||
@Desc("If the noise multiplier is below zero, what should the air be filled with?")
|
@Desc("If the noise multiplier is below zero, what should the air be filled with?")
|
||||||
private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero();
|
private IrisBiomePaletteLayer air = new IrisBiomePaletteLayer().zero();
|
||||||
|
|
||||||
private transient CellGenerator spot;
|
private transient AtomicCache<CellGenerator> spot = new AtomicCache<>();
|
||||||
|
|
||||||
public IrisRegionSpot()
|
public IrisRegionSpot()
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CellGenerator getSpotGenerator(RNG rng)
|
||||||
|
{
|
||||||
|
return spot.aquire(() ->
|
||||||
|
{
|
||||||
|
CellGenerator spot = new CellGenerator(rng.nextParallelRNG((int) (168583 * (shuffle + 102) + rarity + (scale * 10465) + biome.length() + type.ordinal() + as.ordinal())));
|
||||||
|
spot.setCellScale(scale);
|
||||||
|
spot.setShuffle(shuffle);
|
||||||
|
return spot;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public double getSpotHeight(RNG rng, double x, double z)
|
public double getSpotHeight(RNG rng, double x, double z)
|
||||||
{
|
{
|
||||||
if(getNoiseMultiplier() == 0)
|
if(getNoiseMultiplier() == 0)
|
||||||
@ -57,26 +69,12 @@ public class IrisRegionSpot
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(spot == null)
|
return getSpotGenerator(rng).getDistance(x, z) * getNoiseMultiplier();
|
||||||
{
|
|
||||||
spot = new CellGenerator(rng.nextParallelRNG((int) (168583 * (shuffle + 102) + rarity + (scale * 10465) + biome.length() + type.ordinal() + as.ordinal())));
|
|
||||||
spot.setCellScale(scale);
|
|
||||||
spot.setShuffle(shuffle);
|
|
||||||
}
|
|
||||||
|
|
||||||
return spot.getDistance(x, z) * getNoiseMultiplier();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSpot(RNG rng, double x, double z)
|
public boolean isSpot(RNG rng, double x, double z)
|
||||||
{
|
{
|
||||||
if(spot == null)
|
if(getSpotGenerator(rng).getIndex(x, z, (int) (Math.round(rarity) + 8)) == (int) ((Math.round(rarity) + 8) / 2))
|
||||||
{
|
|
||||||
spot = new CellGenerator(rng.nextParallelRNG((int) (168583 * (shuffle + 102) + rarity + (scale * 10465) + biome.length() + type.ordinal() + as.ordinal())));
|
|
||||||
spot.setCellScale(scale);
|
|
||||||
spot.setShuffle(shuffle);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(spot.getIndex(x, z, (int) (Math.round(rarity) + 8)) == (int) ((Math.round(rarity) + 8) / 2))
|
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
38
src/main/java/com/volmit/iris/util/IrisLock.java
Normal file
38
src/main/java/com/volmit/iris/util/IrisLock.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package com.volmit.iris.util;
|
||||||
|
|
||||||
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class IrisLock
|
||||||
|
{
|
||||||
|
private final ReentrantLock lock;
|
||||||
|
private final String name;
|
||||||
|
private boolean disabled = false;
|
||||||
|
|
||||||
|
public IrisLock(String name)
|
||||||
|
{
|
||||||
|
this.name = name;
|
||||||
|
lock = new ReentrantLock(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void lock()
|
||||||
|
{
|
||||||
|
if(disabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock.lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void unlock()
|
||||||
|
{
|
||||||
|
if(disabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lock.unlock();
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user