mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 16:25:36 +00:00
Remove API surface no module or host uses
The object generator registration (registerObject, ObjectGenerator, ObjectGeneratorFactory, ObjectGenerationContext, FeatureRole): the host catalogued generators but never called one. PlacementContext.objects() with ObjectTransformer and ObjectTransform, PlacementContext.blocks() (placementTerrain() answers the same), BlockPalette, EntitySpec.extensions and Reference.BIOME go too.
This commit is contained in:
1 parent
d0b57a4886
commit
2b6f96e5c2
26 files changed
+119
-269
No files matched your search
@@ -3,7 +3,6 @@ package com.volmit;
|
||||
import com.volmit.mantle.MantleCodec;
|
||||
import com.volmit.mantle.MantleKey;
|
||||
import com.volmit.mantle.MantleLifetime;
|
||||
import com.volmit.object.ObjectGeneratorFactory;
|
||||
import com.volmit.resource.ResourceKind;
|
||||
import com.volmit.service.Service;
|
||||
import com.volmit.stage.StageGraph;
|
||||
@@ -24,8 +23,6 @@ public interface FeatureRegistry {
|
||||
*/
|
||||
<T> void registerMantle(MantleKey<T> key, MantleLifetime lifetime, MantleCodec<T> codec);
|
||||
|
||||
<F extends IrisFeature> void registerObject(Class<F> featureType, ObjectGeneratorFactory<F> factory);
|
||||
|
||||
/** Catalogs settings types that no stage names in {@code when(...)}, such as ones read only
|
||||
* through {@link com.volmit.config.FeatureSettings#at}, so the host decodes them and studio
|
||||
* describes them: {@code registerSettings(WindSettings.class, GustSettings.class)}. Settings that a
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.volmit.block;
|
||||
|
||||
import com.volmit.random.WorldRandom;
|
||||
|
||||
/** Resolved, immutable palette. X and Z are world coordinates, Y is the height above the
|
||||
* dimension's bottom (0 = bottom); selection uses only the given stream.
|
||||
* An empty/unresolvable palette is a pack-load error. Implementations must support concurrent calls.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface BlockPalette {
|
||||
BlockState select(int worldX, int y, int worldZ, WorldRandom random);
|
||||
}
|
||||
@@ -2,8 +2,7 @@ package com.volmit.config;
|
||||
|
||||
/** The platform registry a text option names, so studio can offer the matching completion list: entries of the
|
||||
* server's registries, such as {@code minecraft:stone}, including those that data packs and mods add, and the host's
|
||||
* own noise generators. Resources of the pack are named by their kind instead, {@code @Ref(kind = ...)}. The set is
|
||||
* closed: every registry is one the Iris host can list.
|
||||
* own noise generators. Resources of the pack are named by their kind instead, {@code @Ref(kind = ...)}.
|
||||
*/
|
||||
public enum Reference {
|
||||
/** A block type, such as {@code minecraft:stone}. {@link com.volmit.block.BlockState} options are block references without {@link Ref}. */
|
||||
@@ -12,8 +11,6 @@ public enum Reference {
|
||||
ITEM,
|
||||
/** An entity type, such as {@code minecraft:zombie}. */
|
||||
ENTITY,
|
||||
/** A platform biome, such as {@code minecraft:plains}; not a biome of the pack. */
|
||||
BIOME,
|
||||
/** A platform structure, such as {@code minecraft:village_plains}. */
|
||||
STRUCTURE,
|
||||
/** A platform structure or a prefix naming a family of them: {@code minecraft:village_plains},
|
||||
|
||||
@@ -23,11 +23,10 @@ import java.util.Optional;
|
||||
* @param arrival what happens where it appears
|
||||
* @param adjustsProvidedMob whether the rest of the spec also applies to a {@link ContentKey.Provided} mob, which is
|
||||
* otherwise left as its provider set it up
|
||||
* @param extensions values for a particular host, which other hosts ignore; see {@link #extension}
|
||||
*/
|
||||
public record EntitySpec(ContentKey type, Appearance appearance, Behaviour behaviour, Equipment equipment,
|
||||
List<ItemAttribute> attributes, Company company, Drops drops, Arrival arrival,
|
||||
boolean adjustsProvidedMob, List<Object> extensions) {
|
||||
boolean adjustsProvidedMob) {
|
||||
public EntitySpec {
|
||||
Objects.requireNonNull(type, "type");
|
||||
Objects.requireNonNull(appearance, "appearance");
|
||||
@@ -37,12 +36,6 @@ public record EntitySpec(ContentKey type, Appearance appearance, Behaviour behav
|
||||
Objects.requireNonNull(company, "company");
|
||||
Objects.requireNonNull(drops, "drops");
|
||||
Objects.requireNonNull(arrival, "arrival");
|
||||
extensions = List.copyOf(extensions);
|
||||
}
|
||||
|
||||
/** The extension of type {@code type} the module added for its host; empty when it added none. */
|
||||
public <T> Optional<T> extension(Class<T> type) {
|
||||
return extensions.stream().filter(type::isInstance).map(type::cast).findFirst();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.Optional;
|
||||
/** Host-owned invocation inputs. Views must not be retained or used by detached tasks.
|
||||
*
|
||||
* <p>There is no shared random stream. A stage draws from {@link com.volmit.stage.StageContext#random()},
|
||||
* a stream of its own, and an object generator from {@link com.volmit.object.ObjectGenerationContext#random()}.
|
||||
* a stream of its own.
|
||||
*/
|
||||
public interface InvocationContext {
|
||||
/** The world this invocation generates: its seed, the pack snapshot's resources, its settings and the state modules
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.volmit.object;
|
||||
|
||||
import com.volmit.generation.InvocationContext;
|
||||
import com.volmit.random.WorldRandom;
|
||||
|
||||
/** Geometry-only invocation. The host chooses the variant seed and enforces size limits.
|
||||
* Placement and terrain adaptation happen later; generators return reusable local geometry.
|
||||
*/
|
||||
public interface ObjectGenerationContext extends InvocationContext {
|
||||
/** This generation's stream, seeded from the variant seed the host chose. Do not retain it. */
|
||||
WorldRandom random();
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.volmit.object;
|
||||
|
||||
/** Configured geometry generator. Snapshot settings; concurrent calls use only invocation-local
|
||||
* state. Return a non-null object. The host owns variant selection and snapshot-scoped caching.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ObjectGenerator {
|
||||
GeneratedObject generate(ObjectGenerationContext context);
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
package com.volmit.object;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface ObjectGeneratorFactory<F extends IrisFeature> {
|
||||
ObjectGenerator create(F feature);
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
package com.volmit.object;
|
||||
|
||||
/** Requested transform. The host owns rasterization, property orientation and interpolation.
|
||||
* Rotation is in degrees about the object's anchor; mirrors precede scale, then X/Y/Z rotation.
|
||||
* Unsupported transformations fail rather than silently changing the request.
|
||||
*/
|
||||
public record ObjectTransform(double rotationX, double rotationY, double rotationZ,
|
||||
double scaleX, double scaleY, double scaleZ,
|
||||
boolean mirrorX, boolean mirrorY, boolean mirrorZ) {
|
||||
public ObjectTransform {
|
||||
for (double angle : new double[]{rotationX, rotationY, rotationZ}) {
|
||||
if (!Double.isFinite(angle)) throw new IllegalArgumentException("Non-finite rotation");
|
||||
}
|
||||
for (double scale : new double[]{scaleX, scaleY, scaleZ}) {
|
||||
if (!Double.isFinite(scale) || scale <= 0) throw new IllegalArgumentException("Scale must be finite and positive");
|
||||
}
|
||||
}
|
||||
|
||||
public static ObjectTransform identity() { return new ObjectTransform(0, 0, 0, 1, 1, 1, false, false, false); }
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
package com.volmit.object;
|
||||
|
||||
/** Host adapter returning immutable transformed geometry with updated bounds, block properties,
|
||||
* block entities and markers. Cache keys include pack snapshot, source geometry and transform.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ObjectTransformer {
|
||||
GeneratedObject transform(GeneratedObject object, ObjectTransform transform);
|
||||
}
|
||||
@@ -2,9 +2,7 @@ package com.volmit.placement;
|
||||
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.generation.InvocationContext;
|
||||
import com.volmit.object.ObjectTransformer;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.BlockView;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
@@ -14,12 +12,9 @@ import java.util.Optional;
|
||||
public interface PlacementContext extends InvocationContext {
|
||||
TerrainSampler terrain();
|
||||
FeatureSettings settings();
|
||||
ObjectTransformer objects();
|
||||
/** Prepared blocks before this placement. Use stage access for reads of buffered changes. */
|
||||
BlockView blocks();
|
||||
/**
|
||||
* The world the placement is made in, for the questions about a column the stages ask. Its blocks are the ones before
|
||||
* this placement, like {@link #blocks()}; stages write through their access, never into it.
|
||||
* this placement; stages write through their access, never into it.
|
||||
*/
|
||||
PlacementTerrain placementTerrain();
|
||||
/**
|
||||
|
||||
@@ -9,8 +9,7 @@ import java.util.RandomAccess;
|
||||
|
||||
/** A random stream whose every value is defined here, so the same seed gives the same draws on
|
||||
* every machine and every JDK. World generation draws from it: stages through
|
||||
* {@link com.volmit.stage.StageContext#random()}, object generators through
|
||||
* {@link com.volmit.object.ObjectGenerationContext#random()}.
|
||||
* {@link com.volmit.stage.StageContext#random()}.
|
||||
*
|
||||
* <p>It deliberately does not implement {@link java.util.random.RandomGenerator}: that interface's
|
||||
* default methods, and any a later JDK adds, use algorithms the JDK may change, which would change
|
||||
|
||||
@@ -70,14 +70,6 @@ class ItemAndEntityValuesTest {
|
||||
assertThrows(IllegalArgumentException.class, () -> ResourceId.ofPlatformKey("a:b:c"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEntityHandsAHostTheExtensionItReadsAndNothingForAnotherType() {
|
||||
EntitySpec zombie = entity(List.of("iris extras"));
|
||||
|
||||
assertEquals(Optional.of("iris extras"), zombie.extension(String.class));
|
||||
assertEquals(Optional.empty(), zombie.extension(Integer.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
void anEntityCarriesWhatOnlyAPlatformHasANameForInsteadOfAnExtension() {
|
||||
EntitySpec.Appearance panda = new EntitySpec.Appearance(Optional.empty(), false, false, false, Optional.of("PLAYFUL"),
|
||||
@@ -125,7 +117,7 @@ class ItemAndEntityValuesTest {
|
||||
@Test
|
||||
void anAttemptSaysWhetherLightMatters() {
|
||||
BlockPosition at = new BlockPosition(1, 2, 3);
|
||||
EntitySpec zombie = entity(List.of());
|
||||
EntitySpec zombie = zombie();
|
||||
|
||||
assertFalse(new EntitySpawns.Attempt(at, zombie, EntitySpawns.Surface.LAND, 0, 15, true).restrictsLight());
|
||||
assertTrue(new EntitySpawns.Attempt(at, zombie, EntitySpawns.Surface.LAND, 0, 7, true).restrictsLight());
|
||||
@@ -153,9 +145,9 @@ class ItemAndEntityValuesTest {
|
||||
assertThrows(NullPointerException.class, () -> new AmbientEffects.Command(null, 0, 0, 0));
|
||||
}
|
||||
|
||||
private static EntitySpec entity(List<Object> extensions) {
|
||||
private static EntitySpec zombie() {
|
||||
return new EntitySpec(new ContentKey.Registered(ResourceId.parse("minecraft:zombie")), EntitySpec.Appearance.PLAIN,
|
||||
EntitySpec.Behaviour.NATURAL, EntitySpec.Equipment.NONE, List.of(), EntitySpec.Company.NONE,
|
||||
EntitySpec.Drops.PLATFORM, EntitySpec.Arrival.QUIET, false, extensions);
|
||||
EntitySpec.Drops.PLATFORM, EntitySpec.Arrival.QUIET, false);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user