Thorium Mod Wiki
Advertisement

Mod Calls are special functions provided by tModLoader that mod creators can use to interact with the Thorium Mod in certain ways. They are accessible through Mod.Call and a given call name; for more details, see the tModLoader wiki. This page lists the mod call functions Thorium Mod currently adds, along with examples and what they are used for.

Contents

Important Information[]

  • A Thorium Mod Mod.Call will never raise an exception that propagates beyond the call. If an internal exception occurs, it will be logged (client/server.log) and the call will return null.
  • Mod.Calls that have primitive return types (bool, int etc.) can still return null as mentioned above, see the examples for handling such cases.
  • Mod.Calls that have no return value will return true if the operation/s was/were successful.
  • For best results, add loadAfter = ThoriumMod into your mod's build.txt so that the calls return their true value regardless of mod update order.
    • For example, Thorium Mod updates many of its Player values in the ModPlayer.PostUpdateEquips hook. Accessing these values in hooks that run prior to this will return a possibly "outdated" value. Accessing them inside the hook will only return a guaranteed "final" value if loadAfter = ThoriumMod is added. Accessing them in a later hook (such as ModPlayer.PostUpdate) will work regardless, but may limit you otherwise.
  • Calls that have a "register" nature (such as AddMartianItemID) usually go into Mod.PostSetupContent or an appropriate SetStaticDefaults hook.

Examples[]

To preface, most examples will be listed like this:

Mod thoriumMod = ModLoader.GetMod("ThoriumMod");
if (thoriumMod != null)
{
    //Example here
}

These examples will show you how to handle the different ways a call returns values.

No return[]

The simplest calls are those that do not return anything of direct use, but they just change a stat.

thoriumMod.Call("BonusBardDamage", player, 0.5f); //Increase bard damage by 50%

"No return" calls actually do return a bool with value true to indicate if the operation was successful, use it when you think you need it.

Simple return[]

Calls that return a value need to be handled properly to prevent crashes.

object result = thoriumMod.Call("GetHealBonus", player);
if (result is int healBonus)
{
   //healBonus now contains the player's healing bonus
   //The general pattern is: if (<return value of the call> is <return type of the call> <variable name of your choice>)
}

ValueTuple return[]

Some more complex calls have to return more than one value, realized through ValueTuples.

object result = thoriumMod.Call("IsSymphonicWeapon", item);
if (result is ValueTuple<bool, byte> tuple)
{
    //tuple.Item1 is bool, representing if the given item is a bard weapon or not
    //tuple.Item2 is byte, representing its specific weapon archetype
}

Bestiary Aquatic Depths.pngGetAquaticDepthsBounds[]

Returns the tile coordinate boundaries for the Aquatic Depths generated on world creation.

Parameters[]

  • None.

Return value[]

  • Rectangle consisting of the boundary's upper-left coordinates on the world map, along with its width and height. Note the Aquatic Depths are only generated after the "Micro Biomes" vanilla step, and calling GetAquaticDepthsBounds before will return Rectangle.Empty.

Bestiary Blood Chamber.pngGetBloodChamberBounds[]

Returns the tile coordinate boundaries for the Blood Chamber generated on world creation.

Parameters[]

  • None.

Return value[]

  • Rectangle consisting of the boundary's upper-left coordinates on the world map, along with its width and height. Note the Blood Chamber is only generated after the "Micro Biomes" vanilla step, and calling GetBloodChamberBounds before will return Rectangle.Empty.

Bestiary Blood Chamber.pngGetBloodAltarPosition[]

Returns the world coordinates for the Blood Altar generated on world creation, which the Grim Pointer points to.

Parameters[]

  • None.

Return value[]

  • Vector2 of the Blood Altar's coordinates on the world. Note the Blood Altar is only generated after the "Micro Biomes" vanilla step, and calling GetBloodAltarPosition before will return -Vector2.One.

Silver Spear Tip.pngAddSpearItemID[]

Registers a modded Item (preferably a spear) to the SpearItemIDCache, allowing it to function with the Silver Spear Tip, Molten Spear Tip, and Crystal Spear Tip. You cannot add a vanilla or Thorium Mod Item to this.

Parameters[]

  • int representing the Item type to be registered to the cache.

