<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.isleward.com/index.php?action=history&amp;feed=atom&amp;title=Modding%3ASprites</id>
	<title>Modding:Sprites - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.isleward.com/index.php?action=history&amp;feed=atom&amp;title=Modding%3ASprites"/>
	<link rel="alternate" type="text/html" href="https://wiki.isleward.com/index.php?title=Modding:Sprites&amp;action=history"/>
	<updated>2026-05-03T14:48:03Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.35.1</generator>
	<entry>
		<id>https://wiki.isleward.com/index.php?title=Modding:Sprites&amp;diff=3947&amp;oldid=prev</id>
		<title>Kckckc: added guide for custom sprites</title>
		<link rel="alternate" type="text/html" href="https://wiki.isleward.com/index.php?title=Modding:Sprites&amp;diff=3947&amp;oldid=prev"/>
		<updated>2018-11-16T15:01:43Z</updated>

		<summary type="html">&lt;p&gt;added guide for custom sprites&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Sprites =&lt;br /&gt;
&lt;br /&gt;
'''Sprite''' is a generic term for any image in the game. Sprites are loaded on the client from spritesheets as textures to reduce load.&lt;br /&gt;
&lt;br /&gt;
== Custom Sprites ==&lt;br /&gt;
&lt;br /&gt;
Mods can add spritesheets to load.&lt;br /&gt;
First, they need to hook the &amp;lt;code&amp;gt;onBeforeGetResourceList&amp;lt;/code&amp;gt; event.&lt;br /&gt;
The event will be fired with an array of mappings (empty by default).&lt;br /&gt;
To load a spritesheet, push a string to the array.&lt;br /&gt;
If your images are in an &amp;lt;code&amp;gt;images&amp;lt;/code&amp;gt; directory inside a mod called &amp;lt;code&amp;gt;coolsprites&amp;lt;/code&amp;gt;, the path would look like &amp;lt;code&amp;gt;server/mods/coolsprites/images/myCoolSprites.png&amp;lt;/code&amp;gt;.&lt;br /&gt;
Notice how the path ends with &amp;lt;code&amp;gt;.png&amp;lt;/code&amp;gt;, and how it is relative to the &amp;lt;code&amp;gt;src&amp;lt;/code&amp;gt; directory, not just the server code.&lt;br /&gt;
&lt;br /&gt;
See the necromancer mod source code for an example of how to load images.&lt;br /&gt;
&lt;br /&gt;
=== Under the Hood ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;server/config/clientConfig.js&amp;lt;/code&amp;gt; fires the &amp;lt;code&amp;gt;onBeforeGetResourceList&amp;lt;/code&amp;gt; event.&lt;br /&gt;
Your mod hooks the event.&lt;br /&gt;
Your mod adds to the array.&lt;br /&gt;
ClientConfig saves that array.&lt;br /&gt;
&lt;br /&gt;
A user loads the client.&lt;br /&gt;
The client (&amp;lt;code&amp;gt;js/system/client&amp;lt;/code&amp;gt;) is initialized.&lt;br /&gt;
After initializing, &amp;lt;code&amp;gt;onClientReady&amp;lt;/code&amp;gt; is called.&lt;br /&gt;
That method sends a request to &amp;lt;code&amp;gt;clientConfig&amp;lt;/code&amp;gt; and calls &amp;lt;code&amp;gt;getResourcesList&amp;lt;/code&amp;gt;.&lt;br /&gt;
The clientConfig sends back the array configured by your mod earlier.&lt;br /&gt;
The client receives the list, and initializes &amp;lt;code&amp;gt;js/resources&amp;lt;/code&amp;gt; with the list.&lt;br /&gt;
Resources adds the list of sprites to the core game's sprite list.&lt;br /&gt;
&lt;br /&gt;
After that, resources loads the images.&lt;br /&gt;
If an image path includes &amp;lt;code&amp;gt;png&amp;lt;/code&amp;gt;, the raw path is used and if configured correctly in the mod, the server will send through the correct file.&lt;br /&gt;
Otherwise, the image is loaded from the client code's image directory with &amp;lt;code&amp;gt;.png&amp;lt;/code&amp;gt; appended to the path.&lt;br /&gt;
&lt;br /&gt;
After loading all the sprites, resources emits an event that calls start on &amp;lt;code&amp;gt;main.js&amp;lt;/code&amp;gt;.&lt;br /&gt;
This starts everything else, such as the ui factory, the input handler, and the renderer.&lt;br /&gt;
&lt;br /&gt;
When the renderer is started, it prepares Pixi.js and configures everything it needs.&lt;br /&gt;
It has a list of spriteNames and then it gets the list from the resource list.&lt;br /&gt;
It adds any that were in the resource list that contain &amp;lt;code&amp;gt;.png&amp;lt;/code&amp;gt;.&lt;br /&gt;
This is why it is necessary to include png: the renderer only additionally loads sprites with .png.&lt;br /&gt;
The renderer then creates a texture from each sprite, and uses the textures created for a lot of rendering magic that I'm not going to touch.&lt;/div&gt;</summary>
		<author><name>Kckckc</name></author>
	</entry>
</feed>