9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-31 04:46:40 +00:00

Localdata

This commit is contained in:
Daniel Mills
2020-08-07 03:56:30 -04:00
parent 60324c041c
commit e5384509cf
21 changed files with 189 additions and 131 deletions

View File

@@ -4,6 +4,7 @@ import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.RarityCellGenerator;
import com.volmit.iris.util.CNG;
@@ -111,13 +112,13 @@ public class IrisBiome extends IrisRegistrant
}
public double getHeight(double x, double z, long seed)
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed)
{
double height = 0;
for(IrisBiomeGeneratorLink i : generators)
{
height += i.getHeight(x, z, seed);
height += i.getHeight(xg, x, z, seed);
}
return Math.max(0, Math.min(height, 255));
@@ -380,7 +381,7 @@ public class IrisBiome extends IrisRegistrant
return biomeSkyScatter.get(getBiomeGenerator(rng).fit(0, biomeSkyScatter.size() - 1, x, y, z));
}
public KList<IrisBiome> getRealChildren()
public KList<IrisBiome> getRealChildren(ContextualChunkGenerator g)
{
return realChildren.aquire(() ->
{
@@ -388,14 +389,14 @@ public class IrisBiome extends IrisRegistrant
for(String i : getChildren())
{
realChildren.add(Iris.data.getBiomeLoader().load(i));
realChildren.add(g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i));
}
return realChildren;
});
}
public KList<String> getAllChildren(int limit)
public KList<String> getAllChildren(ContextualChunkGenerator g, int limit)
{
KSet<String> m = new KSet<>();
m.addAll(getChildren());
@@ -405,9 +406,9 @@ public class IrisBiome extends IrisRegistrant
{
for(String i : getChildren())
{
IrisBiome b = Iris.data.getBiomeLoader().load(i);
IrisBiome b = g != null ? g.loadBiome(i) : Iris.globaldata.getBiomeLoader().load(i);
int l = limit;
m.addAll(b.getAllChildren(l));
m.addAll(b.getAllChildren(g, l));
}
}

View File

@@ -1,6 +1,7 @@
package com.volmit.iris.object;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
@@ -31,11 +32,11 @@ public class IrisBiomeGeneratorLink
}
public IrisGenerator getCachedGenerator()
public IrisGenerator getCachedGenerator(ContextualChunkGenerator g)
{
return gen.aquire(() ->
{
IrisGenerator gen = Iris.data.getGeneratorLoader().load(getGenerator());
IrisGenerator gen = g != null ? g.loadGenerator(getGenerator()) : Iris.globaldata.getGeneratorLoader().load(getGenerator());
if(gen == null)
{
@@ -46,9 +47,9 @@ public class IrisBiomeGeneratorLink
});
}
public double getHeight(double x, double z, long seed)
public double getHeight(ContextualChunkGenerator xg, double x, double z, long seed)
{
double g = getCachedGenerator().getHeight(x, z, seed);
double g = getCachedGenerator(xg).getHeight(x, z, seed);
g = g < 0 ? 0 : g;
g = g > 1 ? 1 : g;

View File

@@ -1,6 +1,6 @@
package com.volmit.iris.object;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
@@ -36,17 +36,17 @@ public class IrisBiomeMutation
private transient AtomicCache<KList<String>> sideACache = new AtomicCache<>();
private transient AtomicCache<KList<String>> sideBCache = new AtomicCache<>();
public KList<String> getRealSideA()
public KList<String> getRealSideA(ContextualChunkGenerator xg)
{
return sideACache.aquire(() -> processList(getSideA()));
return sideACache.aquire(() -> processList(xg, getSideA()));
}
public KList<String> getRealSideB()
public KList<String> getRealSideB(ContextualChunkGenerator xg)
{
return sideBCache.aquire(() -> processList(getSideB()));
return sideBCache.aquire(() -> processList(xg, getSideB()));
}
public KList<String> processList(KList<String> s)
public KList<String> processList(ContextualChunkGenerator xg, KList<String> s)
{
KSet<String> r = new KSet<>();
@@ -56,14 +56,14 @@ public class IrisBiomeMutation
if(q.startsWith("^"))
{
r.addAll(Iris.data.getRegionLoader().load(q.substring(1)).getLandBiomes());
r.addAll(xg.loadRegion(q.substring(1)).getLandBiomes());
continue;
}
else if(q.startsWith("*"))
{
String name = q.substring(1);
r.addAll(Iris.data.getBiomeLoader().load(name).getAllChildren(7));
r.addAll(xg.loadBiome(name).getAllChildren(xg, 7));
}
else if(q.startsWith("!"))
@@ -74,7 +74,7 @@ public class IrisBiomeMutation
else if(q.startsWith("!*"))
{
String name = q.substring(2);
r.removeAll(Iris.data.getBiomeLoader().load(name).getAllChildren(7));
r.removeAll(xg.loadBiome(name).getAllChildren(xg, 7));
}
else

View File

@@ -6,6 +6,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.util.BlockVector;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.gen.PostBlockChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.B;
@@ -548,31 +549,31 @@ public class IrisDimension extends IrisRegistrant
return cosr.aquire(() -> Math.cos(getDimensionAngle()));
}
public KList<IrisRegion> getAllRegions()
public KList<IrisRegion> getAllRegions(ContextualChunkGenerator g)
{
KList<IrisRegion> r = new KList<>();
for(String i : getRegions())
{
r.add(Iris.data.getRegionLoader().load(i));
r.add(g != null ? g.loadRegion(i) : Iris.globaldata.getRegionLoader().load(i));
}
return r;
}
public KList<IrisBiome> getAllBiomes()
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g)
{
KList<IrisBiome> r = new KList<>();
for(IrisRegion i : getAllRegions())
for(IrisRegion i : getAllRegions(g))
{
r.addAll(i.getAllBiomes());
r.addAll(i.getAllBiomes(g));
}
return r;
}
public ChunkPosition getParallaxSize()
public ChunkPosition getParallaxSize(ContextualChunkGenerator g)
{
return parallaxSize.aquire(() ->
{
@@ -580,8 +581,8 @@ public class IrisDimension extends IrisRegistrant
int z = 0;
KSet<String> objects = new KSet<>();
KList<IrisRegion> r = getAllRegions();
KList<IrisBiome> b = getAllBiomes();
KList<IrisRegion> r = getAllRegions(g);
KList<IrisBiome> b = getAllBiomes(g);
for(IrisBiome i : b)
{
@@ -595,7 +596,7 @@ public class IrisDimension extends IrisRegistrant
{
try
{
BlockVector bv = IrisObject.sampleSize(Iris.data.getObjectLoader().findFile(i));
BlockVector bv = IrisObject.sampleSize(g.getData().getObjectLoader().findFile(i));
x = bv.getBlockX() > x ? bv.getBlockX() : x;
z = bv.getBlockZ() > z ? bv.getBlockZ() : z;
}

View File

@@ -150,11 +150,11 @@ public class IrisObject extends IrisRegistrant
if(config.isBore())
{
for(int i = x - Math.floorDiv(w, 2); i <= x + Math.floorDiv(w, 2); i++)
for(int i = x - Math.floorDiv(w, 2); i <= x + Math.floorDiv(w, 2) - (w % 2 == 0 ? 1 : 0); i++)
{
for(int j = y - 1; j <= y + h - 2; j++)
for(int j = y - Math.floorDiv(h, 2); j <= y + Math.floorDiv(h, 2) - (h % 2 == 0 ? 1 : 0); j++)
{
for(int k = z - Math.floorDiv(d, 2); k <= z + Math.floorDiv(d, 2); k++)
for(int k = z - Math.floorDiv(d, 2); k <= z + Math.floorDiv(d, 2) - (d % 2 == 0 ? 1 : 0); k++)
{
placer.set(i, j, k, AIR);
}

View File

@@ -1,6 +1,7 @@
package com.volmit.iris.object;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.util.Desc;
import com.volmit.iris.util.DontObfuscate;
import com.volmit.iris.util.KList;
@@ -64,14 +65,14 @@ public class IrisObjectPlacement
}
public IrisObject getSchematic(RNG random)
public IrisObject getSchematic(ContextualChunkGenerator g, RNG random)
{
if(place.isEmpty())
{
return null;
}
return Iris.data.getObjectLoader().load(place.get(random.nextInt(place.size())));
return (g == null ? Iris.globaldata : g.getData()).getObjectLoader().load(place.get(random.nextInt(place.size())));
}
public int getTriesForChunk(RNG random)

View File

@@ -1,6 +1,7 @@
package com.volmit.iris.object;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.CNG;
import com.volmit.iris.util.Desc;
@@ -176,7 +177,7 @@ public class IrisRegion extends IrisRegistrant
return getShoreHeightGenerator().fitDoubleD(shoreHeightMin, shoreHeightMax, x / shoreHeightZoom, z / shoreHeightZoom);
}
public KList<IrisBiome> getAllBiomes()
public KList<IrisBiome> getAllBiomes(ContextualChunkGenerator g)
{
KMap<String, IrisBiome> b = new KMap<>();
KSet<String> names = new KSet<>();
@@ -196,7 +197,7 @@ public class IrisRegion extends IrisRegistrant
continue;
}
IrisBiome biome = Iris.data.getBiomeLoader().load(i);
IrisBiome biome = (g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i);
b.put(biome.getLoadKey(), biome);
names.remove(i);
names.addAll(biome.getChildren());
@@ -206,42 +207,42 @@ public class IrisRegion extends IrisRegistrant
return b.v();
}
public KList<IrisBiome> getBiomes(InferredType type)
public KList<IrisBiome> getBiomes(ContextualChunkGenerator g, InferredType type)
{
if(type.equals(InferredType.LAND))
{
return getRealLandBiomes();
return getRealLandBiomes(g);
}
else if(type.equals(InferredType.SEA))
{
return getRealSeaBiomes();
return getRealSeaBiomes(g);
}
else if(type.equals(InferredType.SHORE))
{
return getRealShoreBiomes();
return getRealShoreBiomes(g);
}
else if(type.equals(InferredType.CAVE))
{
return getRealCaveBiomes();
return getRealCaveBiomes(g);
}
else if(type.equals(InferredType.ISLAND))
{
return getRealIslandBiomes();
return getRealIslandBiomes(g);
}
else if(type.equals(InferredType.SKYLAND))
{
return getRealSkylandBiomes();
return getRealSkylandBiomes(g);
}
return new KList<>();
}
public KList<IrisBiome> getRealCaveBiomes()
public KList<IrisBiome> getRealCaveBiomes(ContextualChunkGenerator g)
{
return realCaveBiomes.aquire(() ->
{
@@ -249,14 +250,14 @@ public class IrisRegion extends IrisRegistrant
for(String i : getCaveBiomes())
{
realCaveBiomes.add(Iris.data.getBiomeLoader().load(i));
realCaveBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realCaveBiomes;
});
}
public KList<IrisBiome> getRealSkylandBiomes()
public KList<IrisBiome> getRealSkylandBiomes(ContextualChunkGenerator g)
{
return realSkylandBiomes.aquire(() ->
{
@@ -264,14 +265,14 @@ public class IrisRegion extends IrisRegistrant
for(String i : getSkylandBiomes())
{
realSkylandBiomes.add(Iris.data.getBiomeLoader().load(i));
realSkylandBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realSkylandBiomes;
});
}
public KList<IrisBiome> getRealIslandBiomes()
public KList<IrisBiome> getRealIslandBiomes(ContextualChunkGenerator g)
{
return realIslandBiomes.aquire(() ->
{
@@ -279,14 +280,14 @@ public class IrisRegion extends IrisRegistrant
for(String i : getIslandBiomes())
{
realIslandBiomes.add(Iris.data.getBiomeLoader().load(i));
realIslandBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realIslandBiomes;
});
}
public KList<IrisBiome> getRealShoreBiomes()
public KList<IrisBiome> getRealShoreBiomes(ContextualChunkGenerator g)
{
return realShoreBiomes.aquire(() ->
{
@@ -294,14 +295,14 @@ public class IrisRegion extends IrisRegistrant
for(String i : getShoreBiomes())
{
realShoreBiomes.add(Iris.data.getBiomeLoader().load(i));
realShoreBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realShoreBiomes;
});
}
public KList<IrisBiome> getRealSeaBiomes()
public KList<IrisBiome> getRealSeaBiomes(ContextualChunkGenerator g)
{
return realSeaBiomes.aquire(() ->
{
@@ -309,14 +310,14 @@ public class IrisRegion extends IrisRegistrant
for(String i : getSeaBiomes())
{
realSeaBiomes.add(Iris.data.getBiomeLoader().load(i));
realSeaBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realSeaBiomes;
});
}
public KList<IrisBiome> getRealLandBiomes()
public KList<IrisBiome> getRealLandBiomes(ContextualChunkGenerator g)
{
return realLandBiomes.aquire(() ->
{
@@ -324,7 +325,7 @@ public class IrisRegion extends IrisRegistrant
for(String i : getLandBiomes())
{
realLandBiomes.add(Iris.data.getBiomeLoader().load(i));
realLandBiomes.add((g == null ? Iris.globaldata : g.getData()).getBiomeLoader().load(i));
}
return realLandBiomes;

View File

@@ -1,6 +1,7 @@
package com.volmit.iris.object;
import com.volmit.iris.Iris;
import com.volmit.iris.gen.ContextualChunkGenerator;
import com.volmit.iris.gen.ParallaxChunkGenerator;
import com.volmit.iris.gen.atomics.AtomicCache;
import com.volmit.iris.util.CellGenerator;
@@ -52,20 +53,20 @@ public class IrisStructurePlacement
{
RNG rng = g.getMasterRandom().nextParallelRNG(-88738456);
RNG rnp = rng.nextParallelRNG(cx - (cz * cz));
int s = gridSize() - (getStructure().isMergeEdges() ? 1 : 0);
int sh = gridHeight() - (getStructure().isMergeEdges() ? 1 : 0);
int s = gridSize(g) - (getStructure(g).isMergeEdges() ? 1 : 0);
int sh = gridHeight(g) - (getStructure(g).isMergeEdges() ? 1 : 0);
for(int i = cx << 4; i < (cx << 4) + 15; i += Math.max(s / 2, 1))
for(int i = cx << 4; i < (cx << 4) + 15; i += Math.max(s, 1))
{
for(int j = cz << 4; j < (cz << 4) + 15; j += Math.max(s / 2, 1))
for(int j = cz << 4; j < (cz << 4) + 15; j += Math.max(s, 1))
{
if(getStructure().getMaxLayers() <= 1)
if(getStructure(g).getMaxLayers() <= 1)
{
placeLayer(g, rng, rnp, i, 0, j, s, sh);
continue;
}
for(int k = 0; k < s * getStructure().getMaxLayers(); k += Math.max(sh, 1))
for(int k = 0; k < s * getStructure(g).getMaxLayers(); k += Math.max(sh, 1))
{
placeLayer(g, rng, rnp, i, k, j, s, sh);
}
@@ -87,7 +88,7 @@ public class IrisStructurePlacement
}
int h = (height == -1 ? 0 : height) + (Math.floorDiv(k, sh) * sh);
TileResult t = getStructure().getTile(rng, i, h, j);
TileResult t = getStructure(g).getTile(rng, i, h, j);
if(t != null)
{
@@ -96,7 +97,7 @@ public class IrisStructurePlacement
t.getPlacement().setBore(true);
}
IrisObject o = load(t.getTile().getObjects().get(rnp.nextInt(t.getTile().getObjects().size())));
IrisObject o = load(g, t.getTile().getObjects().get(rnp.nextInt(t.getTile().getObjects().size())));
o.place(Math.floorDiv(i, s) * s, height == -1 ? -1 : h, Math.floorDiv(j, s) * s, g, t.getPlacement(), rng);
}
}
@@ -106,24 +107,24 @@ public class IrisStructurePlacement
return config.aquire(() -> new IrisObjectPlacement());
}
public IrisObject load(String s)
public IrisObject load(ContextualChunkGenerator g, String s)
{
return Iris.data.getObjectLoader().load(s);
return g.getData().getObjectLoader().load(s);
}
public int gridSize()
public int gridSize(ContextualChunkGenerator g)
{
return getStructure().getGridSize();
return getStructure(g).getGridSize();
}
public int gridHeight()
public int gridHeight(ContextualChunkGenerator g)
{
return getStructure().getGridHeight();
return getStructure(g).getGridHeight();
}
public IrisStructure getStructure()
public IrisStructure getStructure(ContextualChunkGenerator g)
{
return structure.aquire(() -> Iris.data.getStructureLoader().load(getTileset()));
return structure.aquire(() -> (g == null ? Iris.globaldata : g.getData()).getStructureLoader().load(getTileset()));
}
public boolean hasStructure(RNG random, double x, double y, double z)