diff --git a/gradle.properties b/gradle.properties index a26da175..6fb762fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -8,7 +8,7 @@ loader_version=0.14.21 fabric_version=0.84.0+1.20.1 # Mod Properties -mod_version=0.8.0 +mod_version=0.8.1 maven_group=net.devtech archives_base_name=arrp # Dependencies diff --git a/src/main/java/net/devtech/arrp/impl/RuntimeResourcePackImpl.java b/src/main/java/net/devtech/arrp/impl/RuntimeResourcePackImpl.java index ecf0ba6c..c545df41 100644 --- a/src/main/java/net/devtech/arrp/impl/RuntimeResourcePackImpl.java +++ b/src/main/java/net/devtech/arrp/impl/RuntimeResourcePackImpl.java @@ -303,7 +303,7 @@ public void dumpDirect(Path output) { for(Map.Entry, Supplier> e : this.root.entrySet()) { String pathStr = String.join("/", e.getKey()); Path path = output.resolve(pathStr); - if(path.startsWith(output)) { + if(path.toAbsolutePath().startsWith(output.toAbsolutePath())) { Files.createDirectories(path.getParent()); Files.write(path, e.getValue().get()); } else { @@ -554,7 +554,7 @@ private void write(Path dir, Identifier identifier, byte[] data) { String namespace = identifier.getNamespace(); String path = identifier.getPath(); Path file = dir.resolve(namespace).resolve(path); - if(file.startsWith(dir)) { + if(file.toAbsolutePath().startsWith(dir.toAbsolutePath())) { Files.createDirectories(file.getParent()); try(OutputStream output = Files.newOutputStream(file)) { output.write(data); diff --git a/src/test/java/test/RRPPreTest.java b/src/test/java/test/RRPPreTest.java index a33f14ad..ab88905a 100644 --- a/src/test/java/test/RRPPreTest.java +++ b/src/test/java/test/RRPPreTest.java @@ -16,6 +16,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import net.devtech.arrp.api.RuntimeResourcePack; import net.devtech.arrp.impl.RuntimeResourcePackImpl; import net.devtech.arrp.json.blockstate.JMultipart; import net.devtech.arrp.json.blockstate.JState; @@ -27,9 +28,14 @@ import net.minecraft.util.Identifier; import net.minecraft.util.math.Direction; +import java.nio.file.Path; public class RRPPreTest { public static void main(String[] args) { + RuntimeResourcePack pack = RuntimeResourcePack.create("test:test"); + pack.addLang(new Identifier("aaaa:aaaa"), new JLang().entry("aaaa", "bbbbb")); + pack.dumpDirect(Path.of("aaaa")); + JState iron_block = state(variant(JState.model("block/iron_block"))); JState oak_fence = state(multipart(JState.model("block/oak_fence_post")), multipart(JState.model("block/oak_fence_side").uvlock()).when(when().add("north", "true")), @@ -47,6 +53,8 @@ public static void main(String[] args) { .west(face("all").uv(9, 0, 11, 16)) .east(face("all").uv(9, 0, 11, 16)))); + + Gson gson = new GsonBuilder().registerTypeAdapter(JMultipart.class, new JMultipart.Serializer()) .registerTypeAdapter(JWhen.class, new JWhen.Serializer()) .registerTypeAdapter(JState.class, new JState.Serializer())