From f6033d9c1b071031bd3ef9ee5d98dc9e4bc15ea9 Mon Sep 17 00:00:00 2001 From: RePixelatedMC <107539181+RePixelatedMC@users.noreply.github.com> Date: Tue, 22 Apr 2025 10:38:30 +0200 Subject: [PATCH] - Forgot to commit this before creating a branch.. - Dev test of Jigsaw structures biome exclusions --- .../components/MantleJigsawComponent.java | 22 ++++++++++++- .../object/IrisJigsawStructurePlacement.java | 3 ++ .../engine/object/IrisPlacementExclusion.java | 33 +++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 core/src/main/java/com/volmit/iris/engine/object/IrisPlacementExclusion.java diff --git a/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java b/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java index 6ba27c542..147a972ab 100644 --- a/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java +++ b/core/src/main/java/com/volmit/iris/engine/mantle/components/MantleJigsawComponent.java @@ -93,13 +93,33 @@ public class MantleJigsawComponent extends IrisMantleComponent { try { if (i == null || checkMinDistances(i.collectMinDistances(), x, z, cachedRegions, cache, distanceCache)) return false; - } catch (Throwable ignored) {} + if (!checkBiomes(i, x, z)) + return false; + } catch (Throwable ignored) { + } RNG rng = new RNG(seed); IrisPosition position = new IrisPosition((x << 4) + rng.nextInt(15), 0, (z << 4) + rng.nextInt(15)); IrisJigsawStructure structure = getData().getJigsawStructureLoader().load(i.getStructure()); return place(writer, position, structure, rng, false); } + private boolean checkBiomes(IrisJigsawStructurePlacement placement, int x, int z) { + // todo: biome getting kinda sucks + var biome = getEngineMantle().getEngine().getSurfaceBiome((x << 4) + 8, (z << 4) + 8); + if (biome != null) { + if (biome.isSea() && placement.getExclude().isExcludeOceanBiomes()) { + return false; + } + if (biome.isLand() && placement.getExclude().isExcludeLandBiomes()) { + return false; + } + if (biome.isShore() && placement.getExclude().isExcludeShoreBiomes()) { + return false; + } + } + return true; + } + @ChunkCoordinates private boolean checkMinDistances(KMap minDistances, int x, int z, KSet cachedRegions, KMap> cache, KMap distanceCache) { int range = 0; diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java b/core/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java index 5f0220321..4ca35a7a6 100644 --- a/core/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisJigsawStructurePlacement.java @@ -78,6 +78,9 @@ public class IrisJigsawStructurePlacement implements IRare { @Desc("Threshold for noise style") private double threshold = 0.5; + @Desc("Exclude the structure from certain places") + private IrisPlacementExclusion exclude = new IrisPlacementExclusion(); + @ArrayType(type = IrisJigsawMinDistance.class) @Desc("List of minimum distances to check for") private KList minDistances = new KList<>(); diff --git a/core/src/main/java/com/volmit/iris/engine/object/IrisPlacementExclusion.java b/core/src/main/java/com/volmit/iris/engine/object/IrisPlacementExclusion.java new file mode 100644 index 000000000..38827b27e --- /dev/null +++ b/core/src/main/java/com/volmit/iris/engine/object/IrisPlacementExclusion.java @@ -0,0 +1,33 @@ +package com.volmit.iris.engine.object; + +import com.volmit.iris.engine.object.annotations.ArrayType; +import com.volmit.iris.engine.object.annotations.Desc; +import com.volmit.iris.engine.object.annotations.RegistryListResource; +import com.volmit.iris.util.collection.KList; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +@Accessors(chain = true) +@NoArgsConstructor +@AllArgsConstructor +@Desc("Represents an image map") +@Data +public class IrisPlacementExclusion { + + @Desc("Excludes the structure from all ocean biomes defined in region") + private boolean excludeOceanBiomes; + + @Desc("Excludes the structure from all shore biomes defined in region") + private boolean excludeShoreBiomes; + + @Desc("Excludes the structure from all land biomes defined in region") + private boolean excludeLandBiomes; + + @RegistryListResource(IrisBiome.class) + @Desc("tbd") + @ArrayType(min = 1, type = String.class) + private KList excludeBiomes = new KList<>(); + +}