mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Merge branch 'wave3b/3'
# Conflicts: # CONTRACTS.md
This commit is contained in:
commit
3ab8b88e56
10 files changed
+199
-32
No files matched your search
@@ -6,7 +6,7 @@ import java.util.Set;
|
||||
|
||||
/** Finds the structures a module places, for the host's structure commands and index. Structures are named by their
|
||||
* keys, in the form packs write them ({@code castle}, {@code villages/plains}). The host asks the providers in order and
|
||||
* sends a key to the first that can locate it in the world.
|
||||
* sends a key to the first that places it in the world ({@link #placed}).
|
||||
*/
|
||||
@Service(Providers.FIRST)
|
||||
public interface StructureLocator {
|
||||
@@ -20,10 +20,19 @@ public interface StructureLocator {
|
||||
*/
|
||||
Set<String> locatable(PackWorld world);
|
||||
|
||||
/** The keys under which {@link #locate} finds the structures this module places in {@code world}, locatable or not: its
|
||||
* own structures, the platform structures it starts itself and the platform structures its own stand in for (namespaced,
|
||||
* such as {@code minecraft:ancient_city}). Commands report them and send a search for one of them here. By default the
|
||||
* {@link #locatable} ones.
|
||||
*/
|
||||
default Set<String> placed(PackWorld world) {
|
||||
return locatable(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* The start of structure {@code key} nearest to the column {@code fromX}, {@code fromZ} (world coordinates), searched
|
||||
* up to {@code maxRadiusChunks} chunks away from it. The position is the structure's origin: world X and Z, and Y the
|
||||
* height above the dimension's bottom of its base. Called with a key from {@link #locatable}. May take long; the
|
||||
* height above the dimension's bottom of its base. Called with a key from {@link #placed}. May take long; the
|
||||
* host calls it off the server's main thread.
|
||||
*/
|
||||
LocateResult locate(PackWorld world, String key, int fromX, int fromZ, int maxRadiusChunks);
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.volmit.service;
|
||||
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.vanilla.DecorationStep;
|
||||
import com.volmit.world.PackWorld;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* A module's say over the platform's own placed features in the pack's worlds: the ores, trees, plants, springs and other
|
||||
* decorations Minecraft, data packs and mods declare for a biome. By default the platform runs none of them over the pack's
|
||||
* terrain. The host asks every provider, in module id order: it runs the platform's feature pass in a world when any
|
||||
* provider turns it on with {@link #generates}, and then skips a decoration step or a feature that any provider refuses.
|
||||
*
|
||||
* <p>Every answer is decided from the world alone (its settings and resources), never from a position: the host asks once
|
||||
* per world, and once per world and step or feature, and keeps the answer while the world runs. Every method may be
|
||||
* called from any thread, concurrently.
|
||||
*/
|
||||
@Service(Providers.ALL)
|
||||
public interface VanillaFeatures {
|
||||
/** Whether the platform runs its placed features over the terrain of {@code world}. False when the module has no part in it. */
|
||||
default boolean generates(PackWorld world) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the platform places the features of decoration step {@code step} in {@code world}: empty for a step of a newer
|
||||
* platform the API does not know yet. True when the module has no part in it.
|
||||
*/
|
||||
default boolean generatesStep(PackWorld world, Optional<DecorationStep> step) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Whether the platform places the feature {@code feature}, such as {@code minecraft:ore_diamond}, in {@code world}. True when the module has no part in it. */
|
||||
default boolean generatesFeature(PackWorld world, ResourceId feature) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -10,8 +10,10 @@ import com.volmit.vanilla.VanillaStructureRule;
|
||||
import com.volmit.vanilla.VanillaStructureSetup;
|
||||
import com.volmit.vanilla.VanillaStructureStart;
|
||||
import com.volmit.vanilla.VanillaStructureStartContext;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
/** A module's say over the platform's own structures, the ones Minecraft, data packs and mods register, in the pack's
|
||||
* worlds. The host asks every provider, in module id order:
|
||||
@@ -91,4 +93,37 @@ public interface VanillaStructures {
|
||||
default VanillaStructureSetup setup(VanillaStructureContext context) {
|
||||
return VanillaStructureSetup.UNCHANGED;
|
||||
}
|
||||
|
||||
/** The platform structures this module starts itself in {@code world} ({@link #starts}), wherever its own placements put
|
||||
* them. The host's locate and structure commands send them to {@link #locateStart}.
|
||||
*/
|
||||
default Set<ResourceId> startedStructures(PackWorld world) {
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
/** Those of {@link #startedStructures} whose starts {@link #locateStart} can find in {@code world}: a start whose
|
||||
* placement can never start in the world's height, for one, cannot be searched for.
|
||||
*/
|
||||
default Set<ResourceId> locatableStarts(PackWorld world) {
|
||||
return Set.of();
|
||||
}
|
||||
|
||||
/**
|
||||
* The start of the platform structure {@code structure} this module makes nearest to the column {@code fromX},
|
||||
* {@code fromZ} (world coordinates), searched ring by ring outward through its placements' grids up to {@code maxRings}
|
||||
* rings: the nearest start of the first ring that has one. The position is the start's origin: world X and Z, and Y the
|
||||
* height above the dimension's bottom of its base. Only chunks {@code accepts} allows count; the host checks the start
|
||||
* the platform made there and searches again without a chunk it refuses. An exception {@code accepts} throws ends the
|
||||
* search and reaches the caller. Called with a structure from {@link #locatableStarts}, off the server's main thread.
|
||||
*/
|
||||
default LocateResult locateStart(PackWorld world, ResourceId structure, int fromX, int fromZ, int maxRings,
|
||||
ChunkFilter accepts) {
|
||||
return LocateResult.NOT_FOUND;
|
||||
}
|
||||
|
||||
/** Which chunks a {@link #locateStart} search may answer with. */
|
||||
@FunctionalInterface
|
||||
interface ChunkFilter {
|
||||
boolean accepts(int chunkX, int chunkZ);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.volmit.vanilla;
|
||||
|
||||
import com.volmit.config.Desc;
|
||||
|
||||
/** A decoration step of the platform's chunk generation, in the platform's order: the step in which it places a structure's
|
||||
* pieces, or a placed feature such as an ore or a tree.
|
||||
*/
|
||||
@Desc("A decoration step of the platform's chunk generation. Structures and placed features are grouped into these steps, which run in this order.")
|
||||
public enum DecorationStep {
|
||||
@Desc("Raw generation - the earliest step, before lakes.")
|
||||
RAW_GENERATION,
|
||||
@Desc("Lakes.")
|
||||
LAKES,
|
||||
@Desc("Local modifications such as amethyst geodes, icebergs and dripstone clusters.")
|
||||
LOCAL_MODIFICATIONS,
|
||||
@Desc("Underground structures, and the features tagged to run with them.")
|
||||
UNDERGROUND_STRUCTURES,
|
||||
@Desc("Surface structures, and the features tagged to run with them.")
|
||||
SURFACE_STRUCTURES,
|
||||
@Desc("Strongholds.")
|
||||
STRONGHOLDS,
|
||||
@Desc("Underground ores. This is the step that carries vanilla and mod ore veins.")
|
||||
UNDERGROUND_ORES,
|
||||
@Desc("Underground decoration such as glow lichen, sculk patches and cave vegetation.")
|
||||
UNDERGROUND_DECORATION,
|
||||
@Desc("Fluid springs - the small water and lava spring features.")
|
||||
FLUID_SPRINGS,
|
||||
@Desc("Vegetal decoration - trees, grass, flowers, kelp and most surface plant life.")
|
||||
VEGETAL_DECORATION,
|
||||
@Desc("Top layer modification - freezing and snow placement.")
|
||||
TOP_LAYER_MODIFICATION;
|
||||
|
||||
/** Whether this is one of the steps the platform places its underground structures in. */
|
||||
public boolean isUnderground() {
|
||||
return this == UNDERGROUND_STRUCTURES || this == UNDERGROUND_DECORATION || this == STRONGHOLDS;
|
||||
}
|
||||
}
|
||||
@@ -67,7 +67,7 @@ public interface StructureFit {
|
||||
|
||||
int chunkZ();
|
||||
|
||||
StructureStep step();
|
||||
DecorationStep step();
|
||||
|
||||
/** The terrain adaptation the platform's definition of the structure asks for. */
|
||||
TerrainAdaptation adaptation();
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
package com.volmit.vanilla;
|
||||
|
||||
/** The decoration step in which the platform places a structure's pieces, in the platform's order. */
|
||||
public enum StructureStep {
|
||||
RAW_GENERATION,
|
||||
LAKES,
|
||||
LOCAL_MODIFICATIONS,
|
||||
UNDERGROUND_STRUCTURES,
|
||||
SURFACE_STRUCTURES,
|
||||
STRONGHOLDS,
|
||||
UNDERGROUND_ORES,
|
||||
UNDERGROUND_DECORATION,
|
||||
FLUID_SPRINGS,
|
||||
VEGETAL_DECORATION,
|
||||
TOP_LAYER_MODIFICATION;
|
||||
|
||||
/** Whether this is one of the steps the platform places its underground structures in. */
|
||||
public boolean isUnderground() {
|
||||
return this == UNDERGROUND_STRUCTURES || this == UNDERGROUND_DECORATION || this == STRONGHOLDS;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user