ZephaniahNoah
Terrarian
According to this guide, showing how a glowmask is applied to dropped items, it is not easy to add a glowmask to "weapons being held" in the current version of tModLoader. However, this library makes it easy for developers to add a glow mask to their items. Simply add the GlowMaskAPI.dll file to your references. And add modReferences = GlowMaskAPI to your build.txt...
Below is an example of how you would use GlowMaskAPI to add a glow mask to a sword.
ExampleSwordGlow.png would be your glowmask.
Note that AddGlowMask is happening inside SetStaticDefaults. We are not doing this in SetDefaults because it runs several times while the game is running. We only need to load the texture once.
Also, regarding the guide I mentioned at the beginning, there is no need to use the PostDrawInWorld hook they suggest to add a glowmask to dropped items. This library will add a glowmask to your item regardless of where it is.
Anyone playing your mod will also need to download and enable GlowMaskAPI from the mod browser.
GlowMaskAPI may be incompatible with other mods that use hacky methods to apply glowmasks.
In the future I would like to improve GlowMaskAPI allowing users to apply a glowmask with only one line of code instead of three.
Latest version: 1.6
Below is an example of how you would use GlowMaskAPI to add a glow mask to a sword.
Code:
namespace ExampleMod.Items
{
public class ExampleSword : ModItem
{
public static short glowMask;
public override void SetStaticDefaults()
{
DisplayName.SetDefault("Example Sword");
if (Main.netMode != NetmodeID.Server)
glowMask=GlowMaskAPI.Tools.instance.AddGlowMask(mod.GetTexture("Items/ExampleSwordGlow"));
}
public override void SetDefaults()
{
item.damage=20;
item.melee=true;
item.width=64;
item.height=64;
item.useTime=30;
item.useAnimation=30;
item.useStyle=1;
item.glowMask=glowMask;
}
}
}
Note that AddGlowMask is happening inside SetStaticDefaults. We are not doing this in SetDefaults because it runs several times while the game is running. We only need to load the texture once.
Also, regarding the guide I mentioned at the beginning, there is no need to use the PostDrawInWorld hook they suggest to add a glowmask to dropped items. This library will add a glowmask to your item regardless of where it is.
Anyone playing your mod will also need to download and enable GlowMaskAPI from the mod browser.
GlowMaskAPI may be incompatible with other mods that use hacky methods to apply glowmasks.
In the future I would like to improve GlowMaskAPI allowing users to apply a glowmask with only one line of code instead of three.
Latest version: 1.6
Last edited: