Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,8 @@ public static void startGenerate(File source, File output) {
if (geo != null) {
entry.getValue().addHeadBind(geo);
}
Path path = animationsFolder.toPath().resolve(entry.getValue().getPath() + entry.getKey() + ".animation.json");
Path pathController = animationControllersFolder.toPath().resolve(entry.getValue().getPath() + entry.getKey() + ".animation_controllers.json");
Path path = animationsFolder.toPath().resolve(entry.getKey() + ".json");
Path pathController = animationControllersFolder.toPath().resolve(entry.getKey() + ".json");

pathController.toFile().getParentFile().mkdirs();
path.toFile().getParentFile().mkdirs();
Expand All @@ -294,7 +294,7 @@ public static void startGenerate(File source, File output) {

for (Map.Entry<String, Geometry> entry : geometryMap.entrySet()) {
entry.getValue().modify();
Path path = modelsFolder.toPath().resolve(entry.getValue().getPath() + entry.getKey() + ".geo.json");
Path path = modelsFolder.toPath().resolve(entry.getKey() + ".json");
path.toFile().getParentFile().mkdirs();
String id = entry.getValue().getGeometryId();

Expand All @@ -309,7 +309,7 @@ public static void startGenerate(File source, File output) {
String suffix = size[0] + "_" + size[1];
entry.getValue().setTextureWidth(size[0]);
entry.getValue().setTextureHeight(size[1]);
path = modelsFolder.toPath().resolve(entry.getValue().getPath() + entry.getKey() + "_" + suffix + ".geo.json");
path = modelsFolder.toPath().resolve(entry.getKey() + "_" + suffix + ".json");

entry.getValue().setId(id + "_" + suffix);

Expand Down Expand Up @@ -341,7 +341,7 @@ public static void startGenerate(File source, File output) {
for (Map.Entry<String, Map<String, Texture>> textures : textureMap.entrySet()) {

for (Map.Entry<String, Texture> entry : textures.getValue().entrySet()) {
Path path = texturesFolder.toPath().resolve(entry.getValue().getPath() + textures.getKey() + "/" + entry.getKey() + ".png");
Path path = texturesFolder.toPath().resolve(entry.getKey() + ".png");
path.toFile().getParentFile().mkdirs();

if (path.toFile().exists()) {
Expand All @@ -361,7 +361,7 @@ public static void startGenerate(File source, File output) {
Entity entity = entry.getValue();
entity.modify();

Path entityPath = entityFolder.toPath().resolve(entity.getPath() + entry.getKey() + ".entity.json");
Path entityPath = entityFolder.toPath().resolve(entry.getKey() + ".json");
entityPath.toFile().getParentFile().mkdirs();
if (entityPath.toFile().exists()) {
continue;
Expand All @@ -378,7 +378,7 @@ public static void startGenerate(File source, File output) {
if (!geometryMap.containsKey(id)) continue;
RenderController controller = new RenderController(id, geometryMap.get(id).getBones(), entity);
entity.setRenderController(controller);
Path renderPath = new File(renderControllersFolder, "controller.render." + id + ".json").toPath();
Path renderPath = new File(renderControllersFolder, "meg_" + id + ".json").toPath();
if (renderPath.toFile().exists()) {
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public void modify() {

json = new JsonParser().parse(TEMPLATE.replace("%entity_id%", modelId)
.replace("%geometry%", "geometry.meg_" + modelId)
.replace("%texture%", "textures/entity/" + path + modelId)
.replace("%texture%", "textures/entity/" + modelId)
.replace("%look_at_target%", modelConfig.isEnableHeadRotation() ? "animation." + modelId + ".look_at_target" : "animation.none")
.replace("%material%", modelConfig.getMaterial())).getAsJsonObject();

Expand All @@ -88,8 +88,8 @@ public void modify() {
materials.forEach(jsonMaterials::addProperty);

if (modelConfig.getPerTextureUvSize().isEmpty()) {
jsonGeometry.addProperty("default", "geometry.meg_" + modelId);
jsonTextures.addProperty("default", "textures/entity/" + path + modelId + "/" + textureMap.keySet().stream().findFirst().orElse("def"));
jsonGeometry.addProperty(modelId, "geometry.meg_" + modelId);
jsonTextures.addProperty("default", "textures/entity/" + modelId);
}

for (String name : textureMap.keySet()) {
Expand All @@ -100,11 +100,12 @@ public void modify() {
Integer[] size = modelConfig.getPerTextureUvSize().getOrDefault(name, new Integer[]{16, 16});
String suffix = size[0] + "_" + size[1];

jsonGeometry.addProperty("t_" + suffix, "geometry.meg_" + modelId + "_" + suffix);
jsonTextures.addProperty(name, "textures/entity/" + path + modelId + "/" + name);
jsonGeometry.addProperty(modelId + "_" + suffix, "geometry.meg_" + modelId + "_" + suffix);
jsonTextures.addProperty(name, "textures/entity/" + name);

}
jsonRenderControllers.add("controller.render." + modelId + "_" + name);
String controllerName = name.equals(modelId) ? "controller.render.meg_" + modelId : "controller.render.meg_" + modelId + "_" + name;
jsonRenderControllers.add(controllerName);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ public String generate() {

JsonObject controller = new JsonObject();

renderControllers.add("controller.render." + modelId + "_" + key, controller);
String controllerName = key.equals(modelId) ? "controller.render.meg_" + modelId : "controller.render.meg_" + modelId + "_" + key;
renderControllers.add(controllerName, controller);

if (!entity.getModelConfig().getPerTextureUvSize().isEmpty()) {
Integer[] size = entity.getModelConfig().getPerTextureUvSize().getOrDefault(key, new Integer[]{16, 16});
String suffix = "t_" + size[0] + "_" + size[1];
controller.addProperty("geometry", "Geometry." + suffix);
String suffix = size[0] + "_" + size[1];
controller.addProperty("geometry", "Geometry." + modelId + "_" + suffix);
} else {
controller.addProperty("geometry", "Geometry.default");
controller.addProperty("geometry", "Geometry." + modelId);
}
JsonArray materials = new JsonArray();
String material = entity.getModelConfig().getTextureMaterials().get(key);
Expand All @@ -71,7 +72,9 @@ public String generate() {
controller.add("uv_anim", uvAnim);
JsonArray offset = new JsonArray();
offset.add(0.0);
offset.add("math.mod(math.floor(q.life_time * " + anim.fps + ")," + anim.frames + ") / " + anim.frames);
// Cap fps at reasonable value (7.0 is standard for Bedrock animations)
double animFps = anim.fps > 60 ? 7.0 : anim.fps;
offset.add("math.mod(math.floor(q.life_time * " + animFps + ")," + anim.frames + ") / " + anim.frames);
uvAnim.add("offset", offset);
JsonArray scale = new JsonArray();
scale.add(1.0);
Expand Down