mirror of
https://github.com/GeyserExtensionists/GeyserModelEnginePackGenerator.git
synced 2025-12-19 15:09:18 +00:00
huh
This commit is contained in:
19
pom.xml
19
pom.xml
@@ -35,6 +35,10 @@
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>jitpack.io</id>
|
||||
<url>https://jitpack.io</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@@ -62,5 +66,20 @@
|
||||
<scope>system</scope>
|
||||
<systemPath>${project.basedir}/libs/geyserutils-geyser-1.0-SNAPSHOT.jar</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>me.rochblondiaux</groupId>
|
||||
<artifactId>blockbenchmodelreader</artifactId>
|
||||
<version>1.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.GeyserMC.PackConverter</groupId>
|
||||
<artifactId>bedrock-pack-schema</artifactId>
|
||||
<version>3d8150474d</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.github.GeyserMC.PackConverter</groupId>
|
||||
<artifactId>pack-schema-api</artifactId>
|
||||
<version>3d8150474d</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -14,13 +14,15 @@ import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class GeneratorMain {
|
||||
public static final Map<String, Entity> entityMap = new HashMap<>();
|
||||
public static final Map<String, Animation> animationMap = new HashMap<>();
|
||||
public static final Map<String, Geometry> geometryMap = new HashMap<>();
|
||||
public static final Map<String, Texture> textureMap = new HashMap<>();
|
||||
public static final Map<String, Animation> animationMap = new HashMap<>();
|
||||
public static final Map<String, Geometry> geometryMap = new HashMap<>();
|
||||
public static final Map<String, Map<String, Texture>> textureMap = new HashMap<>();
|
||||
public static final Gson GSON = new GsonBuilder().setPrettyPrinting()
|
||||
.create();
|
||||
|
||||
@@ -40,13 +42,23 @@ public class GeneratorMain {
|
||||
String modelId = folder.getName().toLowerCase();
|
||||
|
||||
Entity entity = new Entity(modelId);
|
||||
TextureConfig textureConfig = new TextureConfig();
|
||||
boolean canAdd = false;
|
||||
for (File e : folder.listFiles()) {
|
||||
if (e.isDirectory()) {
|
||||
generateFromFolder(currentPath + folder.getName() + "/", e);
|
||||
}
|
||||
if (e.getName().endsWith(".png")) {
|
||||
textureMap.put(modelId, new Texture(modelId, currentPath, e.toPath()));
|
||||
String textureName = e.getName().replace(".png", "");
|
||||
Set<String> bindingBones = new HashSet<>();
|
||||
bindingBones.add("*");
|
||||
if (!textureConfig.getBingingBones().containsKey(textureName)) {
|
||||
bindingBones = textureConfig.getBingingBones().get(textureName);
|
||||
}
|
||||
textureMap.computeIfAbsent(modelId, s -> new HashMap<>()).put(textureName, new Texture(modelId, currentPath, bindingBones, e.toPath()));
|
||||
if (!textureConfig.getBingingBones().isEmpty()) {
|
||||
textureConfig.getBingingBones().put(textureName, Set.of("*"));
|
||||
}
|
||||
}
|
||||
if (e.getName().endsWith(".json")) {
|
||||
try {
|
||||
@@ -136,6 +148,15 @@ public class GeneratorMain {
|
||||
materialsFolder.mkdirs();
|
||||
|
||||
File materialFile = new File(materialsFolder, "entity.material");
|
||||
|
||||
if (!materialFile.exists()) {
|
||||
try {
|
||||
Files.writeString(materialFile.toPath(),
|
||||
Material.TEMPLATE, StandardCharsets.UTF_8);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Animation> entry : animationMap.entrySet()) {
|
||||
Entity entity = entityMap.get(entry.getKey());
|
||||
@@ -179,7 +200,7 @@ public class GeneratorMain {
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Texture> entry : textureMap.entrySet()) {
|
||||
for (Map.Entry<String, Map<String, Texture>> entry : textureMap.entrySet()) {
|
||||
Path path = texturesFolder.toPath().resolve(entry.getValue().getPath() + entry.getKey() + ".png");
|
||||
path.toFile().getParentFile().mkdirs();
|
||||
|
||||
@@ -213,7 +234,7 @@ public class GeneratorMain {
|
||||
|
||||
String id = entity.getModelId();
|
||||
if (!geometryMap.containsKey(id)) continue;
|
||||
RenderController controller = new RenderController(id, geometryMap.get(id).getBones());
|
||||
RenderController controller = new RenderController(id, geometryMap.get(id).getBones(), entity);
|
||||
entity.setRenderController(controller);
|
||||
Path renderPath = new File(renderControllersFolder, "controller.render." + id + ".json").toPath();
|
||||
if (renderPath.toFile().exists()) {
|
||||
|
||||
@@ -11,6 +11,7 @@ import me.zimzaza4.geyserutils.geyser.GeyserUtils;
|
||||
import re.imc.geysermodelenginepackgenerator.GeneratorMain;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -26,13 +27,12 @@ public class Entity {
|
||||
"description": {
|
||||
"identifier": "modelengine:%entity_id%",
|
||||
"materials": {
|
||||
"default": "%material%"
|
||||
"default": "%material%",
|
||||
"anim": "entity_alphatest_anim_change_color"
|
||||
},
|
||||
"textures": {
|
||||
"default": "%texture%"
|
||||
},
|
||||
"geometry": {
|
||||
"default": "%geometry%"
|
||||
},
|
||||
"animations": {
|
||||
"look_at_target": "%look_at_target%"
|
||||
@@ -54,19 +54,13 @@ public class Entity {
|
||||
String modelId;
|
||||
JsonObject json;
|
||||
boolean hasHeadAnimation = false;
|
||||
@Setter
|
||||
@Getter
|
||||
Animation animation;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
Geometry geometry;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
RenderController renderController;
|
||||
|
||||
String path;
|
||||
Map<String, Texture> textureMap;
|
||||
TextureConfig textureConfig;
|
||||
|
||||
|
||||
Properties config = new Properties();
|
||||
|
||||
@@ -87,6 +81,14 @@ 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 jsonGeometry = description.get("geometry").getAsJsonObject();
|
||||
|
||||
for (String name : textureMap.keySet()) {
|
||||
jsonTextures.addProperty(name,"textures/entity/" + path + modelId + "/" + name);
|
||||
jsonGeometry.addProperty(name, "geometry.modelengine_" + modelId);
|
||||
}
|
||||
|
||||
JsonArray animate = description.get("scripts").getAsJsonObject().get("animate").getAsJsonArray();
|
||||
|
||||
if (animation != null) {
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package re.imc.geysermodelenginepackgenerator.generator;
|
||||
|
||||
public class Material {
|
||||
public static final String TEMPLATE = """
|
||||
{
|
||||
"materials":{
|
||||
"version":"1.0.0",
|
||||
"entity_alphatest_anim_change_color:entity_alphatest_change_color":{
|
||||
"+defines":[
|
||||
"USE_UV_ANIM"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
""";
|
||||
|
||||
}
|
||||
@@ -11,10 +11,12 @@ public class RenderController {
|
||||
public static final Set<String> NEED_REMOVE_WHEN_SORT = Set.of("pbody_", "plarm_", "prarm_", "plleg_", "prleg_", "phead_", "p_");
|
||||
String modelId;
|
||||
Set<String> bones;
|
||||
Entity entity;
|
||||
|
||||
public RenderController(String modelId, Set<String> bones) {
|
||||
public RenderController(String modelId, Set<String> bones, Entity entity) {
|
||||
this.modelId = modelId;
|
||||
this.bones = bones;
|
||||
this.entity = entity;
|
||||
}
|
||||
|
||||
// look, I'm fine with your other code and stuff, but I ain't using templates for JSON lmao
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.Set;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@@ -12,8 +13,7 @@ import java.nio.file.Path;
|
||||
public class Texture {
|
||||
|
||||
String modelId;
|
||||
|
||||
String path;
|
||||
Set<String> bindingBones;
|
||||
Path originalPath;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package re.imc.geysermodelenginepackgenerator.generator;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public class TextureConfig {
|
||||
|
||||
@SerializedName("binding_bones")
|
||||
Map<String, Set<String>> bingingBones = new HashMap<>();
|
||||
@SerializedName("anim_textures")
|
||||
Map<String, AnimTextureOptions> animTextures = new HashMap<>();
|
||||
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public static class AnimTextureOptions {
|
||||
boolean animUv;
|
||||
float fps;
|
||||
int frames;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user