修复些问题, 优化了下配置
This commit is contained in:
parent
600d628dec
commit
b3a7f94133
27
build.gradle
27
build.gradle
|
|
@ -29,11 +29,17 @@ subprojects {
|
|||
// Loom adds the essential maven repositories to download Minecraft and libraries from automatically.
|
||||
// See https://docs.gradle.org/current/userguide/declaring_repositories.html
|
||||
// for more information about repositories.
|
||||
maven { url = 'https://maven.parchmentmc.org' }
|
||||
}
|
||||
loom {
|
||||
silentMojangMappingsLicense()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
minecraft "net.minecraft:minecraft:$rootProject.minecraft_version"
|
||||
mappings loom.officialMojangMappings()
|
||||
mappings loom.layered() {
|
||||
officialMojangMappings()
|
||||
parchment ("org.parchmentmc.data:parchment-1.20.1:2023.09.03@zip")
|
||||
}
|
||||
}
|
||||
|
||||
java {
|
||||
|
|
@ -50,7 +56,22 @@ subprojects {
|
|||
it.options.encoding = "UTF-8"
|
||||
it.options.release = 17
|
||||
}
|
||||
|
||||
def resourceTargets=["fabric.mod.json",'META-INF/mods.toml'];
|
||||
def replaceProperties = [
|
||||
mod_name: mod_name,
|
||||
mod_version: mod_version,
|
||||
mod_source:mod_source,
|
||||
mod_credits:mod_credits,
|
||||
mod_authors: mod_authors,
|
||||
mod_description: mod_description,
|
||||
mod_licence:mod_licence,
|
||||
group:maven_group]
|
||||
processResources{
|
||||
inputs.properties replaceProperties
|
||||
filesMatching(resourceTargets) {
|
||||
expand replaceProperties
|
||||
}
|
||||
}
|
||||
// Configure Maven publishing.
|
||||
publishing {
|
||||
publications {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
package com.leisuretimedock.jsonem.platform;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public interface IPlatFormHelper {
|
||||
boolean shouldDumpModels();
|
||||
Path getDumpModelsPath();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.google.gson.Gson;
|
|||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.leisuretimedock.jsonem.JsonEm;
|
||||
import com.leisuretimedock.jsonem.platform.Services;
|
||||
import com.leisuretimedock.jsonem.serialization.JsonEMCodecs;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
|
|
@ -12,7 +13,6 @@ import net.minecraft.client.model.geom.ModelLayers;
|
|||
import net.minecraft.client.model.geom.builders.LayerDefinition;
|
||||
import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.server.packs.resources.ResourceManager;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
|
@ -23,7 +23,7 @@ import java.util.Map;
|
|||
import java.util.Optional;
|
||||
|
||||
public class JsonEntityModelUtil {
|
||||
public static Path DUMP_DIR;
|
||||
|
||||
public static final Gson GSON = new Gson();
|
||||
|
||||
public static Optional<LayerDefinition> readJson(InputStream data) {
|
||||
|
|
@ -52,12 +52,13 @@ public class JsonEntityModelUtil {
|
|||
}
|
||||
|
||||
public static void dump(ModelLayerLocation layer, LayerDefinition data) throws IOException {
|
||||
if (!Files.exists(DUMP_DIR)) {
|
||||
Files.createDirectories(DUMP_DIR);
|
||||
Path dumpModelsPath = Services.PLATFORM.getDumpModelsPath();
|
||||
if (!Files.exists(dumpModelsPath)) {
|
||||
Files.createDirectories(dumpModelsPath);
|
||||
}
|
||||
|
||||
var modelResult = JsonEMCodecs.TEXTURED_MODEL_DATA.encode(data, JsonOps.INSTANCE, new JsonObject());
|
||||
var modelFolder = DUMP_DIR.resolve("assets").resolve(layer.getModel().getNamespace()).resolve("models").resolve("entity").resolve(layer.getModel().getPath());
|
||||
var modelFolder = dumpModelsPath.resolve("assets").resolve(layer.getModel().getNamespace()).resolve("models").resolve("entity").resolve(layer.getModel().getPath());
|
||||
var modelFile = modelFolder.resolve(layer.getLayer()+".json");
|
||||
|
||||
if (!Files.exists(modelFolder)) {
|
||||
|
|
|
|||
|
|
@ -2,10 +2,18 @@ package com.leisuretimedock.jsonem.fabric.platform;
|
|||
|
||||
import com.leisuretimedock.jsonem.fabric.JsonEmFabric;
|
||||
import com.leisuretimedock.jsonem.platform.IPlatFormHelper;
|
||||
import net.fabricmc.loader.api.FabricLoader;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class FabricPlatformHelper implements IPlatFormHelper {
|
||||
@Override
|
||||
public boolean shouldDumpModels() {
|
||||
return "true".equals(JsonEmFabric.CONFIG.values.getProperty("dump_models"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getDumpModelsPath() {
|
||||
return FabricLoader.getInstance().getGameDir().resolve("jsonem_dump");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,17 @@
|
|||
{
|
||||
"schemaVersion": 1,
|
||||
"id": "jsonem",
|
||||
"version": "${version}",
|
||||
"name": "JsonEM_Neo_Forge_1_20_1",
|
||||
"description": "Migrate from Fabric 1.20.1",
|
||||
"version": "${mod_version}",
|
||||
"name": "${mod_name}",
|
||||
"description": "${mod_description}",
|
||||
"authors": [
|
||||
"FoundationGames",
|
||||
"R3944Realms"
|
||||
"${mod_authors}"
|
||||
],
|
||||
"contact": {
|
||||
"homepage": ""
|
||||
"homepage": "",
|
||||
"sources": "${mod_source}"
|
||||
},
|
||||
"license": "MIT",
|
||||
"license": "${mod_licence}",
|
||||
"icon": "assets/jsonem/icon.png",
|
||||
"environment": "*",
|
||||
"entrypoints": {
|
||||
|
|
|
|||
6
fabric/src/main/resources/pack.mcmeta
Normal file
6
fabric/src/main/resources/pack.mcmeta
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "jsonem resources",
|
||||
"pack_format": 15
|
||||
}
|
||||
}
|
||||
|
|
@ -2,10 +2,18 @@ package com.leisuretimedock.jsonem.forge.platform;
|
|||
|
||||
import com.leisuretimedock.jsonem.forge.config.JsonEmConfig;
|
||||
import com.leisuretimedock.jsonem.platform.IPlatFormHelper;
|
||||
import net.minecraftforge.fml.loading.FMLPaths;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ForgePlatformHelper implements IPlatFormHelper {
|
||||
@Override
|
||||
public boolean shouldDumpModels() {
|
||||
return JsonEmConfig.INSTANCE.DUMP_MODELS.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Path getDumpModelsPath() {
|
||||
return FMLPaths.GAMEDIR.get().resolve("jsonem_dump");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +1,17 @@
|
|||
modLoader = "javafml"
|
||||
loaderVersion = "[47,)"
|
||||
#issueTrackerURL = ""
|
||||
license = "MIT"
|
||||
license = "${mod_licence}"
|
||||
|
||||
[[mods]]
|
||||
modId = "jsonem"
|
||||
version = "${version}"
|
||||
displayName = "JsonEM_Neo_Forge_1_20_1"
|
||||
authors = "FoundationGames, R3944Realms"
|
||||
version = "${mod_version}"
|
||||
displayName = "${mod_name}"
|
||||
credits = "${mod_credits}"
|
||||
authors = "${mod_authors}"
|
||||
description = '''
|
||||
Migrate from Fabric 1.20.1
|
||||
'''
|
||||
${mod_description}
|
||||
'''
|
||||
logoFile = "assets/jsonem/icon.png"
|
||||
|
||||
[[dependencies.jsonem]]
|
||||
|
|
|
|||
6
forge/src/main/resources/pack.mcmeta
Normal file
6
forge/src/main/resources/pack.mcmeta
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"pack": {
|
||||
"description": "jsonem resources",
|
||||
"pack_format": 15
|
||||
}
|
||||
}
|
||||
|
|
@ -2,7 +2,14 @@
|
|||
org.gradle.jvmargs=-Xmx2G
|
||||
org.gradle.parallel=true
|
||||
# Mod properties
|
||||
mod_id=jsonem
|
||||
mod_name=jsonEM
|
||||
mod_version=1.0-SNAPSHOT
|
||||
mod_source=https://github.com/LeisureTimeDock/JsonEM_Neo_Forge
|
||||
mod_credits=
|
||||
mod_authors= FoundationGames, R3944Realms
|
||||
mod_description=Migrate from Fabric 1.20.1
|
||||
mod_licence=MIT
|
||||
maven_group=com.leisuretimedock
|
||||
archives_name=jsonem_neo_forge_1_20_1
|
||||
enabled_platforms=fabric,neoforge
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ pluginManagement {
|
|||
repositories {
|
||||
maven { url "https://maven.fabricmc.net/" }
|
||||
maven { url "https://maven.architectury.dev/" }
|
||||
maven { url "https://maven.minecraftforge.net/" }
|
||||
maven { url "https://files.minecraftforge.net/maven/" }
|
||||
gradlePluginPortal()
|
||||
}
|
||||
|
|
@ -13,6 +14,3 @@ include 'common'
|
|||
include 'fabric'
|
||||
include 'forge'
|
||||
|
||||
project(':common').projectDir = file('common')
|
||||
project(':forge').projectDir = file('forge')
|
||||
project(':fabric').projectDir = file('fabric')
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user