Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/1.21.0' into 1.21.0
Browse files Browse the repository at this point in the history
  • Loading branch information
HappyRespawnanchor committed Nov 9, 2024
2 parents a2c394b + e8d2b76 commit 691f82b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,25 @@

package org.ayamemc.ayame.model.resource;

import org.ayamemc.ayame.model.AyameModelType;
import org.ayamemc.ayame.model.IndexData;
import org.ayamemc.ayame.util.TODO;

import java.io.File;
import java.nio.file.Path;
import java.util.List;

public interface IModelResource {
// TODO 完成
IndexData.ModelMetaData getMetaData();

public static IModelResource fromFile(File file){
List<IndexData.ModelData> getModels();

default IndexData.ModelData getDefault() {
return getModels().getFirst();
}

static IModelResource fromFile(File file){
throw new TODO("create model from file");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

package org.ayamemc.ayame.model.resource;

import org.ayamemc.ayame.model.IndexData;
import org.ayamemc.ayame.util.JsonInterpreter;
import org.ayamemc.ayame.util.TODO;

import java.util.HashMap;
Expand Down Expand Up @@ -58,7 +58,7 @@ public static IModelResource create(String format, ModelFile modelFile) {
* @return 模型实例
*/
public static IModelResource create(ModelFile modelFile){
return create(modelFile.getIndexData().metaData().format(), modelFile);
return create(modelFile.getFormat(), modelFile);
}

/**
Expand All @@ -76,7 +76,7 @@ public static boolean contains(String name){
* @return 是否支持被读取
*/
public static boolean contains(ModelFile modelFile){
return contains(modelFile.getIndexData().metaData().format());
return contains(modelFile.getFormat());
}

@FunctionalInterface
Expand All @@ -87,8 +87,12 @@ public interface ResourceFactory {

public static class ModelFile{
// TODO 这里起暂时的占位符作用,后面请修改它
public IndexData getIndexData(){
public JsonInterpreter getIndexJson(){
throw new TODO("Model File");
}

public String getFormat(){
return getIndexJson().getString("format");
}
}
}
48 changes: 12 additions & 36 deletions examples/test/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@
"vanilla-like"
]
},
"default": {
"name": "默认",
"model": "models/def_model.json",
"animation": "animations/def_anim.json",
"texture": "textures/def_tex.json",
"arm": "animations/arm.json",
"controllers": [
"ayame:default"
]
},
"presets": [
"models": [
{
"name": "默认",
"model": "models/def_model.json",
"animation": "animations/def_anim.json",
"texture": "textures/def_tex.json",
"arm": "animations/arm.json",
"controllers": [
"ayame:default"
]
},
{
"name": "预设1",
"model": "models/def_model.json",
Expand All @@ -36,29 +36,5 @@
"ayame:default"
]
}
],
"注释(别管这么多啦,这是咱开发时用的)": {
"presets": [
{
"name": "预设1",
"model": "models/preset1_model.json",
"animation": "animations/preset1_anim.json",
"texture": "textures/preset1_tex.json",
"arm": "animations/arm.json",
"controllers": [
"ayame:default"
]
},
{
"name": "预设2",
"model": "models/preset2_model.json",
"animation": "animations/preset2_anim.json",
"texture": "textures/preset2_tex.json",
"arm": "animations/arm.json",
"controllers": [
"ayame:default"
]
}
]
}
]
}

0 comments on commit 691f82b

Please sign in to comment.