Changing a PNG file to XNB

Ninjamaster247

Newcomer
i've got a PNG file i need to convert to XNB, its for a sprite change, but i don't know how, i have the mods if needed for clearification
 

Thaddeus_

Sodbuster
From what I've read you just need to make a content pack and it should work fine. May be wrong though, I am still figuring out what I am doing with modding SDV.
 

mouse

Farmer
To expand on the above posts, replacing any of the game files entirely is not recommended for a lot of reasons -- overwriting game files in general is meh, you can lose your changes in game updates, you have no choice but to replace entire files and so conflict with any other mod ever that wants to make changes to it, they're old and likely broken, etc. You can read more here if you're interested.

We have nicer ways of doing it now, and the simplest is with a pack for Content Patcher. It can be a little confusing at first, especially if you try to take in the whole author guide at once, because it can do a lot of things that just replacing the XNB never could (like replacing only a specific sprite on the whole sheet, only at certain times or in certain locations, or after you have x hearts or etc), even if you don't need it to. It's not magic, so it's totally possible to have a highly incompatible CP pack that still loads a whole file (even an XNB file, if you want) and conflicts with all the other mods BUT...

... even the worst pack for Content Patcher will show up in a SMAPI log, and in commands like CP's patch summary which is a helpful list of all the the changes made to different files. This is lifesaving when something goes wrong, and/or you need to ask for help. If you search DIYCP on the Nexus, you can find some template packs where you can just replace the images with the ones you want instead, or you could find some specific pack that does exactly what you want and change that (e.g. a farmhouse texture mod specifically).

This basic example in the docs shows how you'd replace the dinosaur sprite with one of your own. There are lots of little CP packs on the Nexus that just replace specific sprites, too. If you want (and it's SFW/doesn't otherwise break the site rules), you can upload the png you want to use and I can convert it to a CP pack for you, and maybe that will help for the next time.

As far as the original question goes, if you really need to re-pack an XNB for some reason, I'd just unpack the target file, replace the png, then repack (by running pack instead of unpack), so the metadata is already there for repacking. It's best avoided if it can be helped, though, and safest to just leave the entire Content folder untouched.
 
Top