added namespace support make sure to add inside the config models.namespace

This commit is contained in:
xSquishyLiam
2025-09-01 19:36:57 +01:00
parent 48241509d2
commit ed95ddfbaf
5 changed files with 14 additions and 11 deletions

View File

@@ -110,8 +110,9 @@ public class Entity {
}
}
public void register() {
String id = "modelengine:" + modelId;
public void register(String namespace) {
String id = namespace + ":" + modelId;
boolean registered = REGISTERED_ENTITIES.contains(id);
if (registered) return;
@@ -121,13 +122,13 @@ public class Entity {
if (!modelConfig.isDisablePartVisibility()) {
for (int i = 0; i < Math.ceil(geometry.getBones().size() / 24f); i++) {
GeyserUtils.addProperty(id, "modelengine:bone" + i, Integer.class);
GeyserUtils.addProperty(id, namespace + ":" + "bone" + i, Integer.class);
}
}
if (animation != null) {
for (int i = 0; i < Math.ceil(animation.getAnimationIds().size() / 24f); i++) {
GeyserUtils.addProperty(id, "modelengine:anim" + i, Integer.class);
GeyserUtils.addProperty(id, namespace + ":" + "anim" + i, Integer.class);
}
}

View File

@@ -8,15 +8,15 @@ public class PackManifest {
{
"format_version": 1,
"header": {
"name": "ModelEngine",
"description": "ModelEngine For Geyser",
"name": "GeyserModelEngine",
"description": "GeyserModelEngine For Geyser",
"uuid": "%uuid-1%",
"version": [0, 0, 1]
},
"modules": [
{
"type": "resources",
"description": "ModelEngine",
"description": "GeyserModelEngine",
"uuid": "%uuid-2%",
"version": [0, 0, 1]
}

View File

@@ -19,7 +19,7 @@ public class RenderController {
}
// look, I'm fine with your other code and stuff, but I ain't using templates for JSON lmao
public String generate() {
public String generate(String namespace) {
List<String> se = new ArrayList<>(bones.keySet());
Collections.sort(se);
JsonObject root = new JsonObject();
@@ -155,7 +155,7 @@ public class RenderController {
if (entity.getModelConfig().isDisablePartVisibility()) {
visibilityItem.addProperty(boneName, true);
} else {
visibilityItem.addProperty(boneName, "math.mod(math.floor(query.property('modelengine:bone" + index / 24 + "') / " + n + "), 2) == 1");
visibilityItem.addProperty(boneName, "math.mod(math.floor(query.property('" + namespace + ":bone" + index / 24 + "') / " + n + "), 2) == 1");
}
partVisibility.add(visibilityItem);
if (!uvBonesId.contains("*")) {

View File

@@ -53,7 +53,7 @@ public class ResourcePackManager {
}
for (Entity entity : entityCache.values()) {
entity.register();
entity.register(extension.getConfigManager().getConfig().getString("models.namespace"));
}
}
@@ -203,7 +203,7 @@ public class ResourcePackManager {
if (renderPath.toFile().exists()) continue;
try {
Files.writeString(renderPath, controller.generate(), StandardCharsets.UTF_8);
Files.writeString(renderPath, controller.generate(extension.getConfigManager().getConfig().getString("models.namespace")), StandardCharsets.UTF_8);
} catch (IOException err) {
throw new RuntimeException(err);
}

View File

@@ -1,3 +1,5 @@
models:
namespace: "modelengine"
options:
resource-pack: