diff --git a/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java b/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java index 6080530bb..06b961c13 100644 --- a/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java +++ b/core/src/main/java/com/volmit/iris/core/commands/CommandDeveloper.java @@ -37,6 +37,7 @@ import com.volmit.iris.util.io.CountingDataInputStream; import com.volmit.iris.util.io.IO; import com.volmit.iris.util.mantle.TectonicPlate; import com.volmit.iris.util.math.M; +import com.volmit.iris.util.matter.Matter; import com.volmit.iris.util.nbt.mca.MCAFile; import com.volmit.iris.util.nbt.mca.MCAUtil; import com.volmit.iris.util.parallel.MultiBurst; @@ -53,6 +54,7 @@ import org.bukkit.World; import java.io.*; import java.net.InetAddress; import java.net.NetworkInterface; +import java.nio.file.Files; import java.util.*; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -78,6 +80,33 @@ public class CommandDeveloper implements DecreeExecutor { Iris.reportError(new Exception("This is a test")); } + @Decree(description = "Test") + public void mantle(@Param(defaultValue = "false") boolean plate, @Param(defaultValue = "21474836474") String name) throws Throwable { + var base = Iris.instance.getDataFile("dump", "pv." + name + ".ttp.lz4b.bin"); + var section = Iris.instance.getDataFile("dump", "pv." + name + ".section.bin"); + + //extractSection(base, section, 5604930, 4397); + + if (plate) { + try (var in = CountingDataInputStream.wrap(new BufferedInputStream(new FileInputStream(base)))) { + new TectonicPlate(1088, in, true); + } catch (Throwable e) { + e.printStackTrace(); + } + } else Matter.read(section); + if (!TectonicPlate.hasError()) + Iris.info("Read " + (plate ? base : section).length() + " bytes from " + (plate ? base : section).getAbsolutePath()); + } + + private void extractSection(File source, File target, long offset, int length) throws IOException { + var raf = new RandomAccessFile(source, "r"); + var bytes = new byte[length]; + raf.seek(offset); + raf.readFully(bytes); + raf.close(); + Files.write(target.toPath(), bytes); + } + @Decree(description = "Test") public void dumpThreads() { try {