per texture material

This commit is contained in:
zimzaza4
2024-10-20 18:56:05 +08:00
parent 42d92dd809
commit 68223acd38
3 changed files with 15 additions and 1 deletions

View File

@@ -76,8 +76,13 @@ public class Entity {
JsonObject description = json.get("minecraft:client_entity").getAsJsonObject().get("description").getAsJsonObject();
JsonObject jsonAnimations = description.get("animations").getAsJsonObject();
JsonObject jsonTextures = description.get("textures").getAsJsonObject();
JsonObject jsonMaterials = description.get("materials").getAsJsonObject();
JsonArray jsonRenderControllers = description.get("render_controllers").getAsJsonArray();
Map<String, String> materials = getModelConfig().getTextureMaterials();
materials.forEach(jsonMaterials::addProperty);
for (String name : textureMap.keySet()) {
jsonTextures.addProperty(name,"textures/entity/" + path + modelId + "/" + name);

View File

@@ -26,6 +26,12 @@ public class ModelConfig {
Map<String, Set<String>> bingingBones = new HashMap<>();
@SerializedName("anim_textures")
Map<String, AnimTextureOptions> animTextures = new HashMap<>();
@SerializedName("texture_materials")
Map<String, String> textureMaterials = new HashMap<>();
public Map<String, String> getTextureMaterials() {
return textureMaterials != null ? textureMaterials : Map.of();
}
@NoArgsConstructor
@AllArgsConstructor

View File

@@ -40,8 +40,11 @@ public class RenderController {
controller.addProperty("geometry", "Geometry.default");
JsonArray materials = new JsonArray();
String material = entity.getModelConfig().getTextureMaterials().get(key);
JsonObject materialItem = new JsonObject();
if (anim != null) {
if (material != null) {
materialItem.addProperty("*", "Material." + material);
} else if (anim != null) {
materialItem.addProperty("*", "Material.anim");
JsonObject uvAnim = new JsonObject();
controller.add("uv_anim", uvAnim);