mirror of
https://github.com/xSquishyLiam/mc-GeyserModelEnginePackGenerator-extension.git
synced 2025-12-19 23:09:16 +00:00
and fully sorted namespaces (i hope)
This commit is contained in:
@@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import re.imc.geysermodelenginepackgenerator.GeyserModelEnginePackGenerator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -36,7 +37,7 @@ public class AnimationController {
|
|||||||
}
|
}
|
||||||
""";
|
""";
|
||||||
|
|
||||||
public void load(Animation animation, Entity entity) {
|
public void load(GeyserModelEnginePackGenerator extension, Animation animation, Entity entity) {
|
||||||
JsonObject root = new JsonObject();
|
JsonObject root = new JsonObject();
|
||||||
json = root;
|
json = root;
|
||||||
root.addProperty("format_version", "1.10.0");
|
root.addProperty("format_version", "1.10.0");
|
||||||
@@ -51,7 +52,9 @@ public class AnimationController {
|
|||||||
for (String id : sorted) {
|
for (String id : sorted) {
|
||||||
id = id.replace(" ", "_");
|
id = id.replace(" ", "_");
|
||||||
int n = (int) Math.pow(2, (i % 24));
|
int n = (int) Math.pow(2, (i % 24));
|
||||||
JsonObject controller = JsonParser.parseString(CONTROLLER_TEMPLATE.replace("%anim%", id).replace("%query%", "math.mod(math.floor(query.property('modelengine:anim" + i / 24 + "') / " + n + "), 2)")).getAsJsonObject();
|
|
||||||
|
//TODO namespace
|
||||||
|
JsonObject controller = JsonParser.parseString(CONTROLLER_TEMPLATE.replace("%anim%", id).replace("%query%", "math.mod(math.floor(query.property('" + extension.getConfigManager().getConfig().getString("models.namespace") + ":anim" + i / 24 + "') / " + n + "), 2)")).getAsJsonObject();
|
||||||
animationControllers.add("controller.animation." + animation.getModelId() + "." + id, controller);
|
animationControllers.add("controller.animation." + animation.getModelId() + "." + id, controller);
|
||||||
i++;
|
i++;
|
||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ public class Geometry {
|
|||||||
public void load(String json) {
|
public void load(String json) {
|
||||||
this.json = JsonParser.parseString(json).getAsJsonObject();
|
this.json = JsonParser.parseString(json).getAsJsonObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setId(String id) {
|
public void setId(String id) {
|
||||||
geometryId = id;
|
geometryId = id;
|
||||||
getInternal().get("description").getAsJsonObject().addProperty("identifier", id);
|
getInternal().get("description").getAsJsonObject().addProperty("identifier", id);
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class RenderController {
|
|||||||
if (key.endsWith("_e")) continue;
|
if (key.endsWith("_e")) continue;
|
||||||
|
|
||||||
// Texture texture = entity.textureMap.get(key);
|
// Texture texture = entity.textureMap.get(key);
|
||||||
Set<String> uvBonesId = entity.getModelConfig().bingingBones.get(key);
|
Set<String> uvBonesId = entity.getModelConfig().getBingingBones().get(key);
|
||||||
|
|
||||||
if (uvBonesId == null) {
|
if (uvBonesId == null) {
|
||||||
if (!singleTexture) {
|
if (!singleTexture) {
|
||||||
@@ -138,7 +138,7 @@ public class RenderController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
for (Map.Entry<String, Set<String>> entry : entity.getModelConfig().bingingBones.entrySet()) {
|
for (Map.Entry<String, Set<String>> entry : entity.getModelConfig().getBingingBones().entrySet()) {
|
||||||
if (entry.getKey().equals(key)) continue;
|
if (entry.getKey().equals(key)) continue;
|
||||||
|
|
||||||
if (entry.getValue().stream().anyMatch(boneName::equalsIgnoreCase)) {
|
if (entry.getValue().stream().anyMatch(boneName::equalsIgnoreCase)) {
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ public class ResourcePackManager {
|
|||||||
if (path.toFile().exists()) continue;
|
if (path.toFile().exists()) continue;
|
||||||
|
|
||||||
AnimationController controller = new AnimationController();
|
AnimationController controller = new AnimationController();
|
||||||
controller.load(entry.getValue(), entity);
|
controller.load(extension, entry.getValue(), entity);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Files.writeString(path, GSON.toJson(entry.getValue().getJson()), StandardCharsets.UTF_8);
|
Files.writeString(path, GSON.toJson(entry.getValue().getJson()), StandardCharsets.UTF_8);
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
public class ZipUtil {
|
public class ZipUtil {
|
||||||
|
|
||||||
public static void compressFolder(File folder, String folderName, ZipOutputStream zipOutputStream) throws IOException {
|
public static void compressFolder(File folder, String folderName, ZipOutputStream zipOutputStream) throws IOException {
|
||||||
File[] files = folder.listFiles();
|
File[] files = folder.listFiles();
|
||||||
|
|
||||||
@@ -16,13 +17,15 @@ public class ZipUtil {
|
|||||||
if (folderName == null) {
|
if (folderName == null) {
|
||||||
compressFolder(file, file.getName(), zipOutputStream);
|
compressFolder(file, file.getName(), zipOutputStream);
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
|
|
||||||
compressFolder(file, folderName + "/" + file.getName(), zipOutputStream);
|
compressFolder(file, folderName + "/" + file.getName(), zipOutputStream);
|
||||||
} else {
|
} else {
|
||||||
if (folderName == null) {
|
if (folderName == null) {
|
||||||
addToZipFile(file.getName(), file, zipOutputStream);
|
addToZipFile(file.getName(), file, zipOutputStream);
|
||||||
continue;
|
continue;
|
||||||
};
|
}
|
||||||
|
|
||||||
addToZipFile(folderName + "/" + file.getName(), file, zipOutputStream);
|
addToZipFile(folderName + "/" + file.getName(), file, zipOutputStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +43,7 @@ public class ZipUtil {
|
|||||||
zipOutputStream.write(buffer, 0, bytesRead);
|
zipOutputStream.write(buffer, 0, bytesRead);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
zipOutputStream.closeEntry();
|
zipOutputStream.closeEntry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user