Return value[]

  • bool which is true if the addition was successful; else, it is false.

Silver Spear Tip.pngIsSpearItemID[]

Checks if the inputted Item is registered to SpearItemIDCache.

Parameters[]

  • int representing the Item type to check.

Return value[]

  • bool which is true if it is registered; else, it is false.

Iron Flail-Core.pngAddFlailProjectileID[]

Registers a custom Projectile (preferably a thrown flail projectile) to the FlailProjectileIDCache, allowing it to function with the Iron Flail-Core, Cursed Flail-Core, and Vile Flail-Core. You cannot add a vanilla or Thorium Mod Item to this.

Parameters[]

  • int representing the Projectile type to be registered to the cache.

Return value[]

  • bool which is true if the addition was successful; else, it is false.

Iron Flail-Core.pngIsFlailProjectileID[]

Checks if the inputted Projectile is registered to FlailProjectileIDCache.

Parameters[]

  • int representing the Projectile type to check.

Return value[]

  • bool which is true if it is registered; else, it is false.

Conduit Suit.pngAddMartianItemID[]

Registers a custom Item (preferably a weapon from the Martian Madness event) to the MartianItemIDCache, allowing it to benefit from Conduit armor's damage bonus to martian weapons. You cannot add a vanilla or Thorium Mod Item to this.

Parameters[]

  • int representing the Item type to be registered to the cache.

Return value[]

  • bool which is true if the addition was successful; else, it is false.

Conduit Suit.pngIsMartianItemID[]

Checks if the inputted Item is registered to MartianItemIDCache.

Parameters[]

  • int representing the Item type to check.

Return value[]

  • bool which is true if it is registered; else, it is false.

Bard Emblem.pngIsSymphonicWeapon[]

Checks if the inputted Item is a Bard weapon.

Parameters[]

  • int representing the Item type to check.

Return value[]

  • ValueTuple with the values:
    • Item1: bool which is true if it is of the BardItem type and has a damage value greater than 0; else, it is false.
    • Item2: byte representing the instrument type the BardItem belongs to [1].

Bard Emblem.pngIsSymphonicProjectile[]

Checks if the inputted Projectile belongs to a Bard weapon.

Parameters[]

  • int representing the Projectile type to check.

Return value[]

  • ValueTuple with the values:
    • Item1: bool which is true if it is of the BardProjectile type; else, it is false.
    • Item2: byte representing the instrument type the BardProjectile belongs to [1].

Bestiary Aquatic Depths.pngGetZoneAquaticDepths[]

Checks if the player is in or close to the Aquatic Depths biome for its respective enemies to spawn.

Parameters[]

  • Player to check its biome for.

Return value[]

  • bool which is true if the player is in or close to the biome; else, it is false.

Bestiary Granite.pngGetZoneGranite[]

Checks if the player is in or close to the Granite Cave biome for its respective enemies to spawn. This is an "extension" of vanilla since it is lacking such a variable in its code. Use this if you want to avoid setting up the biome detection yourself.

Parameters[]

  • Player to check its biome for.

Return value[]

  • bool which is true if the player is in or close to the biome; else, it is false.

Bestiary Marble.pngGetZoneMarble[]

Checks if the player is in or close to the Marble Cave biome for its respective enemies to spawn. This is an "extension" of vanilla since it is lacking such a variable in its code. Use this if you want to avoid setting up the biome detection yourself.

Parameters[]

  • Player to check its biome for.

Return value[]

  • bool which is true if the player is in or close to the biome; else, it is false.

Bard Emblem.pngBonusBardDamage[]

Adds to the player's symphonic damage multiplier by a provided amount (i.e. +=).

Parameters[]

  • Player that will have its symphonic damage increased.
  • float value to increase the player's symphonic damage multiplier by.

Return value[]

  • None.

Bard Emblem.pngBonusBardDamageMult[]

Multiplies to the player's symphonic damage multiplier by a provided amount (i.e. *=).

Parameters[]

  • Player that will have its symphonic damage increased.
  • float value to multiply the player's symphonic damage multiplier by.

Return value[]

  • None.

Bard Emblem.pngBonusBardDamageFlat[]

Adds a flat symphonic damage bonus calculated after the normal damage formula.

