diff --git a/ExampleMod/assets/examplemod/models/item/ruby_wand.json b/ExampleMod/assets/examplemod/models/item/ruby_wand.json
index 96deffd..e0cf652 100644
--- a/ExampleMod/assets/examplemod/models/item/ruby_wand.json
+++ b/ExampleMod/assets/examplemod/models/item/ruby_wand.json
@@ -1,5 +1,5 @@
{
- "parent": "item/handheld",
+ "parent": "minecraft:item/handheld",
"textures": {
"layer0": "examplemod:item/ruby_wand"
}
diff --git a/WeaveLoader.API/Assets/ModelResolver.cs b/WeaveLoader.API/Assets/ModelResolver.cs
index ae6a963..3e9192b 100644
--- a/WeaveLoader.API/Assets/ModelResolver.cs
+++ b/WeaveLoader.API/Assets/ModelResolver.cs
@@ -261,13 +261,36 @@ internal static class ModelResolver
}
string modRoot = ModContext.ModFolder ?? "";
- if (string.IsNullOrWhiteSpace(modRoot))
- return false;
+ if (!string.IsNullOrWhiteSpace(modRoot))
+ {
+ string file = Path.Combine(modRoot, "assets", ns, "models", rel.Replace('/', Path.DirectorySeparatorChar) + ".json");
+ if (File.Exists(file))
+ {
+ modelPath = file;
+ modelNamespace = ns;
+ return true;
+ }
- string file = Path.Combine(modRoot, "assets", ns, "models", rel.Replace('/', Path.DirectorySeparatorChar) + ".json");
- modelPath = file;
- modelNamespace = ns;
- return true;
+ if (TryGetSharedModelFilePath(ns, rel, out string sharedPath))
+ {
+ modelPath = sharedPath;
+ modelNamespace = ns;
+ return true;
+ }
+
+ modelPath = file;
+ modelNamespace = ns;
+ return true;
+ }
+
+ if (TryGetSharedModelFilePath(ns, rel, out string fallbackPath))
+ {
+ modelPath = fallbackPath;
+ modelNamespace = ns;
+ return true;
+ }
+
+ return false;
}
private static bool TryGetBlockStateFilePath(Identifier id, string? blockStateValue, out string blockStatePath)
@@ -440,9 +463,55 @@ internal static class ModelResolver
return false;
string relative = value.Replace('/', Path.DirectorySeparatorChar);
- string fullPath = Path.Combine(ModContext.ModFolder!, "assets", ns, "models", relative + ".json");
- modelPath = fullPath;
- modelNamespace = ns;
+ string? modRoot = ModContext.ModFolder;
+ if (!string.IsNullOrWhiteSpace(modRoot))
+ {
+ string fullPath = Path.Combine(modRoot!, "assets", ns, "models", relative + ".json");
+ if (File.Exists(fullPath))
+ {
+ modelPath = fullPath;
+ modelNamespace = ns;
+ return true;
+ }
+
+ if (TryGetSharedModelFilePath(ns, relative, out string sharedPath))
+ {
+ modelPath = sharedPath;
+ modelNamespace = ns;
+ return true;
+ }
+
+ modelPath = fullPath;
+ modelNamespace = ns;
+ return true;
+ }
+
+ if (TryGetSharedModelFilePath(ns, relative, out string fallbackPath))
+ {
+ modelPath = fallbackPath;
+ modelNamespace = ns;
+ return true;
+ }
+
+ return false;
+ }
+
+ private static bool TryGetSharedModelFilePath(string ns, string relative, out string modelPath)
+ {
+ modelPath = "";
+
+ if (!ns.Equals("minecraft", StringComparison.OrdinalIgnoreCase))
+ return false;
+
+ string? apiRoot = ModContext.ApiModFolder;
+ if (string.IsNullOrWhiteSpace(apiRoot))
+ return false;
+
+ string file = Path.Combine(apiRoot!, "assets", ns, "models", relative.Replace('/', Path.DirectorySeparatorChar) + ".json");
+ if (!File.Exists(file))
+ return false;
+
+ modelPath = file;
return true;
}
diff --git a/WeaveLoader.API/ModContext.cs b/WeaveLoader.API/ModContext.cs
index d53b3b2..2b26e60 100644
--- a/WeaveLoader.API/ModContext.cs
+++ b/WeaveLoader.API/ModContext.cs
@@ -4,4 +4,5 @@ public static class ModContext
{
public static string? ModId { get; internal set; }
public static string? ModFolder { get; internal set; }
+ public static string? ApiModFolder { get; internal set; }
}
diff --git a/WeaveLoader.API/WeaveLoader.API.csproj b/WeaveLoader.API/WeaveLoader.API.csproj
index 2f46deb..ea17638 100644
--- a/WeaveLoader.API/WeaveLoader.API.csproj
+++ b/WeaveLoader.API/WeaveLoader.API.csproj
@@ -17,8 +17,11 @@
+
+
+
diff --git a/WeaveLoader.API/mod_assets/minecraft/models/item/generated.json b/WeaveLoader.API/mod_assets/minecraft/models/item/generated.json
new file mode 100644
index 0000000..d92ce2a
--- /dev/null
+++ b/WeaveLoader.API/mod_assets/minecraft/models/item/generated.json
@@ -0,0 +1,30 @@
+{
+ "parent": "builtin/generated",
+ "gui_light": "front",
+ "display": {
+ "ground": {
+ "rotation": [ 0, 0, 0 ],
+ "translation": [ 0, 2, 0],
+ "scale": [ 0.5, 0.5, 0.5 ]
+ },
+ "head": {
+ "rotation": [ 0, 180, 0 ],
+ "translation": [ 0, 13, 7],
+ "scale": [ 1, 1, 1]
+ },
+ "thirdperson_righthand": {
+ "rotation": [ 0, 0, 0 ],
+ "translation": [ 0, 3, 1 ],
+ "scale": [ 0.55, 0.55, 0.55 ]
+ },
+ "firstperson_righthand": {
+ "rotation": [ 0, -90, 25 ],
+ "translation": [ 1.13, 3.2, 1.13],
+ "scale": [ 0.68, 0.68, 0.68 ]
+ },
+ "fixed": {
+ "rotation": [ 0, 180, 0 ],
+ "scale": [ 1, 1, 1 ]
+ }
+ }
+}
diff --git a/ExampleMod/assets/examplemod/models/item/handheld.json b/WeaveLoader.API/mod_assets/minecraft/models/item/handheld.json
similarity index 100%
rename from ExampleMod/assets/examplemod/models/item/handheld.json
rename to WeaveLoader.API/mod_assets/minecraft/models/item/handheld.json
diff --git a/WeaveLoader.Core/ModDiscovery.cs b/WeaveLoader.Core/ModDiscovery.cs
index 7a69bbe..28d55f0 100644
--- a/WeaveLoader.Core/ModDiscovery.cs
+++ b/WeaveLoader.Core/ModDiscovery.cs
@@ -26,6 +26,7 @@ internal static class ModDiscovery
var apiFolder = Path.Combine(modsPath, "WeaveLoader.API");
if (Directory.Exists(apiFolder))
{
+ ModContext.ApiModFolder = apiFolder;
var apiMod = new WeaveLoaderApiMod();
var attr = typeof(WeaveLoaderApiMod).GetCustomAttribute()!;
mods.Add(new DiscoveredMod(apiMod, attr, typeof(ModDiscovery).Assembly, apiFolder));