mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-27 00:04:42 +00:00
Procedural settings tests on the overworld pack's JSON
This commit is contained in:
1 parent
42ba2dcfaf
commit
5ec3fb78d3
4 files changed
+269
-74
No files matched your search
+6
-6
@@ -1,5 +1,8 @@
|
||||
package art.arcane.iris.engine.object.placement;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.formation.ResolvedFormation;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.placement.IObjectPlacer;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.placement.IrisSurfaceSupport;
|
||||
@@ -7,7 +10,6 @@ import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectRotation;
|
||||
import art.arcane.iris.engine.object.prefab.IrisObjectTranslate;
|
||||
import art.arcane.iris.engine.object.prefab.TileData;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.spi.PlatformBlockState;
|
||||
@@ -164,13 +166,11 @@ public class IrisSurfaceSupportTest {
|
||||
|
||||
@Test
|
||||
public void formationDefaultsToWiderBufferThanObjectDefault() {
|
||||
IrisFormation formation = new IrisFormation();
|
||||
|
||||
assertEquals(2, new IrisObjectPlacement().getSurfaceSupportBuffer());
|
||||
assertEquals(3, formation.asPlacement().getSurfaceSupportBuffer());
|
||||
assertEquals(3, new ResolvedFormation(new Formation()).asPlacement().getSurfaceSupportBuffer());
|
||||
|
||||
formation.setSurfaceSupportBuffer(0);
|
||||
assertEquals(0, formation.asPlacement().getSurfaceSupportBuffer());
|
||||
Formation flush = TestSettings.with(new Formation(), "surfaceSupportBuffer", 0);
|
||||
assertEquals(0, new ResolvedFormation(flush).asPlacement().getSurfaceSupportBuffer());
|
||||
}
|
||||
|
||||
private static boolean isUnsupported(IObjectPlacer placer, List<IrisBlockVector> footprint,
|
||||
|
||||
+193
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Servers
|
||||
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package art.arcane.iris.engine.object.procedural;
|
||||
|
||||
import art.arcane.iris.builtin.anchor.ObjectPlaceMode;
|
||||
import art.arcane.iris.builtin.carve.CarvingMode;
|
||||
import art.arcane.iris.builtin.objects.coral.Coral;
|
||||
import art.arcane.iris.builtin.objects.coral.CoralForm;
|
||||
import art.arcane.iris.builtin.objects.crystal.Crystal;
|
||||
import art.arcane.iris.builtin.objects.crystal.CrystalDistribution;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.builtin.objects.formation.FormationForm;
|
||||
import art.arcane.iris.builtin.objects.fungi.Fungus;
|
||||
import art.arcane.iris.builtin.objects.ruin.Ruin;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLeafMode;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertSame;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.mockito.Mockito.CALLS_REAL_METHODS;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
|
||||
/**
|
||||
* The procedural objects the overworld pack's biomes write ({@code snippet/procedural-objects/frozen/...}) read into the module settings
|
||||
* classes (IrisApi types only) with the values Iris's own classes read from the same JSON, and made placeable.
|
||||
*/
|
||||
public class ProceduralSettingsDecodingTest {
|
||||
private static final String ICEBERG = """
|
||||
{"name": "glacial-iceberg", "chance": 0.08, "density": 1, "variants": 24, "seed": 5055001, "mode": "CENTER_HEIGHT",
|
||||
"carvingSupport": "SURFACE_ONLY", "surfaceSupportBuffer": 1, "block": "minecraft:packed_ice",
|
||||
"blockPalette": "snippet/palette/frozen/magical-ice", "capBlock": "minecraft:blue_ice",
|
||||
"rotation": {"enabled": true, "yAxis": {"enabled": true, "min": 0, "max": 360, "interval": 45}},
|
||||
"form": "ICEBERG", "translate": {"y": -4}, "heightMin": 12, "heightMax": 22, "baseWidthMin": 5, "baseWidthMax": 8,
|
||||
"icebergPeaks": 4, "roughness": 0.42, "jitter": 0.14}
|
||||
""";
|
||||
private static final String FROST_BLOOM = """
|
||||
{"mode": "CENTER_HEIGHT", "carvingSupport": "SURFACE_ONLY",
|
||||
"rotation": {"enabled": true, "yAxis": {"enabled": true, "min": 0, "max": 360, "interval": 45}},
|
||||
"growthSurface": "FLOOR", "block": "minecraft:packed_ice", "blockPalette": "snippet/palette/frozen/magical-ice",
|
||||
"tipBlock": "minecraft:blue_ice", "baseBlock": "minecraft:blue_ice", "tipChance": 0.65, "name": "glacial-frost-bloom",
|
||||
"chance": 0.28, "density": 2, "variants": 24, "seed": 5055031, "translate": {"y": -1}, "baseRadius": 1.8, "baseNoise": 0.4,
|
||||
"shardCountMin": 3, "shardCountMax": 6, "shardLengthMin": 2, "shardLengthMax": 5, "shardBaseRadius": 1.1,
|
||||
"shardTaper": 1.0, "spreadAngle": 68, "distribution": "GOLDEN_ANGLE", "jitter": 0.35}
|
||||
""";
|
||||
private static final String BIOME = """
|
||||
{"name": "Glacial", "proceduralObjects": "snippet/procedural-objects/frozen/magical-ice-spikes-biome"}
|
||||
""";
|
||||
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
private Gson gson;
|
||||
|
||||
@Before
|
||||
public void decodeLikeIrisDoes() throws IOException {
|
||||
File palettes = folder.newFolder("snippet", "palette", "frozen");
|
||||
Files.writeString(new File(palettes, "magical-ice.json").toPath(),
|
||||
"{\"style\": {\"style\": \"SIMPLEX\", \"zoom\": 0.4}, \"palette\": [{\"block\": \"minecraft:packed_ice\"}, {\"block\": \"minecraft:blue_ice\", \"weight\": 2}]}");
|
||||
File objects = folder.newFolder("snippet", "procedural-objects", "frozen");
|
||||
Files.writeString(new File(objects, "magical-ice-spikes-biome.json").toPath(),
|
||||
"{\"formations\": [" + ICEBERG + "], \"crystals\": [" + FROST_BLOOM + "]}");
|
||||
IrisData data = mock(IrisData.class, CALLS_REAL_METHODS);
|
||||
doReturn(folder.getRoot()).when(data).getDataFolder();
|
||||
gson = new GsonBuilder().registerTypeAdapterFactory(data).create();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aFormationReadsEveryFieldIrisReadFromIt() {
|
||||
Formation iceberg = gson.fromJson(ICEBERG, Formation.class);
|
||||
|
||||
assertEquals("glacial-iceberg", iceberg.name());
|
||||
assertEquals(0.08, iceberg.chance(), 0);
|
||||
assertEquals(24, iceberg.variants());
|
||||
assertEquals(5055001L, iceberg.seed());
|
||||
assertEquals(ObjectPlaceMode.CENTER_HEIGHT, iceberg.mode());
|
||||
assertEquals(CarvingMode.SURFACE_ONLY, iceberg.carvingSupport());
|
||||
assertEquals(1, iceberg.surfaceSupportBuffer());
|
||||
assertEquals("minecraft:packed_ice", iceberg.block());
|
||||
assertEquals("minecraft:blue_ice", iceberg.capBlock().orElseThrow());
|
||||
assertEquals(FormationForm.ICEBERG, iceberg.form());
|
||||
assertEquals(-4, iceberg.translate().y());
|
||||
assertTrue(iceberg.rotation().yAxis().enabled());
|
||||
assertEquals(45, iceberg.rotation().yAxis().interval(), 0);
|
||||
assertEquals(360, iceberg.rotation().yAxis().max(), 0);
|
||||
assertEquals(4, iceberg.icebergPeaks());
|
||||
assertEquals(0.42, iceberg.roughness(), 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void palettesMayBeSnippetsAndReadAsPaletteSpecs() {
|
||||
Formation iceberg = gson.fromJson(ICEBERG, Formation.class);
|
||||
|
||||
var palette = iceberg.blockPalette().orElseThrow();
|
||||
assertEquals("SIMPLEX", palette.style().style());
|
||||
assertEquals(0.4, palette.style().zoom(), 0);
|
||||
assertEquals(2, palette.palette().size());
|
||||
assertEquals(2, palette.palette().get(1).weight());
|
||||
assertTrue(gson.fromJson("{}", Formation.class).blockPalette().isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aCrystalReadsItsFieldsAndEnums() {
|
||||
Crystal bloom = gson.fromJson(FROST_BLOOM, Crystal.class);
|
||||
|
||||
assertEquals("glacial-frost-bloom", bloom.name());
|
||||
assertEquals(CrystalDistribution.GOLDEN_ANGLE, bloom.distribution());
|
||||
assertEquals(1.8, bloom.baseRadius(), 0);
|
||||
assertEquals(6, bloom.shardCountMax());
|
||||
assertEquals("minecraft:blue_ice", bloom.baseBlock());
|
||||
assertEquals(-1, bloom.translate().y());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void aBiomeHoldsItsProceduralObjectsFromASnippet() {
|
||||
IrisBiome biome = gson.fromJson(BIOME, IrisBiome.class);
|
||||
|
||||
IrisProceduralObjects objects = biome.getProceduralObjects();
|
||||
assertEquals(1, objects.getFormations().size());
|
||||
assertEquals(1, objects.getCrystals().size());
|
||||
assertEquals("glacial-iceberg", objects.getFormations().get(0).name());
|
||||
assertFalse(objects.isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void everyKindPlacesWithItsSettingsAndMakesTheSamePlacementEachTime() {
|
||||
IrisProceduralObjects objects = gson.fromJson("{\"coral\": [{}], \"fungi\": [{}], \"ruins\": [{}], "
|
||||
+ "\"formations\": [" + ICEBERG + "], \"crystals\": [" + FROST_BLOOM + "]}", IrisProceduralObjects.class);
|
||||
|
||||
List<IrisProceduralPlacement> placements = objects.getAllPlacements();
|
||||
assertEquals(5, placements.size());
|
||||
assertSame("one placeable per settings, kept", placements.get(0), objects.getAllPlacements().get(0));
|
||||
|
||||
IrisProceduralPlacement iceberg = placements.get(1);
|
||||
assertEquals("glacial-iceberg", iceberg.getName());
|
||||
assertEquals(0.08, iceberg.getChance(), 0);
|
||||
IrisObjectPlacement placement = iceberg.asPlacement();
|
||||
assertEquals(ObjectPlaceMode.CENTER_HEIGHT, placement.getMode());
|
||||
assertEquals(1, placement.getSurfaceSupportBuffer());
|
||||
assertEquals(-4, placement.getTranslate().getY());
|
||||
assertEquals(45, placement.getRotation().getYAxis().interval(), 0);
|
||||
assertTrue(placement.getRotation().isEnabled());
|
||||
assertFalse(iceberg.isPlausible());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void emptyKindsHaveIrisDefaults() {
|
||||
Coral coral = gson.fromJson("{}", Coral.class);
|
||||
assertEquals("coral", coral.name());
|
||||
assertEquals(0.4, coral.chance(), 0);
|
||||
assertEquals(CoralForm.BRANCHING, coral.form());
|
||||
assertEquals("minecraft:tube_coral_block", coral.block());
|
||||
assertTrue(coral.underwater());
|
||||
assertTrue(coral.tipBlock().isEmpty());
|
||||
assertTrue(coral.stiltSettings().isEmpty());
|
||||
|
||||
assertEquals(ObjectPlaceMode.MIN_HEIGHT, gson.fromJson("{}", Ruin.class).mode());
|
||||
assertEquals("fungus", gson.fromJson("{}", Fungus.class).name());
|
||||
assertEquals(3, gson.fromJson("{}", Formation.class).surfaceSupportBuffer());
|
||||
assertEquals(TreeLeafMode.TRIMMED, TreeLeafMode.valueOf("TRIMMED"));
|
||||
}
|
||||
}
|
||||
+40
-39
@@ -1,8 +1,9 @@
|
||||
package art.arcane.iris.engine.object.procedural.formation;
|
||||
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.objects.formation.Formation;
|
||||
import art.arcane.iris.engine.object.procedural.formation.FormationCanvas;
|
||||
import art.arcane.iris.engine.object.procedural.formation.FormationShapeBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.formation.IrisFormation;
|
||||
import art.arcane.iris.util.common.math.Vector3i;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import org.junit.Test;
|
||||
@@ -65,18 +66,18 @@ public class FormationShapeBuilderTest {
|
||||
|
||||
@Test
|
||||
public void thinLeaningSpireRetainsAConnectedPointedTip() {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setRoughness(0.12);
|
||||
formation.setJitter(0.02);
|
||||
formation.setTopWidth(0);
|
||||
formation.setLean(10);
|
||||
formation.setLeanAzimuth(18);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "roughness", 0.12);
|
||||
TestSettings.with(formation, "jitter", 0.02);
|
||||
TestSettings.with(formation, "topWidth", 0);
|
||||
TestSettings.with(formation, "lean", 10);
|
||||
TestSettings.with(formation, "leanAzimuth", 18);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
int height = 48;
|
||||
FormationShapeBuilder.spire(canvas, formation, height, 1.0, new RNG(137L));
|
||||
double shear = Math.tan(Math.toRadians(formation.getLean())) * (height - 1);
|
||||
int tipX = (int) Math.round(Math.cos(Math.toRadians(formation.getLeanAzimuth())) * shear);
|
||||
int tipZ = (int) Math.round(Math.sin(Math.toRadians(formation.getLeanAzimuth())) * shear);
|
||||
double shear = Math.tan(Math.toRadians(formation.lean())) * (height - 1);
|
||||
int tipX = (int) Math.round(Math.cos(Math.toRadians(formation.leanAzimuth())) * shear);
|
||||
int tipZ = (int) Math.round(Math.sin(Math.toRadians(formation.leanAzimuth())) * shear);
|
||||
|
||||
assertEquals(FormationCanvas.Role.CAP, canvas.getCells().get(new Vector3i(tipX, height - 1, tipZ)));
|
||||
assertEquals(height - 1, maxY(canvas));
|
||||
@@ -86,10 +87,10 @@ public class FormationShapeBuilderTest {
|
||||
|
||||
@Test
|
||||
public void archRetainsGroundedLegsAndAnOpenCenter() {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setArchSpan(10);
|
||||
formation.setArchThickness(2);
|
||||
formation.setArchAsymmetry(0.8);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "archSpan", 10);
|
||||
TestSettings.with(formation, "archThickness", 2);
|
||||
TestSettings.with(formation, "archAsymmetry", 0.8);
|
||||
FormationCanvas canvas = arch(formation, 149L);
|
||||
FormationCanvas repeated = arch(formation, 149L);
|
||||
FormationCanvas different = arch(formation, 151L);
|
||||
@@ -107,17 +108,17 @@ public class FormationShapeBuilderTest {
|
||||
|
||||
@Test
|
||||
public void zeroAsymmetryKeepsArchMirroredAndThicknessScales() {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setRoughness(0.0);
|
||||
formation.setJitter(0.0);
|
||||
formation.setArchSpan(10);
|
||||
formation.setArchAsymmetry(0.0);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "roughness", 0.0);
|
||||
TestSettings.with(formation, "jitter", 0.0);
|
||||
TestSettings.with(formation, "archSpan", 10);
|
||||
TestSettings.with(formation, "archAsymmetry", 0.0);
|
||||
|
||||
formation.setArchThickness(1);
|
||||
TestSettings.with(formation, "archThickness", 1);
|
||||
FormationCanvas thin = arch(formation, 173L);
|
||||
formation.setArchThickness(2);
|
||||
TestSettings.with(formation, "archThickness", 2);
|
||||
FormationCanvas medium = arch(formation, 173L);
|
||||
formation.setArchThickness(3);
|
||||
TestSettings.with(formation, "archThickness", 3);
|
||||
FormationCanvas thick = arch(formation, 173L);
|
||||
|
||||
assertEquals(0, unmirroredCells(medium));
|
||||
@@ -135,51 +136,51 @@ public class FormationShapeBuilderTest {
|
||||
}
|
||||
|
||||
private FormationCanvas iceberg(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setIcebergPeaks(4);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "icebergPeaks", 4);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.iceberg(canvas, formation, 20, 5.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas fissure(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setFractureCount(3);
|
||||
formation.setFractureSeparation(4);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "fractureCount", 3);
|
||||
TestSettings.with(formation, "fractureSeparation", 4);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.fissure(canvas, formation, 18, 4.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas spiral(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setSpiralTurns(1.75);
|
||||
formation.setSpiralRadius(6);
|
||||
formation.setSpiralThickness(1);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "spiralTurns", 1.75);
|
||||
TestSettings.with(formation, "spiralRadius", 6);
|
||||
TestSettings.with(formation, "spiralThickness", 1);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.spiral(canvas, formation, 20, 4.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas overhang(long seed) {
|
||||
IrisFormation formation = baseFormation();
|
||||
formation.setOverhangReach(14);
|
||||
formation.setOverhangDrop(4);
|
||||
Formation formation = baseFormation();
|
||||
TestSettings.with(formation, "overhangReach", 14);
|
||||
TestSettings.with(formation, "overhangDrop", 4);
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.overhang(canvas, formation, 20, 3.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private FormationCanvas arch(IrisFormation formation, long seed) {
|
||||
private FormationCanvas arch(Formation formation, long seed) {
|
||||
FormationCanvas canvas = new FormationCanvas();
|
||||
FormationShapeBuilder.arch(canvas, formation, 18, 4.0, new RNG(seed));
|
||||
return canvas;
|
||||
}
|
||||
|
||||
private IrisFormation baseFormation() {
|
||||
IrisFormation formation = new IrisFormation();
|
||||
formation.setRoughness(0.2);
|
||||
formation.setJitter(0.05);
|
||||
private Formation baseFormation() {
|
||||
Formation formation = new Formation();
|
||||
TestSettings.with(formation, "roughness", 0.2);
|
||||
TestSettings.with(formation, "jitter", 0.05);
|
||||
return formation;
|
||||
}
|
||||
|
||||
|
||||
+30
-29
@@ -1,12 +1,13 @@
|
||||
package art.arcane.iris.engine.object.procedural.tree;
|
||||
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranchProbability;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeBranches;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeFunction;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeLeafMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeProfile;
|
||||
import art.arcane.iris.engine.object.procedural.tree.IrisTreeSubBranches;
|
||||
import art.arcane.iris.engine.object.TestSettings;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeSubBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranches;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeProfile;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeLeafMode;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeFunction;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeBranchProbability;
|
||||
import art.arcane.iris.builtin.objects.tree.TreeAzimuthMode;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeBlockCanvas;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreeCanopyBuilder;
|
||||
import art.arcane.iris.engine.object.procedural.tree.TreePlausibility;
|
||||
@@ -81,7 +82,7 @@ public class ProceduralTreeGeneratorTest {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:oak_log");
|
||||
tree.setLeaves("minecraft:oak_leaves");
|
||||
tree.setProfile(IrisTreeProfile.OAK);
|
||||
tree.setProfile(TreeProfile.OAK);
|
||||
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 9;
|
||||
@@ -99,19 +100,19 @@ public class ProceduralTreeGeneratorTest {
|
||||
|
||||
@Test
|
||||
public void hollowCanopyHasFewerLeavesThanFilled() {
|
||||
TreeBlockCanvas filled = canopyOnly(IrisTreeLeafMode.FILLED);
|
||||
TreeBlockCanvas hollow = canopyOnly(IrisTreeLeafMode.HOLLOW);
|
||||
TreeBlockCanvas filled = canopyOnly(TreeLeafMode.FILLED);
|
||||
TreeBlockCanvas hollow = canopyOnly(TreeLeafMode.HOLLOW);
|
||||
assertTrue("hollow canopy should place fewer leaves than filled",
|
||||
hollow.getLeaf().size() < filled.getLeaf().size());
|
||||
assertFalse("hollow canopy still places a leaf shell", hollow.getLeaf().isEmpty());
|
||||
}
|
||||
|
||||
private TreeBlockCanvas canopyOnly(IrisTreeLeafMode mode) {
|
||||
private TreeBlockCanvas canopyOnly(TreeLeafMode mode) {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:oak_log");
|
||||
tree.setLeaves("minecraft:oak_leaves");
|
||||
tree.setProfile(IrisTreeProfile.OAK);
|
||||
tree.getCanopy().setMode(mode);
|
||||
tree.setProfile(TreeProfile.OAK);
|
||||
TestSettings.with(tree.getCanopy(), "mode", mode);
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 10;
|
||||
double[][] offsets = TreeTrunkBuilder.build(canvas, tree, height).get(0).offsets();
|
||||
@@ -124,14 +125,14 @@ public class ProceduralTreeGeneratorTest {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:jungle_log");
|
||||
tree.setLeaves("minecraft:jungle_leaves");
|
||||
tree.setProfile(IrisTreeProfile.JUNGLE);
|
||||
IrisTreeBranches branches = new IrisTreeBranches();
|
||||
branches.setProbabilityFunction(IrisTreeBranchProbability.CONSTANT);
|
||||
branches.setProbabilityConstant(1.0);
|
||||
branches.setLengthFunction(IrisTreeFunction.CONSTANT);
|
||||
branches.setLengthConstant(4);
|
||||
branches.setAzimuthMode(art.arcane.iris.engine.object.procedural.tree.IrisTreeAzimuthMode.GOLDEN_ANGLE);
|
||||
tree.getCanopy().setBranches(branches);
|
||||
tree.setProfile(TreeProfile.JUNGLE);
|
||||
TreeBranches branches = new TreeBranches();
|
||||
TestSettings.with(branches, "probabilityFunction", TreeBranchProbability.CONSTANT);
|
||||
TestSettings.with(branches, "probabilityConstant", 1.0);
|
||||
TestSettings.with(branches, "lengthFunction", TreeFunction.CONSTANT);
|
||||
TestSettings.with(branches, "lengthConstant", 4);
|
||||
TestSettings.with(branches, "azimuthMode", art.arcane.iris.builtin.objects.tree.TreeAzimuthMode.GOLDEN_ANGLE);
|
||||
TestSettings.with(tree.getCanopy(), "branches", branches);
|
||||
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 14;
|
||||
@@ -176,14 +177,14 @@ public class ProceduralTreeGeneratorTest {
|
||||
IrisProceduralTree tree = new IrisProceduralTree();
|
||||
tree.setTrunk("minecraft:oak_log");
|
||||
tree.setLeaves("minecraft:oak_leaves");
|
||||
IrisTreeBranches branches = new IrisTreeBranches();
|
||||
branches.setProbabilityFunction(IrisTreeBranchProbability.CONSTANT);
|
||||
branches.setProbabilityConstant(1.0);
|
||||
branches.setLengthFunction(IrisTreeFunction.CONSTANT);
|
||||
branches.setLengthConstant(4);
|
||||
branches.setBranchDepth(depth);
|
||||
branches.setSubBranches(new art.arcane.iris.engine.object.procedural.tree.IrisTreeSubBranches());
|
||||
tree.getCanopy().setBranches(branches);
|
||||
TreeBranches branches = new TreeBranches();
|
||||
TestSettings.with(branches, "probabilityFunction", TreeBranchProbability.CONSTANT);
|
||||
TestSettings.with(branches, "probabilityConstant", 1.0);
|
||||
TestSettings.with(branches, "lengthFunction", TreeFunction.CONSTANT);
|
||||
TestSettings.with(branches, "lengthConstant", 4);
|
||||
TestSettings.with(branches, "branchDepth", depth);
|
||||
TestSettings.with(branches, "subBranches", new art.arcane.iris.builtin.objects.tree.TreeSubBranches());
|
||||
TestSettings.with(tree.getCanopy(), "branches", branches);
|
||||
|
||||
TreeBlockCanvas canvas = new TreeBlockCanvas();
|
||||
int height = 14;
|
||||
|
||||
Reference in new issue
Block a user