mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-07-21 06:10:41 +00:00
Amending / removing all structures will redesign later im over this
This commit is contained in:
@@ -1,93 +0,0 @@
|
||||
package art.arcane.iris.core;
|
||||
|
||||
import art.arcane.volmlib.util.nbt.io.NBTDeserializer;
|
||||
import art.arcane.volmlib.util.nbt.io.NBTSerializer;
|
||||
import art.arcane.volmlib.util.nbt.io.NamedTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.CompoundTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.IntTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.ListTag;
|
||||
import art.arcane.volmlib.util.nbt.tag.Tag;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
public class ExternalDataPackPipelineNbtRewriteTest {
|
||||
@Test
|
||||
public void rewritesOnlyJigsawPoolReferencesForCompressedAndUncompressedNbt() throws Exception {
|
||||
for (boolean compressed : new boolean[]{false, true}) {
|
||||
byte[] source = encodeStructureNbt(compressed, true);
|
||||
Map<String, String> remapped = new HashMap<>();
|
||||
remapped.put("minecraft:witch_hut/foundation", "iris_external_1:witch_hut/foundation");
|
||||
|
||||
byte[] rewritten = invokeRewrite(source, remapped);
|
||||
CompoundTag root = decodeRoot(rewritten, compressed);
|
||||
ListTag<?> blocks = root.getListTag("blocks");
|
||||
|
||||
CompoundTag jigsawBlock = (CompoundTag) blocks.get(0);
|
||||
CompoundTag nonJigsawBlock = (CompoundTag) blocks.get(1);
|
||||
assertEquals("iris_external_1:witch_hut/foundation", jigsawBlock.getCompoundTag("nbt").getString("pool"));
|
||||
assertEquals("minecraft:witch_hut/foundation", nonJigsawBlock.getCompoundTag("nbt").getString("pool"));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nonJigsawPayloadIsLeftUnchanged() throws Exception {
|
||||
byte[] source = encodeStructureNbt(false, false);
|
||||
Map<String, String> remapped = new HashMap<>();
|
||||
remapped.put("minecraft:witch_hut/foundation", "iris_external_1:witch_hut/foundation");
|
||||
|
||||
byte[] rewritten = invokeRewrite(source, remapped);
|
||||
assertArrayEquals(source, rewritten);
|
||||
}
|
||||
|
||||
private byte[] invokeRewrite(byte[] input, Map<String, String> remappedKeys) {
|
||||
return StructureNbtJigsawPoolRewriter.rewrite(input, remappedKeys);
|
||||
}
|
||||
|
||||
private byte[] encodeStructureNbt(boolean compressed, boolean includeJigsaw) throws Exception {
|
||||
CompoundTag root = new CompoundTag();
|
||||
ListTag<CompoundTag> palette = new ListTag<>(CompoundTag.class);
|
||||
|
||||
CompoundTag firstPalette = new CompoundTag();
|
||||
firstPalette.putString("Name", includeJigsaw ? "minecraft:jigsaw" : "minecraft:stone");
|
||||
palette.add(firstPalette);
|
||||
|
||||
CompoundTag secondPalette = new CompoundTag();
|
||||
secondPalette.putString("Name", "minecraft:stone");
|
||||
palette.add(secondPalette);
|
||||
root.put("palette", palette);
|
||||
|
||||
ListTag<CompoundTag> blocks = new ListTag<>(CompoundTag.class);
|
||||
blocks.add(blockTag(0, "minecraft:witch_hut/foundation"));
|
||||
blocks.add(blockTag(1, "minecraft:witch_hut/foundation"));
|
||||
root.put("blocks", blocks);
|
||||
|
||||
NamedTag named = new NamedTag("test", root);
|
||||
return new NBTSerializer(compressed).toBytes(named);
|
||||
}
|
||||
|
||||
private CompoundTag blockTag(int state, String pool) {
|
||||
CompoundTag block = new CompoundTag();
|
||||
block.putInt("state", state);
|
||||
CompoundTag nbt = new CompoundTag();
|
||||
nbt.putString("pool", pool);
|
||||
block.put("nbt", nbt);
|
||||
ListTag<IntTag> pos = new ListTag<>(IntTag.class);
|
||||
pos.add(new IntTag(0));
|
||||
pos.add(new IntTag(0));
|
||||
pos.add(new IntTag(0));
|
||||
block.put("pos", pos);
|
||||
return block;
|
||||
}
|
||||
|
||||
private CompoundTag decodeRoot(byte[] bytes, boolean compressed) throws Exception {
|
||||
NamedTag namedTag = new NBTDeserializer(compressed).fromStream(new ByteArrayInputStream(bytes));
|
||||
Tag<?> rootTag = namedTag.getTag();
|
||||
return (CompoundTag) rootTag;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
package art.arcane.iris.core;
|
||||
|
||||
import art.arcane.volmlib.util.collection.KList;
|
||||
import art.arcane.volmlib.util.collection.KMap;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class ServerConfiguratorDatapackFolderTest {
|
||||
@Test
|
||||
public void resolvesDimensionWorldFolderBackToRootDatapacks() {
|
||||
File folder = new File("/tmp/server/world/dimensions/minecraft/overworld");
|
||||
File datapacks = ServerConfigurator.resolveDatapacksFolder(folder);
|
||||
assertEquals(new File("/tmp/server/world/datapacks").getAbsolutePath(), datapacks.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keepsStandaloneWorldFolderDatapacksUnchanged() {
|
||||
File folder = new File("/tmp/server/custom_world");
|
||||
File datapacks = ServerConfigurator.resolveDatapacksFolder(folder);
|
||||
assertEquals(new File("/tmp/server/custom_world/datapacks").getAbsolutePath(), datapacks.getAbsolutePath());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void installFoldersIncludeExtraStudioWorldDatapackTargets() {
|
||||
File baseFolder = new File("/tmp/server/world/datapacks");
|
||||
File extraFolder = new File("/tmp/server/iris-studio/datapacks");
|
||||
KList<File> baseFolders = new KList<>();
|
||||
baseFolders.add(baseFolder);
|
||||
KList<File> extraFolders = new KList<>();
|
||||
extraFolders.add(extraFolder);
|
||||
KMap<String, KList<File>> extrasByPack = new KMap<>();
|
||||
extrasByPack.put("overworld", extraFolders);
|
||||
|
||||
KList<File> folders = ServerConfigurator.collectInstallDatapackFolders(baseFolders, extrasByPack);
|
||||
|
||||
assertEquals(2, folders.size());
|
||||
assertTrue(folders.contains(baseFolder));
|
||||
assertTrue(folders.contains(extraFolder));
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package art.arcane.iris.core.runtime;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class DatapackReadinessResultTest {
|
||||
@Test
|
||||
public void verificationUsesDimensionTypeKeyPath() throws Exception {
|
||||
Path root = Files.createTempDirectory("iris-datapack-readiness");
|
||||
Path datapackRoot = root.resolve("iris");
|
||||
Files.createDirectories(datapackRoot.resolve("data/iris/dimension_type"));
|
||||
Files.writeString(datapackRoot.resolve("pack.mcmeta"), "{}");
|
||||
Files.writeString(datapackRoot.resolve("data/iris/dimension_type/runtime-key.json"), "{}");
|
||||
|
||||
ArrayList<String> verifiedPaths = new ArrayList<>();
|
||||
ArrayList<String> missingPaths = new ArrayList<>();
|
||||
DatapackReadinessResult.collectVerificationPaths(root.toFile(), "runtime-key", verifiedPaths, missingPaths);
|
||||
|
||||
assertTrue(missingPaths.isEmpty());
|
||||
assertEquals(2, verifiedPaths.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void verificationMarksMissingDimensionTypePath() throws Exception {
|
||||
Path root = Files.createTempDirectory("iris-datapack-readiness-missing");
|
||||
Path datapackRoot = root.resolve("iris");
|
||||
Files.createDirectories(datapackRoot);
|
||||
Files.writeString(datapackRoot.resolve("pack.mcmeta"), "{}");
|
||||
|
||||
ArrayList<String> verifiedPaths = new ArrayList<>();
|
||||
ArrayList<String> missingPaths = new ArrayList<>();
|
||||
DatapackReadinessResult.collectVerificationPaths(root.toFile(), "runtime-key", verifiedPaths, missingPaths);
|
||||
|
||||
assertEquals(1, verifiedPaths.size());
|
||||
assertEquals(1, missingPaths.size());
|
||||
assertTrue(missingPaths.get(0).endsWith(File.separator + "iris" + File.separator + "data" + File.separator + "iris" + File.separator + "dimension_type" + File.separator + "runtime-key.json"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user