and fully sorted namespaces (i hope)

This commit is contained in:
xSquishyLiam
2025-09-06 02:17:16 +01:00
parent 960c2750da
commit 488f9e78f9
5 changed files with 15 additions and 7 deletions

View File

@@ -5,6 +5,7 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import lombok.Getter;
import lombok.Setter;
import re.imc.geysermodelenginepackgenerator.GeyserModelEnginePackGenerator;
import java.util.ArrayList;
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();
json = root;
root.addProperty("format_version", "1.10.0");
@@ -51,7 +52,9 @@ public class AnimationController {
for (String id : sorted) {
id = id.replace(" ", "_");
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);
i++;
if (entity != null) {

View File

@@ -20,6 +20,7 @@ public class Geometry {
public void load(String json) {
this.json = JsonParser.parseString(json).getAsJsonObject();
}
public void setId(String id) {
geometryId = id;
getInternal().get("description").getAsJsonObject().addProperty("identifier", id);

View File

@@ -35,7 +35,7 @@ public class RenderController {
if (key.endsWith("_e")) continue;
// 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 (!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.getValue().stream().anyMatch(boneName::equalsIgnoreCase)) {

View File

@@ -112,7 +112,7 @@ public class ResourcePackManager {
if (path.toFile().exists()) continue;
AnimationController controller = new AnimationController();
controller.load(entry.getValue(), entity);
controller.load(extension, entry.getValue(), entity);
try {
Files.writeString(path, GSON.toJson(entry.getValue().getJson()), StandardCharsets.UTF_8);

View File

@@ -7,6 +7,7 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
public class ZipUtil {
public static void compressFolder(File folder, String folderName, ZipOutputStream zipOutputStream) throws IOException {
File[] files = folder.listFiles();
@@ -16,13 +17,15 @@ public class ZipUtil {
if (folderName == null) {
compressFolder(file, file.getName(), zipOutputStream);
continue;
};
}
compressFolder(file, folderName + "/" + file.getName(), zipOutputStream);
} else {
if (folderName == null) {
addToZipFile(file.getName(), file, zipOutputStream);
continue;
};
}
addToZipFile(folderName + "/" + file.getName(), file, zipOutputStream);
}
}
@@ -40,6 +43,7 @@ public class ZipUtil {
zipOutputStream.write(buffer, 0, bytesRead);
}
}
zipOutputStream.closeEntry();
}
}