mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 22:10:18 +00:00
Fixed ingested ore anchors
- above_bottom and below_top ore anchors resolve against the pack's own dimension height, or the borrowed dimension type's height when the pack borrows one, instead of the vanilla dimension type - Converted deposit heights now match the pack-relative rebase, so a 0..256 pack no longer receives out-of-world ore bands
This commit is contained in:
1 parent
a3f607e264
commit
b8aabd4fd1
3 files changed
+97
-17
No files matched your search
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||
* Copyright (c) 2022 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.pack.ingest;
|
||||
|
||||
import art.arcane.iris.pack.ingest.catalog.CatalogDimensionType;
|
||||
import art.arcane.iris.pack.ingest.catalog.WorldgenCatalog;
|
||||
import com.google.gson.JsonObject;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.TemporaryFolder;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
|
||||
public class IngestHeightBoundsTest {
|
||||
@Rule
|
||||
public TemporaryFolder folder = new TemporaryFolder();
|
||||
|
||||
@Test
|
||||
public void relativeAnchorsResolveAgainstThePacksOwnHeight() throws Exception {
|
||||
JsonObject stone = tinDeposit("\"dimensionHeight\": {\"min\": 0, \"max\": 256}", ModIngestFixture.catalog());
|
||||
|
||||
assertEquals(16, stone.get("minHeight").getAsInt());
|
||||
assertEquals(235, stone.get("maxHeight").getAsInt());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void relativeAnchorsResolveAgainstTheBorrowedTypeWhenSet() throws Exception {
|
||||
WorldgenCatalog fixture = ModIngestFixture.catalog();
|
||||
List<CatalogDimensionType> types = new ArrayList<>(fixture.dimensionTypes());
|
||||
types.add(new CatalogDimensionType("examplemod:skyrealm", 0, 256, 256, null));
|
||||
WorldgenCatalog catalog = new WorldgenCatalog(fixture.format(), fixture.minecraftVersion(), fixture.platform(),
|
||||
fixture.capturedAtEpochMillis(), fixture.contentFingerprint(), fixture.namespaces(), fixture.biomes(),
|
||||
fixture.placedFeatures(), fixture.structures(), types, fixture.levelStems());
|
||||
|
||||
JsonObject stone = tinDeposit("\"dimensionHeight\": {\"min\": 0, \"max\": 192}, \"borrowedDimensionType\": \"examplemod:skyrealm\"",
|
||||
catalog);
|
||||
|
||||
assertEquals(16, stone.get("minHeight").getAsInt());
|
||||
assertEquals(235, stone.get("maxHeight").getAsInt());
|
||||
}
|
||||
|
||||
private JsonObject tinDeposit(String heightFields, WorldgenCatalog catalog) throws Exception {
|
||||
Path root = folder.getRoot().toPath();
|
||||
Path source = ModIngestFixture.writeSourcePack(root);
|
||||
ModIngestFixture.write(source, "dimensions/overworld.json", """
|
||||
{
|
||||
"name": "Overworld",
|
||||
"environment": "NORMAL",
|
||||
"regions": ["hot", "temperate"],
|
||||
%s
|
||||
}
|
||||
""".formatted(heightFields));
|
||||
Path target = root.resolve("packs").resolve("modded");
|
||||
ModIngester.ingest(new ModIngestRequest(source, target, "overworld", catalog, Set.of(ModIngestFixture.MOD), false));
|
||||
JsonObject dimension = ModIngestFixture.readJson(target.resolve("dimensions/modded.json"));
|
||||
JsonObject stone = ModIngestFixture.findByPaletteBlock(dimension.getAsJsonArray("deposits"), "examplemod:tin_ore");
|
||||
assertNotNull(stone);
|
||||
return stone;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public class ModIngesterFeatureTest {
|
||||
assertEquals(4, deposits.size());
|
||||
assertNotNull(stone);
|
||||
assertNotNull(deepslate);
|
||||
assertEquals(80, stone.get("minHeight").getAsInt());
|
||||
assertEquals(16, stone.get("minHeight").getAsInt());
|
||||
assertEquals(427, stone.get("maxHeight").getAsInt());
|
||||
assertEquals("UNIFORM", stone.get("heightDistribution").getAsString());
|
||||
assertEquals(12, stone.get("minPerChunk").getAsInt());
|
||||
|
||||
Reference in new issue
Block a user