mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 16:54:04 +00:00
VanillaFeatures service: whether the platform's own placed features run over a world and which steps and features they skip
@Service(ALL): generates(world) (off unless a module turns it on), generatesStep(world, Optional<DecorationStep>) (empty for a step the API does not name) and generatesFeature(world, feature); any provider may refuse a step or a feature. Answers depend on the world only; the host asks once per world, step and feature. README services table, DESIGN services and feature map, CONTRACTS types and host duty; a test that a silent provider leaves the pass off.
This commit is contained in:
1 parent
cf8b2bb0f6
commit
8676ebc328
5 files changed
+60
-1
No files matched your search
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.volmit;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.OptionsMetadata;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.service.VanillaFeatures;
|
||||
import com.volmit.service.VanillaStructures;
|
||||
import com.volmit.vanilla.DecorationStep;
|
||||
import com.volmit.vanilla.JigsawOverrides;
|
||||
@@ -124,6 +125,16 @@ class VanillaStructureValuesTest {
|
||||
assertEquals(VanillaStructureRule.GENERATE, new VanillaStructures() { }.rule(CITY, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void aFeatureProviderThatSaysNothingLeavesThePlatformsFeaturesOff() {
|
||||
VanillaFeatures silent = new VanillaFeatures() { };
|
||||
|
||||
assertFalse(silent.generates(null));
|
||||
assertTrue(silent.generatesStep(null, Optional.of(DecorationStep.UNDERGROUND_ORES)));
|
||||
assertTrue(silent.generatesStep(null, Optional.empty()));
|
||||
assertTrue(silent.generatesFeature(null, ResourceId.parse("minecraft:ore_diamond")));
|
||||
}
|
||||
|
||||
private static List<String> names(Class<?> type) {
|
||||
return OptionsMetadata.inspect(type).options().stream().map(OptionsMetadata.Option::name).toList();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user