mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 00:34:19 +00:00
Merge wave1/a1
This commit is contained in:
commit
adb848bf9f
29 files changed
+1286
-17
No files matched your search
@@ -0,0 +1,39 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import com.volmit.resource.ResourceKey;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/** A pack {@code test:pack} without resources. */
|
||||
public final class EmptyResources implements PackResources {
|
||||
private final UUID snapshot = UUID.randomUUID();
|
||||
|
||||
@Override
|
||||
public ResourceId packId() {
|
||||
return new ResourceId("test", "pack");
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID snapshotId() {
|
||||
return snapshot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockRegistry blocks() {
|
||||
throw new AssertionError("Unused blocks");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Optional<T> find(ResourceKey<T> key) {
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ResourceId> ids(Class<?> type) {
|
||||
return List.of();
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,7 @@ import com.volmit.placement.PlacementContext;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.TerrainSampler;
|
||||
import com.volmit.world.BlockView;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.Map;
|
||||
|
||||
/** Tests needing no platform facilities fail loudly if code starts using one. */
|
||||
@@ -24,11 +25,17 @@ public final class TestContexts {
|
||||
|
||||
/** The chunk at the origin; a null {@code settings} or {@code mantle} fails when used. */
|
||||
public static GenerationContext generation(Map<Class<?>, Hunk<?>> hunks, FeatureSettings settings, Mantle mantle) {
|
||||
return generation(hunks, settings, mantle, null);
|
||||
}
|
||||
|
||||
/** The chunk at the origin in {@code world}; a null {@code settings}, {@code mantle} or {@code world} fails when used. */
|
||||
public static GenerationContext generation(Map<Class<?>, Hunk<?>> hunks, FeatureSettings settings, Mantle mantle, PackWorld world) {
|
||||
return new GenerationContext() {
|
||||
public int originX() { return 0; }
|
||||
public int originZ() { return 0; }
|
||||
public long worldSeed() { return SEED; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public PackWorld world() { return used(world, "world"); }
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { return used(settings, "settings"); }
|
||||
public Mantle mantle() { return used(mantle, "mantle"); }
|
||||
@@ -48,6 +55,7 @@ public final class TestContexts {
|
||||
public int originZ() { return originZ; }
|
||||
public long worldSeed() { return SEED; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public PackWorld world() { throw new AssertionError("Unused world"); }
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { return settings; }
|
||||
public Mantle mantle() { return mantle; }
|
||||
@@ -62,6 +70,7 @@ public final class TestContexts {
|
||||
return new PlacementContext() {
|
||||
public long worldSeed() { return SEED; }
|
||||
public PackResources resources() { throw new AssertionError("Unused resources"); }
|
||||
public PackWorld world() { throw new AssertionError("Unused world"); }
|
||||
public TerrainSampler terrain() { throw new AssertionError("Unused terrain"); }
|
||||
public FeatureSettings settings() { throw new AssertionError("Unused settings"); }
|
||||
public ObjectTransformer objects() { throw new AssertionError("Unused transforms"); }
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.volmit.support;
|
||||
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.config.PackSettings;
|
||||
import com.volmit.host.WorldStates;
|
||||
import com.volmit.resource.PackResources;
|
||||
import com.volmit.world.PackWorld;
|
||||
import java.util.List;
|
||||
import java.util.function.Function;
|
||||
|
||||
/** A world for tests: the test seed, no resources, no declared settings, and a real state store. */
|
||||
public final class TestWorld implements PackWorld, AutoCloseable {
|
||||
private final WorldStates states = new WorldStates();
|
||||
|
||||
@Override
|
||||
public long seed() {
|
||||
return TestContexts.SEED;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackResources resources() {
|
||||
throw new AssertionError("Unused resources");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PackSettings settings() {
|
||||
return new PackSettings() {
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
return List.of();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T state(Class<T> type, Function<? super PackWorld, ? extends T> create) {
|
||||
return states.state(type, () -> create.apply(this));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
states.close();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user