Public Access
Add Milestone 7 regression and documentation review (#83)
Build / build (push) Canceled after 0s
Build / build (push) Canceled after 0s
This commit is contained in:
1 parent
77f15f8599
commit
e7e2cf7e5a
12 files changed
+424
-285
No files matched your search
@@ -178,8 +178,11 @@ public final class AgeStructureGameTests {
|
||||
var age = AgeRegistrySavedData.resolveOrCreate(helper.getLevel(),
|
||||
new AgeReference(java.util.UUID.randomUUID(), "Mixed " + firstBiome), writing);
|
||||
int expected = firstBiome.equals("the_end") ? 200 : 0;
|
||||
helper.assertValueEqual(age.instability().score(), expected,
|
||||
"Each Village page must charge 100 if any selected biome needs the override");
|
||||
helper.assertValueEqual(age.instability().breakdown().stream()
|
||||
.filter(part -> part.reason().equals("forced_biome_villages"))
|
||||
.mapToInt(AgeInstability.Contribution::points).sum(), expected,
|
||||
"Each Village page must charge 100 if any selected biome needs the override; "
|
||||
+ "seed-completed celestial instability is independent");
|
||||
helper.assertValueEqual(age.instability().breakdown().stream()
|
||||
.filter(part -> part.reason().equals("forced_biome_villages")).count(),
|
||||
firstBiome.equals("the_end") ? 2L : 0L,
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
package net.dnorberg.rivencraft.gametest;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import net.dnorberg.rivencraft.Rivencraft;
|
||||
import net.minecraft.gametest.framework.GameTest;
|
||||
import net.minecraft.gametest.framework.GameTestHelper;
|
||||
import net.neoforged.neoforge.gametest.GameTestHolder;
|
||||
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
|
||||
|
||||
/** Small server-side guard against shipping missing model textures or the library template. */
|
||||
@GameTestHolder(Rivencraft.MOD_ID)
|
||||
@PrefixGameTestTemplate(false)
|
||||
public final class Milestone7ResourceGameTests {
|
||||
private Milestone7ResourceGameTests() {}
|
||||
|
||||
@GameTest(template = "empty")
|
||||
public static void coreModelsResolveBundledTextures(GameTestHelper helper) {
|
||||
for (String model : List.of("book_binder", "ink_mixer", "writing_desk",
|
||||
"book_receptacle", "crystal_block", "crystal_portal")) {
|
||||
String path = "assets/rivencraft/models/block/" + model + ".json";
|
||||
try (InputStream stream = resource(path)) {
|
||||
helper.assertTrue(stream != null, "Missing packaged block model " + path);
|
||||
JsonObject json = JsonParser.parseReader(new InputStreamReader(stream, StandardCharsets.UTF_8))
|
||||
.getAsJsonObject();
|
||||
if (!json.has("textures")) continue;
|
||||
for (var entry : json.getAsJsonObject("textures").entrySet()) {
|
||||
String texture = entry.getValue().getAsString();
|
||||
if (!texture.startsWith("rivencraft:")) continue;
|
||||
String texturePath = "assets/rivencraft/textures/"
|
||||
+ texture.substring("rivencraft:".length()) + ".png";
|
||||
helper.assertTrue(Milestone7ResourceGameTests.class.getClassLoader().getResource(texturePath) != null,
|
||||
"Model " + model + " references missing texture " + texturePath);
|
||||
}
|
||||
} catch (java.io.IOException exception) {
|
||||
throw new IllegalStateException("Cannot inspect " + path, exception);
|
||||
}
|
||||
}
|
||||
helper.assertTrue(Milestone7ResourceGameTests.class.getClassLoader()
|
||||
.getResource("data/rivencraft/structure/mystcraft_library.nbt") != null,
|
||||
"The Legacy library template must be included in the mod JAR");
|
||||
helper.succeed();
|
||||
}
|
||||
|
||||
private static InputStream resource(String path) {
|
||||
return Milestone7ResourceGameTests.class.getClassLoader().getResourceAsStream(path);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user