mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
Merge branch 'wave3/c' into feat/irisapi-host
# Conflicts: # core/src/test/java/art/arcane/iris/core/modules/DecorantSettingsDecodingTest.java # core/src/test/java/art/arcane/iris/engine/actuator/TerrainModuleTest.java # core/src/test/java/art/arcane/iris/engine/object/world/biome/IrisBiomeInferenceIsolationTest.java
This commit is contained in:
commit
94f7551fa0
33 files changed
+2469
-320
No files matched your search
@@ -24,6 +24,7 @@ import com.volmit.host.FeatureCatalog;
|
||||
import com.volmit.entity.EntitySpec;
|
||||
import com.volmit.item.ItemDrop;
|
||||
import com.volmit.service.BlockDrops;
|
||||
import com.volmit.service.CaveBiomes;
|
||||
import com.volmit.service.EntitySpawns;
|
||||
import com.volmit.service.LocateResult;
|
||||
import com.volmit.service.Loot;
|
||||
@@ -47,6 +48,19 @@ public final class ModuleServices {
|
||||
private ModuleServices() {
|
||||
}
|
||||
|
||||
/** The pack biome key the module that decides cave biomes puts at the position, whatever the regions say; empty where it overrides nothing. {@code y} is the height above the dimension's bottom. */
|
||||
public static Optional<String> overriddenCaveBiome(Engine engine, int x, int y, int z) {
|
||||
return catalog(engine.getData()).service(CaveBiomes.class)
|
||||
.flatMap(provider -> provider.overriddenBiome(engine.getGeneration().world(), x, y, z));
|
||||
}
|
||||
|
||||
/** How many blocks below the surface the caves of the pack biome {@code biomeKey} begin; 0 where nothing limits them. */
|
||||
public static int caveMinDepthBelowSurface(Engine engine, String biomeKey) {
|
||||
return catalog(engine.getData()).service(CaveBiomes.class)
|
||||
.map(provider -> provider.minDepthBelowSurface(engine.getGeneration().world(), biomeKey))
|
||||
.orElse(0);
|
||||
}
|
||||
|
||||
/** The objects every module would place in the chunk at {@code chunkX}, {@code chunkZ}, guessed without generating it. */
|
||||
public static Set<String> objectsAt(Engine engine, int chunkX, int chunkZ) {
|
||||
PackWorld world = engine.getGeneration().world();
|
||||
|
||||
@@ -19,12 +19,17 @@
|
||||
package art.arcane.iris.core.modules;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.LinkedBiomes;
|
||||
import com.volmit.host.ConfiguredSettings;
|
||||
import com.volmit.resource.ResourceId;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Module settings one dimension, region, biome or object placement declares, at most one value per settings
|
||||
@@ -55,6 +60,32 @@ public final class ModuleSettings {
|
||||
return values.isEmpty();
|
||||
}
|
||||
|
||||
/** The biomes these settings add to the biome tree of the owner's regions ({@link LinkedBiomes#treeBiomes}), in a fixed order. */
|
||||
public Set<String> treeBiomes() {
|
||||
return linkedBiomes(LinkedBiomes::treeBiomes);
|
||||
}
|
||||
|
||||
/**
|
||||
* The biomes these settings use besides ({@link LinkedBiomes#usedBiomes}), in a fixed order.
|
||||
*
|
||||
* @param dimension the settings of the dimension the owner is part of
|
||||
*/
|
||||
public Set<String> usedBiomes(ModuleSettings dimension) {
|
||||
return linkedBiomes(linked -> linked.usedBiomes(dimension.values()));
|
||||
}
|
||||
|
||||
private Set<String> linkedBiomes(Function<LinkedBiomes, Set<String>> pick) {
|
||||
if (values.isEmpty()) {
|
||||
return Set.of();
|
||||
}
|
||||
Set<String> biomes = new LinkedHashSet<>();
|
||||
values.values().stream()
|
||||
.filter(LinkedBiomes.class::isInstance)
|
||||
.sorted(Comparator.comparing(value -> value.getClass().getName()))
|
||||
.forEach(value -> biomes.addAll(pick.apply((LinkedBiomes) value)));
|
||||
return biomes;
|
||||
}
|
||||
|
||||
/** These settings as one placement's own, declared by {@code source}. */
|
||||
public ConfiguredSettings placement(ResourceId source) {
|
||||
return isEmpty() ? ConfiguredSettings.none() : ConfiguredSettings.placement(source, values.values().toArray(IrisFeature[]::new));
|
||||
|
||||
@@ -28,6 +28,7 @@ import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||
import art.arcane.iris.core.nms.container.BlockPos;
|
||||
import art.arcane.iris.core.nms.container.Pair;
|
||||
import art.arcane.iris.core.modules.ModuleServices;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
import art.arcane.iris.engine.UpperDimensionContext;
|
||||
import art.arcane.iris.engine.data.chunk.TerrainChunk;
|
||||
@@ -35,8 +36,6 @@ import art.arcane.iris.engine.mantle.EngineMantle;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.engine.object.value.IrisColor;
|
||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingEntry;
|
||||
import art.arcane.iris.engine.object.terrain.carving.IrisDimensionCarvingResolver;
|
||||
import art.arcane.iris.engine.object.runtime.IrisEngineData;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||
@@ -72,6 +71,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -274,20 +274,11 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
||||
|
||||
@BlockCoordinates
|
||||
default IrisBiome getCaveBiome(int x, int y, int z) {
|
||||
return getCaveBiome(x, y, z, null);
|
||||
}
|
||||
|
||||
@BlockCoordinates
|
||||
default IrisBiome getCaveBiome(int x, int y, int z, IrisDimensionCarvingResolver.State state) {
|
||||
IrisBiome surfaceBiome = getSurfaceBiome(x, z);
|
||||
int worldY = y + getWorld().minHeight();
|
||||
IrisDimensionCarvingEntry rootCarvingEntry = IrisDimensionCarvingResolver.resolveRootEntry(this, worldY, state);
|
||||
if (rootCarvingEntry != null) {
|
||||
IrisDimensionCarvingEntry resolvedCarvingEntry = IrisDimensionCarvingResolver.resolveFromRoot(this, rootCarvingEntry, x, z, state);
|
||||
IrisBiome resolvedCarvingBiome = IrisDimensionCarvingResolver.resolveEntryBiome(this, resolvedCarvingEntry, state);
|
||||
if (resolvedCarvingBiome != null) {
|
||||
return resolvedCarvingBiome;
|
||||
}
|
||||
Optional<String> overriddenKey = ModuleServices.overriddenCaveBiome(this, x, y, z);
|
||||
IrisBiome overriddenBiome = overriddenKey.map(key -> getData().getBiomeLoader().load(key)).orElse(null);
|
||||
if (overriddenBiome != null) {
|
||||
return overriddenBiome;
|
||||
}
|
||||
|
||||
IrisBiome caveBiome = getCaveBiome(x, z);
|
||||
@@ -301,7 +292,7 @@ public interface Engine extends DataProvider, Fallible, BlockUpdater, Renderer,
|
||||
return surfaceBiome;
|
||||
}
|
||||
|
||||
int minDepth = Math.max(0, caveBiome.getCaveMinDepthBelowSurface());
|
||||
int minDepth = Math.max(0, ModuleServices.caveMinDepthBelowSurface(this, caveBiome.getLoadKey()));
|
||||
if (depthBelowSurface < minDepth) {
|
||||
return surfaceBiome;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user