some improve

This commit is contained in:
zimzaza4
2024-04-21 14:00:30 +08:00
parent a20c2eb421
commit a768a4cc64
4 changed files with 8 additions and 5 deletions

View File

@@ -25,11 +25,13 @@ public class ExtensionMain implements Extension {
File[] files = source.listFiles(); File[] files = source.listFiles();
if (files != null) { if (files != null) {
for (File file : files) { for (File file : files) {
String id = "modelengine:" + file.getName(); String id = "modelengine:" + file.getName().toLowerCase();
GeyserUtils.addCustomEntity(id); GeyserUtils.addCustomEntity(id);
} }
} }
} }
@Subscribe @Subscribe
public void onPackLoad(GeyserLoadResourcePacksEvent event) { public void onPackLoad(GeyserLoadResourcePacksEvent event) {

View File

@@ -40,7 +40,7 @@ public class GeneratorMain {
if (file1.listFiles() == null) { if (file1.listFiles() == null) {
continue; continue;
} }
String modelId = file1.getName(); String modelId = file1.getName().toLowerCase();
entityMap.put(modelId, new Entity(modelId)); entityMap.put(modelId, new Entity(modelId));
for (File e : file1.listFiles()) { for (File e : file1.listFiles()) {
@@ -59,7 +59,6 @@ public class GeneratorMain {
} }
if (isGeometryFile(json)) { if (isGeometryFile(json)) {
System.out.println("G");
Geometry geometry = new Geometry(); Geometry geometry = new Geometry();
geometry.load(json); geometry.load(json);
geometry.setModelId(modelId); geometry.setModelId(modelId);

View File

@@ -66,8 +66,8 @@ public class Animation {
} }
if (name.startsWith("h_") || name.startsWith("hi_")) { if (name.startsWith("h_") || name.startsWith("hi_")) {
bones.add(name, new JsonParser().parse(HEAD_TEMPLATE)); bones.add(name, new JsonParser().parse(HEAD_TEMPLATE));
i++;
} }
i++;
} }
} }
if (i == 0) { if (i == 0) {
@@ -75,6 +75,7 @@ public class Animation {
} }
GeneratorMain.entityMap GeneratorMain.entityMap
.get(modelId).setHasHeadAnimation(true); .get(modelId).setHasHeadAnimation(true);
object.add("bones", bones); object.add("bones", bones);
json.get("animations").getAsJsonObject().add("animation." + modelId + ".look_at_target", object); json.get("animations").getAsJsonObject().add("animation." + modelId + ".look_at_target", object);
} }

View File

@@ -26,8 +26,9 @@ public class Entity {
"default": "%geometry%" "default": "%geometry%"
}, },
"animations": { "animations": {
"default": "animation.%geometry%.idle", "default": "animation.%entity_id%.idle",
"look_at_target": "%look_at_target%" "look_at_target": "%look_at_target%"
}, },
"scripts": { "scripts": {
"animate": [ "animate": [