Crashed Ship datapck support
This commit is contained in:
parent
a4dfa6d507
commit
62c9c622a4
2 changed files with 69 additions and 5 deletions
|
@ -1,9 +1,13 @@
|
|||
package ru.betterend.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Random;
|
||||
import java.util.Set;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
|
||||
|
@ -35,6 +39,33 @@ public class StructureHelper {
|
|||
return readStructure("/data/" + ns + "/structures/" + nm + ".nbt");
|
||||
}
|
||||
|
||||
public static Structure readStructure(File datapack, String path) {
|
||||
if (datapack.isDirectory()) {
|
||||
return readStructure(datapack.toString() + "/" + path);
|
||||
}
|
||||
else if (datapack.isFile() && datapack.getName().endsWith(".zip")) {
|
||||
try {
|
||||
ZipFile zipFile = new ZipFile(datapack);
|
||||
Enumeration<? extends ZipEntry> entries = zipFile.entries();
|
||||
while (entries.hasMoreElements()) {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
String name = entry.getName();
|
||||
long compressedSize = entry.getCompressedSize();
|
||||
long normalSize = entry.getSize();
|
||||
String type = entry.isDirectory() ? "DIR" : "FILE";
|
||||
|
||||
System.out.println(name);
|
||||
System.out.format("\t %s - %d - %d\n", type, compressedSize, normalSize);
|
||||
}
|
||||
zipFile.close();
|
||||
}
|
||||
catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Structure readStructure(String path) {
|
||||
try {
|
||||
InputStream inputstream = StructureHelper.class.getResourceAsStream(path);
|
||||
|
@ -320,8 +351,7 @@ public class StructureHelper {
|
|||
|| state.isIn(BlockTags.LOGS)
|
||||
|| state.isIn(BlockTags.LEAVES)
|
||||
|| state.getMaterial().equals(Material.PLANT)
|
||||
|| state.getMaterial().equals(Material.LEAVES)
|
||||
|| state.getMaterial().equals(Material.WOOD);
|
||||
|| state.getMaterial().equals(Material.LEAVES);
|
||||
}
|
||||
|
||||
private static void shuffle(Random random) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue