- Forgot to commit this before creating a branch..

- Dev test of Jigsaw structures biome exclusions
This commit is contained in:
RePixelatedMC 2025-04-22 10:38:30 +02:00
parent f42bf07d4e
commit f6033d9c1b
3 changed files with 57 additions and 1 deletions

View File

@ -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<String, Integer> minDistances, int x, int z, KSet<Position2> cachedRegions, KMap<String, KSet<Position2>> cache, KMap<Position2, Double> distanceCache) {
int range = 0;

View File

@ -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<IrisJigsawMinDistance> minDistances = new KList<>();

View File

@ -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<String> excludeBiomes = new KList<>();
}