This commit is contained in:
zimzaza4
2024-12-06 22:23:40 +08:00
parent 4931513b8b
commit 5d059e3c32
2 changed files with 8 additions and 8 deletions

View File

@@ -64,7 +64,7 @@ public class GeneratorMain {
} }
Map<String, Texture> map = textureMap.computeIfAbsent(modelId, s -> new HashMap<>()); Map<String, Texture> map = textureMap.computeIfAbsent(modelId, s -> new HashMap<>());
try { try {
map.put(textureName, new Texture(modelId, currentPath, bindingBones, ImageIO.read(zip.getInputStream(e)))); map.put(textureName, new Texture(modelId, currentPath, bindingBones, zip.getInputStream(e).readAllBytes()));
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@@ -111,11 +111,11 @@ public class GeneratorMain {
public static void generateFromFolder(String currentPath, File folder) { public static void generateFromFolder(String currentPath, File folder, boolean root) {
if (folder.listFiles() == null) { if (folder.listFiles() == null) {
return; return;
} }
String modelId = folder.getName().toLowerCase(); String modelId = root ? "" : folder.getName().toLowerCase();
Entity entity = new Entity(modelId); Entity entity = new Entity(modelId);
ModelConfig modelConfig = new ModelConfig(); ModelConfig modelConfig = new ModelConfig();
@@ -131,7 +131,7 @@ public class GeneratorMain {
boolean canAdd = false; boolean canAdd = false;
for (File e : folder.listFiles()) { for (File e : folder.listFiles()) {
if (e.isDirectory()) { if (e.isDirectory()) {
generateFromFolder(currentPath + folder.getName() + "/", e); generateFromFolder(currentPath + folder.getName() + "/", e, false);
} }
if (e.getName().endsWith(".zip")) { if (e.getName().endsWith(".zip")) {
try { try {
@@ -149,7 +149,7 @@ public class GeneratorMain {
} }
Map<String, Texture> map = textureMap.computeIfAbsent(modelId, s -> new HashMap<>()); Map<String, Texture> map = textureMap.computeIfAbsent(modelId, s -> new HashMap<>());
try { try {
map.put(textureName, new Texture(modelId, currentPath, bindingBones, ImageIO.read(e))); map.put(textureName, new Texture(modelId, currentPath, bindingBones, Files.readAllBytes(e.toPath())));
} catch (IOException ex) { } catch (IOException ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
@@ -218,7 +218,7 @@ public class GeneratorMain {
} }
public static void startGenerate(File source, File output) { public static void startGenerate(File source, File output) {
generateFromFolder("", source); generateFromFolder("", source, true);
File animationsFolder = new File(output, "animations"); File animationsFolder = new File(output, "animations");
File entityFolder = new File(output, "entity"); File entityFolder = new File(output, "entity");
@@ -345,7 +345,7 @@ public class GeneratorMain {
} }
try { try {
if (entry.getValue().getImage() != null) { if (entry.getValue().getImage() != null) {
ImageIO.write(entry.getValue().getImage(), "png", path.toFile()); Files.write(path, entry.getValue().getImage());
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();

View File

@@ -17,6 +17,6 @@ public class Texture {
String modelId; String modelId;
String path; String path;
Set<String> bindingBones; Set<String> bindingBones;
BufferedImage image; byte[] image;
} }