diff --git a/src/main/java/com/volmit/iris/object/IrisDimension.java b/src/main/java/com/volmit/iris/object/IrisDimension.java index bfb89b56e..66358279e 100644 --- a/src/main/java/com/volmit/iris/object/IrisDimension.java +++ b/src/main/java/com/volmit/iris/object/IrisDimension.java @@ -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 regions = new KList<>(); + @ArrayType(min = 1, type = IrisJigsawStructurePlacement.class) + @DontObfuscate + @Desc("Jigsaw structures") + private KList jigsawStructures = new KList<>(); + @Required @MinNumber(0) @MaxNumber(255) diff --git a/src/main/java/com/volmit/iris/object/IrisRegion.java b/src/main/java/com/volmit/iris/object/IrisRegion.java index 37e539b7b..65fd87a8a 100644 --- a/src/main/java/com/volmit/iris/object/IrisRegion.java +++ b/src/main/java/com/volmit/iris/object/IrisRegion.java @@ -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 jigsawStructures = new KList<>(); + @DontObfuscate @Desc("Add random chances for terrain features") @ArrayType(min = 1, type = IrisFeaturePotential.class) diff --git a/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java b/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java index 4bafe90ab..9506f91a7 100644 --- a/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java +++ b/src/main/java/com/volmit/iris/scaffold/engine/EngineParallaxManager.java @@ -197,8 +197,6 @@ public interface EngineParallaxManager extends DataProvider, IObjectPlacer { int s = (int) Math.ceil(getParallaxSize() / 2D); int i,j; KList 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 generateParallaxJigsaw(RNG rng, int x, int z, IrisBiome biome) { + default KList placeStructure(IrisPosition position, IrisJigsawStructure structure, RNG rng) + { KList placeAfter = new KList<>(); - for (IrisJigsawStructurePlacement i : biome.getJigsawStructures()) + if(structure.getFeature() != null) { - if(rng.nextInt(i.getRarity()) == 0) + if(structure.getFeature().getBlockRadius() == 32) { - IrisPosition position = new IrisPosition((x<<4) + rng.nextInt(15),0,(z<<4) + rng.nextInt(15)); - IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); + structure.getFeature().setBlockRadius((double)structure.getMaxDimension()/3); + } - if(structure.getFeature() != null) + 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 generateParallaxJigsaw(RNG rng, int x, int z, IrisBiome biome, IrisRegion region) { + KList 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) { - 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())); + 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; } + } + } - placeAfter.addAll(new PlannedStructure(structure, position, rng).place(this, this)); + 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; + } } }