Support regions & dimensions + strongholds

This commit is contained in:
Daniel Mills 2021-01-12 18:32:36 -05:00
parent 11d5d74c11
commit 2869a2157b
3 changed files with 83 additions and 17 deletions

View File

@ -39,6 +39,11 @@ public class IrisDimension extends IrisRegistrant
@Desc("Create an inverted dimension in the sky (like the nether)")
private IrisDimension sky = null;
@RegistryListJigsaw
@DontObfuscate
@Desc("If defined, Iris will place the given jigsaw structure where minecraft should place the overworld stronghold.")
private String stronghold;
@DontObfuscate
@Desc("Improves the biome grid variation by shuffling the cell grid more depending on the seed. This makes biomes across multiple seeds look far different than before.")
private boolean aggressiveBiomeReshuffle = false;
@ -204,6 +209,11 @@ public class IrisDimension extends IrisRegistrant
@Desc("Define all of the regions to include in this dimension. Dimensions -> Regions -> Biomes -> Objects etc")
private KList<String> regions = new KList<>();
@ArrayType(min = 1, type = IrisJigsawStructurePlacement.class)
@DontObfuscate
@Desc("Jigsaw structures")
private KList<IrisJigsawStructurePlacement> jigsawStructures = new KList<>();
@Required
@MinNumber(0)
@MaxNumber(255)

View File

@ -25,6 +25,11 @@ public class IrisRegion extends IrisRegistrant implements IRare
@Desc("The name of the region")
private String name = "A Region";
@ArrayType(min = 1, type = IrisJigsawStructurePlacement.class)
@DontObfuscate
@Desc("Jigsaw structures")
private KList<IrisJigsawStructurePlacement> jigsawStructures = new KList<>();
@DontObfuscate
@Desc("Add random chances for terrain features")
@ArrayType(min = 1, type = IrisFeaturePotential.class)

View File

@ -197,8 +197,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
int s = (int) Math.ceil(getParallaxSize() / 2D);
int i,j;
KList<Runnable> after = new KList<>();
// Generate Initial Features
for (i = -s; i <= s; i++) {
for (j = -s; j <= s; j++) {
int xx = i +x;
@ -251,8 +249,9 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
int xx = x<<4;
int zz = z<<4;
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
IrisRegion region = getComplex().getRegionStream().get(xx+8, zz+8);
IrisBiome biome = getComplex().getTrueBiomeStream().get(xx+8, zz+8);
after.addAll(generateParallaxJigsaw(rng, x, z, biome));
after.addAll(generateParallaxJigsaw(rng, x, z, biome, region));
generateParallaxSurface(rng, x, z, biome, true);
generateParallaxMutations(rng, x, z, true);
return after;
@ -269,7 +268,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
int zz = z<<4;
getParallaxAccess().setParallaxGenerated(x, z);
RNG rng = new RNG(Cache.key(x, z)).nextParallelRNG(getEngine().getTarget().getWorld().getSeed());
IrisRegion region = getComplex().getRegionStream().get(xx+8, zz+8);
IrisBiome biome = getComplex().getTrueBiomeStream().get(xx+8, zz+8);
generateParallaxSurface(rng, x, z, biome, false);
generateParallaxMutations(rng, x, z, false);
@ -306,27 +304,80 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer {
generateParallaxLayer(x, z, false);
}
default KList<Runnable> generateParallaxJigsaw(RNG rng, int x, int z, IrisBiome biome) {
default KList<Runnable> placeStructure(IrisPosition position, IrisJigsawStructure structure, RNG rng)
{
KList<Runnable> placeAfter = new KList<>();
for (IrisJigsawStructurePlacement i : biome.getJigsawStructures())
{
if(rng.nextInt(i.getRarity()) == 0)
{
IrisPosition position = new IrisPosition((x<<4) + rng.nextInt(15),0,(z<<4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
if(structure.getFeature() != null)
{
if(structure.getFeature().getBlockRadius() == 32)
{
structure.getFeature().setBlockRadius((double)structure.getMaxDimension()/3);
}
getParallaxAccess().getMetaRW(position.getX() >> 4, position.getZ() >> 4).getFeatures()
.add(new IrisFeaturePositional(position.getX(), position.getZ(), structure.getFeature()));
}
placeAfter.addAll(new PlannedStructure(structure, position, rng).place(this, this));
return placeAfter;
}
default KList<Runnable> generateParallaxJigsaw(RNG rng, int x, int z, IrisBiome biome, IrisRegion region) {
KList<Runnable> placeAfter = new KList<>();
boolean placed = false;
if(getEngine().getDimension().getStronghold() != null)
{
IrisPosition pos = getEngine().getCompound().getStrongholdPosition();
if(x == pos.getX() >> 4 && z == pos.getZ() >> 4)
{
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(getEngine().getDimension().getStronghold());
placeAfter.addAll(placeStructure(pos, structure, rng));
placed = true;
}
}
if(!placed)
{
for (IrisJigsawStructurePlacement i : biome.getJigsawStructures())
{
if(rng.nextInt(i.getRarity()) == 0)
{
IrisPosition position = new IrisPosition((x<<4) + rng.nextInt(15),0,(z<<4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
placeAfter.addAll(placeStructure(position, structure, rng));
placed = true;
}
}
}
if(!placed)
{
for (IrisJigsawStructurePlacement i : region.getJigsawStructures())
{
if(rng.nextInt(i.getRarity()) == 0)
{
IrisPosition position = new IrisPosition((x<<4) + rng.nextInt(15),0,(z<<4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
placeAfter.addAll(placeStructure(position, structure, rng));
placed = true;
}
}
}
if(!placed)
{
for (IrisJigsawStructurePlacement i : getEngine().getDimension().getJigsawStructures())
{
if(rng.nextInt(i.getRarity()) == 0)
{
IrisPosition position = new IrisPosition((x<<4) + rng.nextInt(15),0,(z<<4) + rng.nextInt(15));
IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure());
placeAfter.addAll(placeStructure(position, structure, rng));
placed = true;
}
}
}