Coding Help Please Help Me!

Athos

Cowpoke
Hope that Coding Help is a correct section.
I am trying to make my first Mod. The first step is to add two furniture. But!
SMAPI always warn me like: [game] Failed loading texture C:\Users\18316\AppData\Roaming\Stardrop\Data\Selected Mods\MorticianMod\assets for item (F)Athos.MorticianMod/MorticianPainting: asset doesn't exist.
I am not sure that what's the problem.
The Code is not long.Only 200 lines. The Log is written by Chinese, but that's not important.
I have copy the asset to Mods folder Mods/MorticianMod/assets/furniture/xxxxx.png like that.

Another question: How to add secret_notes? Should I add relevant Data/Object?
 

Attachments

Athos

Cowpoke
using Microsoft.Xna.Framework.Graphics;
using StardewModdingAPI;
using StardewModdingAPI.Events;

public class ModEntry : Mod
{
private string FurnitureTexturePath => "FurTest";
private bool _dataModified = false;

public override void Entry(IModHelper helper)
{
helper.Events.Content.AssetRequested += OnAssetRequested;
}

private void OnAssetRequested(object sender, AssetRequestedEventArgs e)
{
Monitor.Log($"请求资源:|>{e.NameWithoutLocale}<|", LogLevel.Info);
if (e.NameWithoutLocale.IsEquivalentTo("Data/Furniture"))
e.Edit(EditFurnitureData);
else if (e.NameWithoutLocale.IsEquivalentTo("FurTest"))
{
Monitor.Log($"尝试请求{e.NameWithoutLocale}", LogLevel.Alert);
e.LoadFromModFile<Texture2D>("assets/furniture/myfurniture.png", AssetLoadPriority.Medium);
}
}
private void EditFurnitureData(IAssetData asset)
{
if (_dataModified) return;

var data = asset.AsDictionary<string, string>().Data;

string baseId = $"{ModManifest.UniqueID}_Furniture";
string newId = baseId;
int counter = 1;
while (data.ContainsKey(newId))
newId = $"{baseId}{counter++}";

string entry = "My Custom Furniture/decor/1 1/1 1/1/100/2/我的自定义家具/0/" + FurnitureTexturePath + "/false/";
data[newId] = entry;
_dataModified = true;
Monitor.Log($"Added furniture '{newId}'");
}
}


Guys! I resolve it. my string entry lost a field before. It lead to path error. I try at least ten different path, Then I found the problem.

I mean the field "texture" is effective . you can use it to set a custom path to load your png file!
 
Top