Parameters[]

  • Player that will have its symphonic damage increased.
  • int value to add flat symphonic damage by.

Return value[]

  • None.

Bard Emblem.pngBonusBardCrit[]

Adds to the player's symphonic critical strike chance by a provided amount.

Parameters[]

  • Player that will have its symphonic critical strike chance increased.
  • int value to increase the player's symphonic critical strike chance by.

Return value[]

  • None.

Bard Emblem.pngBonusBardSpeed[]

Adds to the player's symphonic playing speed by a provided amount.

Parameters[]

  • Player that will have its symphonic playing speed increased.
  • float value to increase the player's symphonic playing speed by.

Return value[]

  • None.

Bard Emblem.pngBonusBardEmpowermentRange[]

Adds to the player's empowerment range by a provided amount.

Parameters[]

  • Player that will have its empowerment range increased.
  • int value to increase the player's empowerment range by.

Return value[]

  • None.

Bard Emblem.pngBonusBardEmpowermentDuration[]

Adds to the player's empowerment duration by a provided amount.

Parameters[]

  • Player that will have its empowerment duration increased.
  • short value to increase the player's empowerment duration by.

Return value[]

  • None.

Bard Emblem.pngBonusBardInspirationMax[]

Adds to the player's maximum inspiration by a provided amount.

Parameters[]

  • Player that will have its maximum inspiration increased.
  • int value to increase the player's maximum inspiration by.[2]

Return value[]

  • None.

Bard Emblem.pngGetBardDamageMods[]

Returns the player's symphonic damage bonuses.

Parameters[]

  • Player to check symphonic damage bonuses.

Return value[]

  • ValueTuple with the values:
    • Item1: float representing the player's base symphonic damage multiplier (symphonicDamage).
    • Item2: float representing the player's additional symphonic damage multiplier (symphonicDamageMult).
    • Item3: int representing the player's additional flat symphonic damage bonus (flatSymphonicDamage).

Bard Emblem.pngGetBardCrit[]

Returns the player's symphonic critical strike chance.

Parameters[]

  • Player to check symphonic critical strike chance.

Return value[]

  • int representing the player's symphonic critical chance.

Bard Emblem.pngGetBardSpeed[]

Returns the player's symphonic playing speed.

Parameters[]

  • Player to check symphonic playing speed.

Return value[]

  • float representing the player's symphonic playing speed.

Bard Emblem.pngGetBardInspiration[]

Returns the player's current inspiration.

Parameters[]

  • Player to check current inspiration.

Return value[]

  • int representing the player's current inspiration.

Bard Emblem.pngGetBardInspirationMax[]

Returns the player's maximum inspiration.

Parameters[]

  • Player to check maximum inspiration.

Return value[]

  • int representing the player's maximum inspiration.

Cleric Emblem.pngBonusHealerDamage[]

Adds to the player's radiant damage multiplier by a provided amount (i.e. +=). [3]

Parameters[]

  • Player that will have its radiant damage increased.
  • float value to increase the player's radiant damage multiplier by.

Return value[]

  • None.

Cleric Emblem.pngBonusHealerDamageFlat[]

Adds a flat radiant damage bonus calculated after the normal damage formula.

Parameters[]

  • Player that will have its radiant damage increased.
  • int value to add flat radiant damage by.

Return value[]

  • None.

Cleric Emblem.pngBonusHealerCrit[]

Adds to the player's radiant critical strike chance by a provided amount.

Parameters[]

  • Player that will have its radiant critical strike chance increased.
  • int value to increase the player's radiant critical strike chance by.

Cleric Emblem.pngBonusHealerHealBonus[]

Adds to the player's bonus healing by a provided amount.

Parameters[]

  • Player that will have its bonus healing increased.
  • int value to increase the player's bonus healing amount by.

Return value[]

  • None.

Cleric Emblem.pngBonusHealerSpeed[]

Adds to the player's radiant use speed by a provided amount.

Parameters[]

  • Player that will have its radiant use speed increased.
  • float value to increase the player's radiant use speed by.

Return value[]

  • None.

Cleric Emblem.pngGetHealerDamageMods[]

Returns the player's radiant damage bonuses.

Parameters[]

  • Player to check radiant damage bonuses.

