mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-28 08:44:50 +00:00
Host side for ported terrain, decorant and deposit: caverns layer, surface kind, image-map ground blocks, bottom world Y, the upper dimension, biomes' own settings, vanilla biome, ore variants, COMPLEX seed; deposit leaves the compiled-in list
This commit is contained in:
1 parent
48e328baef
commit
15a7250ffe
20 files changed
+769
-156
No files matched your search
@@ -21,6 +21,7 @@ package art.arcane.iris.core.modules;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.SeedManager;
|
||||
import art.arcane.iris.engine.modifier.DepositModule;
|
||||
import art.arcane.iris.engine.modifier.MatterModule;
|
||||
import art.arcane.iris.engine.modifier.PerfectionModule;
|
||||
import art.arcane.iris.engine.modifier.PostModule;
|
||||
@@ -51,7 +52,7 @@ public final class BuiltInPack {
|
||||
* with Iris; {@code BuiltInModulesJarTest} loads the same modules from the jar instead.
|
||||
*/
|
||||
public static List<IrisModule> jarModules() {
|
||||
return List.of(new PostModule(), new PerfectionModule(), new MatterModule());
|
||||
return List.of(new PostModule(), new PerfectionModule(), new MatterModule(), new DepositModule());
|
||||
}
|
||||
|
||||
/** Every built-in module: Iris's own and the compiled-in copies of the jar's ({@link #jarModules()}). */
|
||||
|
||||
@@ -41,14 +41,15 @@ public class IrisWorldFacadesTest {
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(seeds.getBiome()).thenReturn(1L);
|
||||
when(seeds.getCarve()).thenReturn(2L);
|
||||
when(seeds.getComponent()).thenReturn(3L);
|
||||
when(seeds.getDecorator()).thenReturn(4L);
|
||||
when(seeds.getDeposit()).thenReturn(5L);
|
||||
when(seeds.getEntity()).thenReturn(6L);
|
||||
when(seeds.getLoot()).thenReturn(7L);
|
||||
when(seeds.getMantle()).thenReturn(8L);
|
||||
when(seeds.getPost()).thenReturn(9L);
|
||||
when(seeds.getTerrain()).thenReturn(10L);
|
||||
when(seeds.getComplex()).thenReturn(3L);
|
||||
when(seeds.getComponent()).thenReturn(4L);
|
||||
when(seeds.getDecorator()).thenReturn(5L);
|
||||
when(seeds.getDeposit()).thenReturn(6L);
|
||||
when(seeds.getEntity()).thenReturn(7L);
|
||||
when(seeds.getLoot()).thenReturn(8L);
|
||||
when(seeds.getMantle()).thenReturn(9L);
|
||||
when(seeds.getPost()).thenReturn(10L);
|
||||
when(seeds.getTerrain()).thenReturn(11L);
|
||||
Engine engine = engine(new IrisDimension());
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
PackWorld world = new IrisPackWorld(engine);
|
||||
|
||||
@@ -65,6 +65,7 @@ import com.volmit.config.FeatureSettings.Entry;
|
||||
import com.volmit.resource.ResourceKey;
|
||||
import com.volmit.stage.Pipeline;
|
||||
import com.volmit.stage.StageGraph;
|
||||
import com.volmit.world.BiomeKind;
|
||||
import com.volmit.world.BiomeSample;
|
||||
import com.volmit.world.BlockPosition;
|
||||
import com.volmit.world.PackWorld;
|
||||
@@ -74,6 +75,7 @@ import com.volmit.world.TerrainSampler;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
@@ -93,7 +95,10 @@ public final class ApiChunk implements GenerationContext {
|
||||
public static final int WIDTH = 16;
|
||||
public static final BlockState AIR = new BlockState("minecraft:air");
|
||||
private static final long SEED = 1337L;
|
||||
/** A key that the fixture's pack has no block for. */
|
||||
public static final String UNKNOWN_BLOCK = "unknown_block";
|
||||
private static final ResourceId DIMENSION = ResourceId.parse("test:dimension/overworld");
|
||||
private static final ResourceId REGION = ResourceId.parse("test:region/plains");
|
||||
private static final ResourceId BIOME = ResourceId.parse("test:biome/plains");
|
||||
private static final int TERRAIN_MARGIN = 16;
|
||||
private static final Set<String> AIRS = Set.of("minecraft:air", "minecraft:cave_air", "minecraft:void_air");
|
||||
@@ -112,8 +117,13 @@ public final class ApiChunk implements GenerationContext {
|
||||
private final ArrayHunk<BlockState> blocks;
|
||||
private final Map<BlockPosition, BlockState> planned = new HashMap<>();
|
||||
private final World world = new World();
|
||||
private final Set<BlockPosition> carved = new HashSet<>();
|
||||
private final List<IrisFeature> dimensionSettings = new ArrayList<>();
|
||||
private final List<IrisFeature> regionSettings = new ArrayList<>();
|
||||
private final List<IrisFeature> biomeSettings = new ArrayList<>();
|
||||
private BiomeSample biomeSample;
|
||||
private BiomeKind surfaceKind = BiomeKind.LAND;
|
||||
private int minWorldY;
|
||||
private IntBinaryOperator surface = (x, z) -> 0;
|
||||
private IntBinaryOperator upperDimension;
|
||||
private double slope;
|
||||
@@ -151,6 +161,53 @@ public final class ApiChunk implements GenerationContext {
|
||||
return this;
|
||||
}
|
||||
|
||||
/** The biomes every column and cave position of the chunk has. */
|
||||
public ApiChunk biomes(ResourceId surfaceBiome, ResourceId caveBiome) {
|
||||
this.biomeSample = new BiomeSample(ResourceId.parse("test:region/plains"), surfaceBiome, Optional.ofNullable(caveBiome));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** What the surface biome of every column is generated as. */
|
||||
public ApiChunk surfaceKind(BiomeKind kind) {
|
||||
this.surfaceKind = kind;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** The Y in the world of the dimension's bottom. */
|
||||
public ApiChunk minWorldY(int minWorldY) {
|
||||
this.minWorldY = minWorldY;
|
||||
return this;
|
||||
}
|
||||
|
||||
/** A void the mantle carved, in world coordinates. */
|
||||
public ApiChunk carve(int x, int y, int z) {
|
||||
carved.add(new BlockPosition(x, y, z));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Settings the dimension declares. */
|
||||
public ApiChunk dimensionSettings(IrisFeature... settings) {
|
||||
dimensionSettings.addAll(List.of(settings));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Settings every region of the chunk declares. */
|
||||
public ApiChunk regionSettings(IrisFeature... settings) {
|
||||
regionSettings.addAll(List.of(settings));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Settings every surface biome of the chunk declares. */
|
||||
public ApiChunk biomeSettings(IrisFeature... settings) {
|
||||
biomeSettings.addAll(List.of(settings));
|
||||
return this;
|
||||
}
|
||||
|
||||
/** The blocks the fixture's pack knows, by the rule in {@link Blocks}. */
|
||||
public static BlockRegistry blocks() {
|
||||
return new Blocks();
|
||||
}
|
||||
|
||||
/** A block a placement planned in the mantle, in world coordinates. */
|
||||
public ApiChunk plan(int x, int y, int z, BlockState block) {
|
||||
planned.put(new BlockPosition(x, y, z), block);
|
||||
@@ -197,9 +254,9 @@ public final class ApiChunk implements GenerationContext {
|
||||
return TestSettings.with(new PaletteLayer(), "palette", List.of(BlockSpec.of(block.key())), "slopeCondition", slope);
|
||||
}
|
||||
|
||||
/** Empty stand-ins for the built-in stages the ported modules order after: carving and floating islands. */
|
||||
/** Empty stand-ins for the built-in stages the ported modules order after: terrain, carving and floating islands. */
|
||||
public static List<IrisModule> standIns() {
|
||||
return List.of(new CarveStandIn(), new FloatingStandIn());
|
||||
return List.of(new TerrainStandIn(), new CarveStandIn(), new FloatingStandIn());
|
||||
}
|
||||
|
||||
/** Runs {@code modules} as a pack's chunk graph, with the {@link #standIns()}. */
|
||||
@@ -242,6 +299,7 @@ public final class ApiChunk implements GenerationContext {
|
||||
public <F extends IrisFeature> List<Entry<F>> at(Class<F> featureType, int worldX, int worldZ) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
addEntries(entries, featureType, Target.DIMENSION, DIMENSION, dimensionSettings);
|
||||
addEntries(entries, featureType, Target.REGION, REGION, regionSettings);
|
||||
addEntries(entries, featureType, Target.BIOME, BIOME, biomeSettings);
|
||||
return entries;
|
||||
}
|
||||
@@ -302,7 +360,21 @@ public final class ApiChunk implements GenerationContext {
|
||||
|
||||
@Override
|
||||
public BiomeSample biome(int worldX, int y, int worldZ) {
|
||||
throw new UnsupportedOperationException("The ported built-ins read biomes through their settings");
|
||||
if (biomeSample == null) {
|
||||
throw new UnsupportedOperationException("The ported built-ins read biomes through their settings");
|
||||
}
|
||||
return biomeSample;
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeKind surfaceKind(int worldX, int worldZ) {
|
||||
requireInside(worldX, worldZ);
|
||||
return surfaceKind;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int minWorldY() {
|
||||
return minWorldY;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -339,6 +411,11 @@ public final class ApiChunk implements GenerationContext {
|
||||
return new PlannedLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MantleLayer<Boolean> caverns() {
|
||||
return new CarvedLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MantleEdit edit() {
|
||||
throw new UnsupportedOperationException("Chunk stages do not edit the mantle");
|
||||
@@ -381,8 +458,41 @@ public final class ApiChunk implements GenerationContext {
|
||||
}
|
||||
}
|
||||
|
||||
private final class CarvedLayer implements MantleLayer<Boolean> {
|
||||
@Override
|
||||
public Boolean get(int x, int y, int z) {
|
||||
return carved.contains(new BlockPosition(x, y, z)) ? Boolean.TRUE : null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void set(int x, int y, int z, Boolean value) {
|
||||
throw new UnsupportedOperationException("Caverns are read-only");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(int x, int y, int z) {
|
||||
throw new UnsupportedOperationException("Caverns are read-only");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visit(BlockBox area, MantleVisitor<Boolean> visitor) {
|
||||
List<BlockPosition> positions = new ArrayList<>(carved);
|
||||
positions.sort(VISIT_ORDER);
|
||||
for (BlockPosition position : positions) {
|
||||
if (area.contains(position.x(), position.y(), position.z())) {
|
||||
visitor.accept(position.x(), position.y(), position.z(), Boolean.TRUE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear(BlockBox area) {
|
||||
throw new UnsupportedOperationException("Caverns are read-only");
|
||||
}
|
||||
}
|
||||
|
||||
/** A world of the chunk: its pack's blocks, a state store and Iris's seeds, each the world seed plus its place. */
|
||||
private static final class World implements PackWorld, IrisSeed.Source {
|
||||
private final class World implements PackWorld, IrisSeed.Source {
|
||||
private final Resources resources = new Resources();
|
||||
private final Map<Class<?>, Object> states = new HashMap<>();
|
||||
|
||||
@@ -398,7 +508,16 @@ public final class ApiChunk implements GenerationContext {
|
||||
|
||||
@Override
|
||||
public PackSettings settings() {
|
||||
throw new UnsupportedOperationException("No pack settings here");
|
||||
return new PackSettings() {
|
||||
@Override
|
||||
public <F extends IrisFeature> List<Entry<F>> declared(Class<F> featureType) {
|
||||
List<Entry<F>> entries = new ArrayList<>();
|
||||
addEntries(entries, featureType, Target.DIMENSION, DIMENSION, dimensionSettings);
|
||||
addEntries(entries, featureType, Target.REGION, REGION, regionSettings);
|
||||
addEntries(entries, featureType, Target.BIOME, BIOME, biomeSettings);
|
||||
return entries;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -473,7 +592,10 @@ public final class ApiChunk implements GenerationContext {
|
||||
private static final class Blocks implements BlockRegistry {
|
||||
@Override
|
||||
public BlockState resolve(String key) {
|
||||
return BlockState.parse(key);
|
||||
if (key.contains(UNKNOWN_BLOCK)) {
|
||||
throw new IllegalArgumentException("Unknown block: " + key);
|
||||
}
|
||||
return BlockState.parse(key.contains(":") ? key : "minecraft:" + key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -510,6 +632,7 @@ public final class ApiChunk implements GenerationContext {
|
||||
case FOLIAGE -> FOLIAGE.contains(material);
|
||||
case DECORATION -> DECORATIONS.contains(material);
|
||||
case VINE -> vine;
|
||||
case ORE -> material.endsWith("_ore");
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
@@ -535,6 +658,19 @@ public final class ApiChunk implements GenerationContext {
|
||||
}
|
||||
}
|
||||
|
||||
private static final class TerrainStandIn implements IrisModule {
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
return ModuleInfo.of("iris:terrain", "Terrain stand-in", "test");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void install(StageGraph graph) {
|
||||
graph.define(IrisStages.Terrain.SHAPE).run(context -> {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private static final class CarveStandIn implements IrisModule {
|
||||
@Override
|
||||
public ModuleInfo info() {
|
||||
|
||||
@@ -20,8 +20,10 @@ package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.deposit.DepositSettings;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import com.volmit.FeatureAttachment.Target;
|
||||
import com.volmit.IrisFeature;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.config.FeatureSettings;
|
||||
import com.volmit.resource.ResourceId;
|
||||
import org.junit.Test;
|
||||
@@ -29,6 +31,8 @@ import org.junit.Test;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DepositModuleTest {
|
||||
private static final int CENTRE = 7;
|
||||
@@ -58,4 +62,122 @@ public class DepositModuleTest {
|
||||
private static FeatureSettings.Entry<DepositSettings> entry(Target level, String source, DepositGenerator generator) {
|
||||
return new FeatureSettings.Entry<>(level, ResourceId.parse("pack:" + source), new DepositSettings(List.of(generator)));
|
||||
}
|
||||
|
||||
private static final int HEIGHT = 128;
|
||||
private static final int GROUND = 80;
|
||||
private static final BlockState STONE = new BlockState("minecraft:stone");
|
||||
|
||||
@Test
|
||||
public void aDimensionsDepositsReplaceStoneInsideTheirBandAndNothingElse() {
|
||||
ApiChunk chunk = groundedChunk()
|
||||
.dimensionSettings(depositsOf("{\"minHeight\": 10, \"maxHeight\": 40, \"minSize\": 6, \"maxSize\": 6, \"minPerChunk\": 4, \"maxPerChunk\": 4,"
|
||||
+ " \"varience\": 1, \"palette\": [{\"block\": \"iron_ore\"}], \"replaceableBlocks\": [\"stone\"]}"));
|
||||
chunk.set(8, 20, 8, new BlockState("minecraft:dirt"));
|
||||
|
||||
chunk.generate(new DepositModule());
|
||||
|
||||
int ores = countOf(chunk, new BlockState("minecraft:iron_ore"));
|
||||
assertTrue("some ore was placed: " + ores, ores > 0);
|
||||
assertEquals("the dirt is not stone", new BlockState("minecraft:dirt"), chunk.get(8, 20, 8));
|
||||
for (int x = 0; x < ApiChunk.WIDTH; x++) {
|
||||
for (int z = 0; z < ApiChunk.WIDTH; z++) {
|
||||
for (int y = 0; y < HEIGHT; y++) {
|
||||
if (chunk.get(x, y, z).equals(new BlockState("minecraft:iron_ore"))) {
|
||||
assertTrue("ore at " + y + " is below the ground and inside the band's reach", y <= GROUND - 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depositsAreTheSameWheneverTheSameChunkIsGenerated() {
|
||||
DepositSettings deposits = depositsOf("{\"minHeight\": 10, \"maxHeight\": 60, \"minSize\": 3, \"maxSize\": 9, \"minPerChunk\": 3, \"maxPerChunk\": 6,"
|
||||
+ " \"palette\": [{\"block\": \"coal_ore\"}, {\"block\": \"iron_ore\"}]}");
|
||||
ApiChunk first = groundedChunk().dimensionSettings(deposits);
|
||||
ApiChunk second = groundedChunk().dimensionSettings(deposits);
|
||||
|
||||
first.generate(new DepositModule());
|
||||
second.generate(new DepositModule());
|
||||
|
||||
for (int x = 0; x < ApiChunk.WIDTH; x++) {
|
||||
for (int y = 0; y < HEIGHT; y++) {
|
||||
for (int z = 0; z < ApiChunk.WIDTH; z++) {
|
||||
assertEquals(x + " " + y + " " + z, first.get(x, y, z), second.get(x, y, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
assertTrue(countOf(first, new BlockState("minecraft:coal_ore")) + countOf(first, new BlockState("minecraft:iron_ore")) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void depositsLeaveCarvedVoidsAlone() {
|
||||
DepositSettings deposits = depositsOf("{\"minHeight\": 10, \"maxHeight\": 60, \"minSize\": 40, \"maxSize\": 40, \"minPerChunk\": 6, \"maxPerChunk\": 6,"
|
||||
+ " \"palette\": [{\"block\": \"iron_ore\"}]}");
|
||||
ApiChunk free = groundedChunk().dimensionSettings(deposits);
|
||||
ApiChunk carved = groundedChunk().dimensionSettings(deposits);
|
||||
for (int x = 0; x < ApiChunk.WIDTH; x++) {
|
||||
for (int z = 0; z < ApiChunk.WIDTH; z++) {
|
||||
for (int y = 20; y < 40; y++) {
|
||||
carved.carve(32 + x, y, -16 + z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free.generate(new DepositModule());
|
||||
carved.generate(new DepositModule());
|
||||
|
||||
assertTrue(countBetween(free, 20, 40) > 0);
|
||||
assertEquals(0, countBetween(carved, 20, 40));
|
||||
assertTrue("above and below the voids the same deposits grow", countBetween(carved, 0, 20) + countBetween(carved, 40, HEIGHT) > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aChunkWithoutDepositsAtItsCentreIsLeftAlone() {
|
||||
ApiChunk chunk = groundedChunk();
|
||||
|
||||
chunk.generate(new DepositModule());
|
||||
|
||||
assertEquals(0, countOf(chunk, new BlockState("minecraft:iron_ore")));
|
||||
}
|
||||
|
||||
private static ApiChunk groundedChunk() {
|
||||
ApiChunk chunk = new ApiChunk(32, -16, HEIGHT).surface((x, z) -> GROUND);
|
||||
for (int x = 0; x < ApiChunk.WIDTH; x++) {
|
||||
for (int z = 0; z < ApiChunk.WIDTH; z++) {
|
||||
for (int y = 0; y <= GROUND; y++) {
|
||||
chunk.set(x, y, z, STONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
return chunk;
|
||||
}
|
||||
|
||||
private static DepositSettings depositsOf(String generatorJson) {
|
||||
return TestSettings.of(DepositSettings.class, "{\"generators\": [" + generatorJson + "]}");
|
||||
}
|
||||
|
||||
private static int countOf(ApiChunk chunk, BlockState block) {
|
||||
int count = 0;
|
||||
for (int x = 0; x < ApiChunk.WIDTH; x++) {
|
||||
for (int y = 0; y < HEIGHT; y++) {
|
||||
for (int z = 0; z < ApiChunk.WIDTH; z++) {
|
||||
count += chunk.get(x, y, z).equals(block) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
private static int countBetween(ApiChunk chunk, int from, int to) {
|
||||
int count = 0;
|
||||
for (int x = 0; x < ApiChunk.WIDTH; x++) {
|
||||
for (int y = from; y < to; y++) {
|
||||
for (int z = 0; z < ApiChunk.WIDTH; z++) {
|
||||
count += chunk.get(x, y, z).equals(new BlockState("minecraft:iron_ore")) ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
}
|
||||
+19
-28
@@ -20,16 +20,19 @@ package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.deposit.DepositHeightDistribution;
|
||||
import art.arcane.iris.builtin.deposit.DepositPlacementScope;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.util.project.hunk.Hunk;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.block.BlockTrait;
|
||||
import com.volmit.host.ArrayHunk;
|
||||
import com.volmit.hunk.Hunk;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class DepositPlacerContainmentTest {
|
||||
@Test
|
||||
@@ -63,16 +66,12 @@ public class DepositPlacerContainmentTest {
|
||||
|
||||
@Test
|
||||
public void airAndFluidTargetsAreRejected() {
|
||||
PlatformBlockState solid = mock(PlatformBlockState.class);
|
||||
PlatformBlockState air = mock(PlatformBlockState.class);
|
||||
PlatformBlockState fluid = mock(PlatformBlockState.class);
|
||||
when(air.isAir()).thenReturn(true);
|
||||
when(fluid.isFluid()).thenReturn(true);
|
||||
BlockRegistry blocks = ApiChunk.blocks();
|
||||
|
||||
assertTrue(DepositPlacer.canReplaceDepositTarget(solid));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(air));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(fluid));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(null));
|
||||
assertTrue(DepositPlacer.canReplaceDepositTarget(blocks, new BlockState("minecraft:stone")));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(blocks, ApiChunk.AIR));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(blocks, new BlockState("minecraft:water")));
|
||||
assertFalse(DepositPlacer.canReplaceDepositTarget(blocks, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -155,21 +154,13 @@ public class DepositPlacerContainmentTest {
|
||||
|
||||
@Test
|
||||
public void exposureProbeChecksOnlyInBoundsOrthogonalNeighbors() {
|
||||
Hunk<PlatformBlockState> data = Hunk.newHunk(3, 3, 3);
|
||||
PlatformBlockState solid = mock(PlatformBlockState.class);
|
||||
PlatformBlockState air = mock(PlatformBlockState.class);
|
||||
when(air.isAir()).thenReturn(true);
|
||||
for (int x = 0; x < 3; x++) {
|
||||
for (int y = 0; y < 3; y++) {
|
||||
for (int z = 0; z < 3; z++) {
|
||||
data.setRaw(x, y, z, solid);
|
||||
}
|
||||
}
|
||||
}
|
||||
BlockRegistry blocks = ApiChunk.blocks();
|
||||
Hunk<BlockState> data = new ArrayHunk<>(BlockState.class, 3, 3, 3, new BlockState("minecraft:stone"));
|
||||
Predicate<BlockState> isAir = state -> blocks.hasTrait(state, BlockTrait.AIR);
|
||||
|
||||
assertFalse(DepositPlacer.isAdjacentToAir(data, 1, 1, 1));
|
||||
data.setRaw(2, 1, 1, air);
|
||||
assertTrue(DepositPlacer.isAdjacentToAir(data, 1, 1, 1));
|
||||
assertFalse(DepositPlacer.isAdjacentToAir(data, 0, 0, 0));
|
||||
assertFalse(DepositPlacer.isAdjacentToAir(data, 1, 1, 1, isAir));
|
||||
data.set(2, 1, 1, ApiChunk.AIR);
|
||||
assertTrue(DepositPlacer.isAdjacentToAir(data, 1, 1, 1, isAir));
|
||||
assertFalse(DepositPlacer.isAdjacentToAir(data, 0, 0, 0, isAir));
|
||||
}
|
||||
}
|
||||
@@ -3,21 +3,12 @@ package art.arcane.iris.engine.modifier;
|
||||
import art.arcane.iris.builtin.deposit.DepositGenerator;
|
||||
import art.arcane.iris.builtin.deposit.OreFrequencySettings;
|
||||
import art.arcane.iris.builtin.deposit.OreSizeSettings;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.core.loader.ResourceLoader;
|
||||
import art.arcane.iris.core.modules.PackResourceFixture;
|
||||
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.SeedManager;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import art.arcane.iris.engine.modifier.ResolvedDeposit.BiomeIdentity;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import com.google.gson.Gson;
|
||||
import com.volmit.block.BlockRegistry;
|
||||
import com.volmit.config.Desc;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.List;
|
||||
@@ -27,40 +18,21 @@ import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
/** A deposit generator made ready for an engine: its clump shapes, ore tuning, replaceable blocks and biome filters. */
|
||||
public class ResolvedDepositTest {
|
||||
private static final long DEPOSIT_SEED = 41L;
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
private static final BlockRegistry BLOCKS = ApiChunk.blocks();
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void thePaletteResolvesThroughThePacksBlocks() throws Exception {
|
||||
UsableBlockPlatform.bind();
|
||||
try {
|
||||
IrisData data = mock(IrisData.class);
|
||||
when(data.getDataFolder()).thenReturn(folder.newFolder("pack"));
|
||||
when(data.getBlockLoader()).thenReturn(mock(ResourceLoader.class));
|
||||
PackResourceFixture.serve(data);
|
||||
Engine engine = mock(Engine.class);
|
||||
SeedManager seeds = mock(SeedManager.class);
|
||||
when(engine.getData()).thenReturn(data);
|
||||
when(engine.getSeedManager()).thenReturn(seeds);
|
||||
when(seeds.getDeposit()).thenReturn(DEPOSIT_SEED);
|
||||
public void thePaletteResolvesThroughThePacksBlocks() {
|
||||
ResolvedDeposit deposit = new ResolvedDeposit(generator("{\"minSize\": 1, \"maxSize\": 1, \"palette\": [{\"block\": \"iron_ore\"}]}"), DEPOSIT_SEED, BLOCKS);
|
||||
DepositClump clump = deposit.clump(new RNG(3));
|
||||
|
||||
ResolvedDeposit deposit = ResolvedDeposit.of(generator("{\"minSize\": 1, \"maxSize\": 1, \"palette\": [{\"block\": \"iron_ore\"}]}"), engine);
|
||||
IrisObject clump = deposit.clump(new RNG(3));
|
||||
|
||||
List<String> keys = new java.util.ArrayList<>();
|
||||
clump.getBlocks().values().forEachRemaining(block -> keys.add(block.key()));
|
||||
assertEquals(List.of("minecraft:iron_ore"), keys);
|
||||
} finally {
|
||||
UsableBlockPlatform.unbind();
|
||||
}
|
||||
List<String> keys = new java.util.ArrayList<>();
|
||||
clump.blocks().values().forEachRemaining(block -> keys.add(block.key()));
|
||||
assertEquals(List.of("minecraft:iron_ore"), keys);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -100,28 +72,27 @@ public class ResolvedDepositTest {
|
||||
@Test
|
||||
public void clumpShapesAreBuiltOncePerSizeFromTheWorldsDepositSeed() {
|
||||
DepositGenerator generator = generator("{\"minSize\": 4, \"maxSize\": 8, \"varience\": 1}");
|
||||
ResolvedDeposit firstWorld = new ResolvedDeposit(generator, DEPOSIT_SEED, List.of(state("minecraft:granite", false)));
|
||||
ResolvedDeposit secondWorld = new ResolvedDeposit(generator, DEPOSIT_SEED + 1, List.of(state("minecraft:granite", false)));
|
||||
ResolvedDeposit firstWorld = new ResolvedDeposit(withPalette(generator, "granite"), DEPOSIT_SEED, BLOCKS);
|
||||
ResolvedDeposit secondWorld = new ResolvedDeposit(withPalette(generator, "granite"), DEPOSIT_SEED + 1, BLOCKS);
|
||||
|
||||
assertTrue("one variant: every pick is the same shape", firstWorld.clump(new RNG(1)) == firstWorld.clump(new RNG(2)));
|
||||
assertNotEquals(firstWorld.clump(new RNG(1)).getBlocks().keys().toString(), secondWorld.clump(new RNG(1)).getBlocks().keys().toString());
|
||||
assertNotEquals(firstWorld.clump(new RNG(1)).blocks().keys().toString(), secondWorld.clump(new RNG(1)).blocks().keys().toString());
|
||||
assertTrue("scaled sizes are their own shapes", firstWorld.clump(new RNG(1)) != firstWorld.clump(new RNG(1), 2D));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clumpSaltIsStableAcrossEquivalentConfigInstances() {
|
||||
ResolvedDeposit first = new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:granite", false)));
|
||||
ResolvedDeposit second = new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:granite", false)));
|
||||
ResolvedDeposit first = new ResolvedDeposit(withPalette(new DepositGenerator(), "granite"), DEPOSIT_SEED, BLOCKS);
|
||||
ResolvedDeposit second = new ResolvedDeposit(withPalette(new DepositGenerator(), "granite"), DEPOSIT_SEED, BLOCKS);
|
||||
|
||||
assertEquals(first.stableClumpSalt(), second.stableClumpSalt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clumpSaltIncludesAuthoredConfigAndPalette() {
|
||||
ResolvedDeposit granite = new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:granite", false)));
|
||||
ResolvedDeposit andesite = new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:andesite", false)));
|
||||
ResolvedDeposit alteredShape = new ResolvedDeposit(generator("{\"shape\": \"VANILLA_SCATTERED\"}"), DEPOSIT_SEED,
|
||||
List.of(state("minecraft:granite", false)));
|
||||
ResolvedDeposit granite = new ResolvedDeposit(withPalette(new DepositGenerator(), "granite"), DEPOSIT_SEED, BLOCKS);
|
||||
ResolvedDeposit andesite = new ResolvedDeposit(withPalette(new DepositGenerator(), "andesite"), DEPOSIT_SEED, BLOCKS);
|
||||
ResolvedDeposit alteredShape = new ResolvedDeposit(withPalette(generator("{\"shape\": \"VANILLA_SCATTERED\"}"), "granite"), DEPOSIT_SEED, BLOCKS);
|
||||
|
||||
assertEquals("the salt Iris deposits always had", 3112546198474861350L, granite.stableClumpSalt());
|
||||
assertNotEquals(granite.stableClumpSalt(), andesite.stableClumpSalt());
|
||||
@@ -130,21 +101,21 @@ public class ResolvedDepositTest {
|
||||
|
||||
@Test
|
||||
public void onlyOreDepositPalettesReceiveBiomeTuning() {
|
||||
assertTrue(new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:iron_ore", true))).isOre());
|
||||
assertFalse(new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:stone", false))).isOre());
|
||||
assertTrue(new ResolvedDeposit(withPalette(new DepositGenerator(), "iron_ore"), DEPOSIT_SEED, BLOCKS).isOre());
|
||||
assertFalse(new ResolvedDeposit(withPalette(new DepositGenerator(), "stone"), DEPOSIT_SEED, BLOCKS).isOre());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void vanillaEllipsoidSizeControlsGeometryRatherThanExactBlockCount() {
|
||||
ResolvedDeposit deposit = new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:iron_ore", true)));
|
||||
ResolvedDeposit deposit = new ResolvedDeposit(withPalette(new DepositGenerator(), "iron_ore"), DEPOSIT_SEED, BLOCKS);
|
||||
long smallBlocks = 0L;
|
||||
long mediumBlocks = 0L;
|
||||
long largeBlocks = 0L;
|
||||
int samples = 500;
|
||||
for (int i = 0; i < samples; i++) {
|
||||
smallBlocks += deposit.vanillaEllipsoid(new RNG(i), 4).getBlocks().size();
|
||||
mediumBlocks += deposit.vanillaEllipsoid(new RNG(i), 8).getBlocks().size();
|
||||
largeBlocks += deposit.vanillaEllipsoid(new RNG(i), 17).getBlocks().size();
|
||||
smallBlocks += deposit.vanillaEllipsoid(new RNG(i), 4).blocks().size();
|
||||
mediumBlocks += deposit.vanillaEllipsoid(new RNG(i), 8).blocks().size();
|
||||
largeBlocks += deposit.vanillaEllipsoid(new RNG(i), 17).blocks().size();
|
||||
}
|
||||
|
||||
assertTrue(smallBlocks > 0L);
|
||||
@@ -155,12 +126,12 @@ public class ResolvedDepositTest {
|
||||
|
||||
@Test
|
||||
public void vanillaScatteredSizeIsAnUpperCandidateBound() {
|
||||
ResolvedDeposit deposit = new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, List.of(state("minecraft:iron_ore", true)));
|
||||
ResolvedDeposit deposit = new ResolvedDeposit(withPalette(new DepositGenerator(), "iron_ore"), DEPOSIT_SEED, BLOCKS);
|
||||
boolean foundEmpty = false;
|
||||
boolean foundNonEmpty = false;
|
||||
RNG rng = new RNG(991L);
|
||||
for (int i = 0; i < 200; i++) {
|
||||
int blocks = deposit.vanillaScattered(rng, 3).getBlocks().size();
|
||||
int blocks = deposit.vanillaScattered(rng, 3).blocks().size();
|
||||
assertTrue(blocks <= 3);
|
||||
foundEmpty |= blocks == 0;
|
||||
foundNonEmpty |= blocks > 0;
|
||||
@@ -172,35 +143,59 @@ public class ResolvedDepositTest {
|
||||
|
||||
@Test
|
||||
public void biomeFiltersAcceptResourceKeysAndVanillaDerivatives() {
|
||||
IrisBiome mountain = new IrisBiome();
|
||||
mountain.setLoadKey("custom/mountain");
|
||||
mountain.setDerivative("minecraft:stony_peaks");
|
||||
IrisBiome plains = new IrisBiome();
|
||||
plains.setLoadKey("custom/plains");
|
||||
plains.setDerivative("minecraft:plains");
|
||||
BiomeIdentity mountain = new BiomeIdentity("custom/mountain", "minecraft:stony_peaks", "minecraft:stony_peaks");
|
||||
BiomeIdentity plains = new BiomeIdentity("custom/plains", "minecraft:plains", "minecraft:plains");
|
||||
|
||||
DepositGenerator included = generator("{\"biomeScope\": \"SURFACE\", \"includedBiomes\": [\"minecraft:stony_peaks\"]}");
|
||||
ResolvedDeposit surface = new ResolvedDeposit(included, DEPOSIT_SEED, List.of());
|
||||
assertTrue(surface.matchesBiome(mountain, plains));
|
||||
assertFalse(surface.matchesBiome(plains, mountain));
|
||||
ResolvedDeposit surface = new ResolvedDeposit(included, DEPOSIT_SEED, BLOCKS);
|
||||
assertTrue(surface.matchesBiome(() -> mountain, () -> plains));
|
||||
assertFalse(surface.matchesBiome(() -> plains, () -> mountain));
|
||||
assertFalse(included.usesCaveBiomeFilter());
|
||||
|
||||
DepositGenerator excluded = generator("{\"biomeScope\": \"SURFACE\", \"excludedBiomes\": [\"custom/mountain\"]}");
|
||||
ResolvedDeposit excluding = new ResolvedDeposit(excluded, DEPOSIT_SEED, List.of());
|
||||
assertFalse(excluding.matchesBiome(mountain, plains));
|
||||
assertTrue(excluding.matchesBiome(plains, mountain));
|
||||
ResolvedDeposit excluding = new ResolvedDeposit(excluded, DEPOSIT_SEED, BLOCKS);
|
||||
assertFalse(excluding.matchesBiome(() -> mountain, () -> plains));
|
||||
assertTrue(excluding.matchesBiome(() -> plains, () -> mountain));
|
||||
|
||||
assertTrue(generator("{\"excludedBiomes\": [\"custom/mountain\"]}").usesCaveBiomeFilter());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aBiomeThatIsNoneMatchesNoKey() {
|
||||
ResolvedDeposit including = new ResolvedDeposit(generator("{\"biomeScope\": \"CAVE\", \"includedBiomes\": [\"carving/drip\"]}"), DEPOSIT_SEED, BLOCKS);
|
||||
ResolvedDeposit excluding = new ResolvedDeposit(generator("{\"biomeScope\": \"CAVE\", \"excludedBiomes\": [\"carving/drip\"]}"), DEPOSIT_SEED, BLOCKS);
|
||||
|
||||
assertFalse(including.matchesBiome(() -> null, () -> null));
|
||||
assertTrue(excluding.matchesBiome(() -> null, () -> null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void noFilterAsksNoBiome() {
|
||||
ResolvedDeposit unfiltered = new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, BLOCKS);
|
||||
|
||||
assertTrue(unfiltered.matchesBiome(() -> {
|
||||
throw new AssertionError("The surface biome is asked for only when a filter reads it");
|
||||
}, () -> {
|
||||
throw new AssertionError("The cave biome is asked for only when a filter reads it");
|
||||
}));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onlyTheBlocksTheServerKnowsAreReplaceable() {
|
||||
ResolvedDeposit deposit = new ResolvedDeposit(generator("{\"replaceableBlocks\": [\"stone\", \"" + ApiChunk.UNKNOWN_BLOCK + "\"]}"), DEPOSIT_SEED, BLOCKS);
|
||||
|
||||
assertTrue(deposit.canReplace(new com.volmit.block.BlockState("minecraft:stone")));
|
||||
assertFalse(deposit.canReplace(new com.volmit.block.BlockState("minecraft:dirt")));
|
||||
assertTrue("a deposit that names no blocks replaces any", new ResolvedDeposit(new DepositGenerator(), DEPOSIT_SEED, BLOCKS)
|
||||
.canReplace(new com.volmit.block.BlockState("minecraft:dirt")));
|
||||
}
|
||||
|
||||
private static DepositGenerator generator(String json) {
|
||||
return new Gson().fromJson(json, DepositGenerator.class);
|
||||
}
|
||||
|
||||
private static PlatformBlockState state(String key, boolean ore) {
|
||||
PlatformBlockState state = mock(PlatformBlockState.class);
|
||||
when(state.isOre()).thenReturn(ore);
|
||||
when(state.key()).thenReturn(key);
|
||||
return state;
|
||||
/** {@code generator} with a palette of {@code block}, as its JSON would have it. */
|
||||
private static DepositGenerator withPalette(DepositGenerator generator, String block) {
|
||||
return art.arcane.iris.engine.object.TestSettings.with(generator, "palette", List.of(com.volmit.block.BlockSpec.of(block)));
|
||||
}
|
||||
}
|
||||
+21
-30
@@ -1,42 +1,30 @@
|
||||
package art.arcane.iris.engine.modifier;
|
||||
|
||||
import art.arcane.iris.builtin.deposit.DepositVariant;
|
||||
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||
import art.arcane.iris.spi.IrisPlatforms;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
import com.google.gson.Gson;
|
||||
import org.junit.After;
|
||||
import com.volmit.ModuleLog;
|
||||
import com.volmit.block.BlockState;
|
||||
import com.volmit.host.ModuleLogs;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||
import static org.mockito.ArgumentMatchers.anyString;
|
||||
import static org.mockito.Mockito.when;
|
||||
|
||||
public class ResolvedDepositVariantTest {
|
||||
private static final String DEEP_IRON = """
|
||||
{"minHeight": -64, "maxHeight": 0, "remap": {"minecraft:iron_ore": "minecraft:deepslate_iron_ore", "unknown_block": "minecraft:stone"}}
|
||||
""";
|
||||
private static final ModuleLog LOG = ModuleLogs.discarding();
|
||||
|
||||
private static void knowEveryBlockButTheUnknownOne() {
|
||||
UsableBlockPlatform.bind();
|
||||
when(IrisPlatforms.get().registries().blockOrNull(anyString(), anyBoolean())).thenAnswer(call -> {
|
||||
String name = call.getArgument(0);
|
||||
return name.equals("unknown_block") ? null : UsableBlockPlatform.block(name);
|
||||
});
|
||||
}
|
||||
|
||||
@After
|
||||
public void unbindPlatform() {
|
||||
UsableBlockPlatform.unbind();
|
||||
private static ResolvedDepositVariant variant(String json) {
|
||||
return new ResolvedDepositVariant(new Gson().fromJson(json, DepositVariant.class), ApiChunk.blocks(), LOG);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aVariantAppliesWithinItsInclusiveBand() {
|
||||
ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson(DEEP_IRON, DepositVariant.class));
|
||||
ResolvedDepositVariant variant = variant(DEEP_IRON);
|
||||
|
||||
assertTrue(variant.appliesAt(-64));
|
||||
assertTrue(variant.appliesAt(0));
|
||||
@@ -46,30 +34,33 @@ public class ResolvedDepositVariantTest {
|
||||
|
||||
@Test
|
||||
public void anOreIsRemappedByItsMaterialAndOtherBlocksAreNot() {
|
||||
knowEveryBlockButTheUnknownOne();
|
||||
ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson(DEEP_IRON, DepositVariant.class));
|
||||
PlatformBlockState iron = UsableBlockPlatform.block("iron_ore");
|
||||
ResolvedDepositVariant variant = variant(DEEP_IRON);
|
||||
|
||||
PlatformBlockState remapped = variant.remapOrNull(iron);
|
||||
BlockState remapped = variant.remapOrNull(new BlockState("minecraft:iron_ore"));
|
||||
|
||||
assertEquals("minecraft:deepslate_iron_ore", remapped.key());
|
||||
assertNull(variant.remapOrNull(UsableBlockPlatform.block("coal_ore")));
|
||||
assertNull(variant.remapOrNull(new BlockState("minecraft:coal_ore")));
|
||||
assertNull(variant.remapOrNull(null));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRuleWhoseSourceTheServerDoesNotKnowRemapsNothing() {
|
||||
knowEveryBlockButTheUnknownOne();
|
||||
DepositVariant unknown = new Gson().fromJson("{\"remap\": {\"unknown_block\": \"minecraft:stone\"}}", DepositVariant.class);
|
||||
ResolvedDepositVariant unknown = variant("{\"remap\": {\"unknown_block\": \"minecraft:stone\"}}");
|
||||
|
||||
assertNull(new ResolvedDepositVariant(unknown).remapOrNull(UsableBlockPlatform.block("unknown_block")));
|
||||
assertNull(unknown.remapOrNull(new BlockState("minecraft:unknown_block")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aRuleWhoseReplacementTheServerDoesNotKnowRemapsNothing() {
|
||||
ResolvedDepositVariant unknown = variant("{\"remap\": {\"minecraft:iron_ore\": \"unknown_block\"}}");
|
||||
|
||||
assertNull(unknown.remapOrNull(new BlockState("minecraft:iron_ore")));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aVariantWithoutRemapsChangesNothing() {
|
||||
UsableBlockPlatform.bind();
|
||||
ResolvedDepositVariant variant = new ResolvedDepositVariant(new Gson().fromJson("{\"maxHeight\": 5}", DepositVariant.class));
|
||||
ResolvedDepositVariant variant = variant("{\"maxHeight\": 5}");
|
||||
|
||||
assertNull(variant.remapOrNull(UsableBlockPlatform.block("iron_ore")));
|
||||
assertNull(variant.remapOrNull(new BlockState("minecraft:iron_ore")));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user