mirror of
https://github.com/Jacobwasbeast/LegacyWeaveLoader.git
synced 2026-07-11 13:19:18 +00:00
feat(api): add default minecraft item models
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
"parent": "item/handheld",
|
||||
"parent": "minecraft:item/handheld",
|
||||
"textures": {
|
||||
"layer0": "examplemod:item/ruby_wand"
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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; }
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@
|
||||
<Target Name="CopyModAssets" AfterTargets="Build">
|
||||
<MakeDir Directories="$(OutputPath)assets\weaveloader.api\textures\block" />
|
||||
<MakeDir Directories="$(OutputPath)assets\weaveloader.api\textures\item" />
|
||||
<MakeDir Directories="$(OutputPath)assets\minecraft\models\item" />
|
||||
<Copy SourceFiles="mod_assets\weaveloader.api\textures\block\missing_block.png" DestinationFolder="$(OutputPath)assets\weaveloader.api\textures\block\" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="mod_assets\weaveloader.api\textures\item\missing_item.png" DestinationFolder="$(OutputPath)assets\weaveloader.api\textures\item\" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="mod_assets\minecraft\models\item\generated.json" DestinationFolder="$(OutputPath)assets\minecraft\models\item\" SkipUnchangedFiles="true" />
|
||||
<Copy SourceFiles="mod_assets\minecraft\models\item\handheld.json" DestinationFolder="$(OutputPath)assets\minecraft\models\item\" SkipUnchangedFiles="true" />
|
||||
</Target>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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 ]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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<ModAttribute>()!;
|
||||
mods.Add(new DiscoveredMod(apiMod, attr, typeof(ModDiscovery).Assembly, apiFolder));
|
||||
|
||||
Reference in New Issue
Block a user