Return value[]

  • ValueTuple with the values:
    • Item1: float representing the player's base radiant damage multiplier (radiantBoost).
    • Item2: float representing the player's additional radiant damage multiplier (always returns 1f).
    • Item3: int representing the player's additional flat radiant damage bonus (flatRadiantDamage).

Cleric Emblem.pngGetHealerCrit[]

Returns the player's symphonic critical strike chance.

Aliases[]

  • GetRadiantCrit

Parameters[]

  • Player to check symphonic critical strike chance.

Return value[]

  • int representing the player's symphonic critical chance.

Cleric Emblem.pngGetHealerHealBonus[]

Returns the player's bonus healing.

Aliases[]

  • GetHealBonus

Parameters[]

  • Player to check bonus healing.

Return value[]

  • int representing the player's bonus healing.

Cleric Emblem.pngGetHealerSpeed[]

Returns the player's radiant use speed.

Parameters[]

  • Player to check radiant use speed.

Return value[]

  • float representing the player's radiant use speed.

Life Recovery (buff).pngBonusLifeRecovery[]

Adds to the player's Life Recovery by a provided amount (i.e. +=).

Parameters[]

  • Player that will have its life recovery increased.
  • int value to increase the player's life recovery by.

Return value[]

  • None.

Life Recovery (buff).pngBonusLifeRecoveryIntervalReduction[]

Adds to the player's amount of ticks subtracted from LifeRecoveryIntervalDefault [4] to reduce the Life Recovery interval by a provided amount (i.e. +=) [5].

Parameters[]

  • Player that will have its life recovery timer reduced.
  • int value to reduce the player's life recovery timer by.

Return value[]

  • None.

Life Recovery (buff).pngGetLifeRecovery[]

Returns the player's Life Recovery.

Parameters[]

  • Player to check life recovery.

Return value[]

  • int representing the player's life recovery.

Life Recovery (buff).pngGetLifeRecoveryInterval[]

Returns the player's Life Recovery interval in ticks.

Parameters[]

  • Player to check life recovery interval.

Return value[]

  • int representing the player's life recovery interval in ticks.

Sniper Rifle.pngGetAllCrit[]

Returns the player's additional crit that Thorium Mod applies to all vanilla and its own damage types. Use this if you want your custom damage type to be affected by Thorium Mod's all crit additions.

Parameters[]

  • Player to check crit.

Return value[]

  • int representing the player's additional crit.

Dart Pouch.pngBonusDartDamage[]

Adds to the player's dart damage multiplier by a provided amount (i.e. +=).

Parameters[]

  • Player that will have its dart damage increased.
  • float value to increase the player's dart damage multiplier by.

Return value[]

  • None.

Conduit Suit.pngBonusMartianDamage[]

Adds to the player's martian damage multiplier by a provided amount (i.e. +=).

Parameters[]

  • Player that will have its martian damage increased.
  • float value to increase the player's martian damage multiplier by.

Return value[]

  • None.

History[]

  • 1.6.5.0: Added 18 new Mod Calls:
    • IsSpearItemID, IsMartianItemID, IsFlailProjectileID.
    • GetAquaticDepthsBounds, GetBloodChamberBounds, GetBloodAltarPosition.
    • GetZoneAquaticDepths, GetZoneGranite, GetZoneMarble.
    • BonusLifeRecovery, BonusLifeRecoveryIntervalReduction, GetLifeRecovery, GetLifeRecoveryInterval.
    • GetAllCrit, GetBardInspiration, GetBardInspirationMax, BonusDartDamage, BonusMartianDamage.
  1. 1.0 1.1 BardInstrumentType values are as follows: 0 = Other (armor, accessories, etc.); 1 = Wind; 2 = Brass; 3 = String; 4 = Percussion; 5 = Electronic.
  2. The resulting value is clamped between 10 and 60.
  3. If a Thorium Mod item says "X% decreased non-radiant damage. X% increased radiant damage", this means you should provide the doubled amount to the call, then manually reduce player.allDamage by the regular amount so that it evens out.
  4. 60, in ticks.
  5. Example: providing 20 to the call will reduce the interval by 20 ticks, effectively increasing the life recovery speed by 33% from the default (60).
Advertisement