tModLoader Rare Item Swap

V 2.0 is here!
Why the major version change? Because this adds a way for any mod to add compatibility with this one without heavy dependancy.
Just add in your mod the mod.Call to this mod you need, and you can add:
- New Parts
- New Part Recipes
- New Shop-based part Recipes
- Ways to drop parts based on your npc's and biomes, events, game-stages (post-moonlord, usually) and weathers.
- NOTE: you can add any drop condition on any of the tables, but try to stick to the ones that fit the style. Use weathers or events for stuff that doesn't fit anywhere else.
- You can also create a file containing all items that don't have either a Recipe or PartRecipe, to find all items in a mod that cannot be obtained other than by drop/chests.

I will post here the empty ModCall log, that contains all the functions currently available. If this is not enough for the compatibility you wish to do, please add a reply in this thread or an issue in github to try and add it to the "API".

[21:09:56] [12/INFO] [ARareItemSwapJPANs]: Mod call was Empty. This will display, in log, what functions are currently available. All function calls are case-insensitive, but arguments are not.
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: Player arguments accept the Player object or the Player.whoAmI (position in the Main.player array;
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: Item arguments take Item objects, ModItem object, the int Type of that item or the Item Tag of the item;
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: NPC arguments take NPC objects, ModNPC object, the int Type of that npc or the NPC Tag of the npc;
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: Int values accept int or its string representation;
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: Func<T> assumes the correct passed one in the argument. null is accepted in most cases
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: Functions available:
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - GetPartList()
Returns a list of ItemTags of the parts that exist.
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - GetMaxPurchasesAvailable (string... parts)
Returns a list of items with the stack as the purchase of one of them for all parts whose tags match the given strings, regardless of amount required.
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - AddNewPart(Item part)
Inserts that item in the part list, being automatically added to the pouch when picked up and open the part shop when used.
Don't forget to use the "AddPartToDropAt" functions if you want to add it to one of the default drop tables.
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - AddPartToDropAt(String tableID, Item part, Func<bool> dropRule)
Adds the part to the given drop table so it is added to the drop pool when "dropRule" is true.
Valid tables are "biome",for dropping when in a specific mod biome, "stage" for dropping after a certain boss was defeated, "event" for dropping during specific events (lunar or goblin-like) and "weather" for weather related events.
If the Part does not exist, it will be added as a part, same as with "AddNewPart" command.
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - AddPartToDropFromNPC(Item part, NPC npc)
Adds the part to the given npc's drop table so it is dropped when the npc is defeated.
Useful for adding RareEnemyParts to your mod's Rare Enemies!
If the Part does not exist, it will be added as a part, same as with "AddNewPart" command.
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - AddBasicShopRecipe(Item toAdd, string mod, string shopName, Func<bool> availability, string... categories)
Creates a simple shop recipe for the given item, in the Mod section and in the Shop/shopName section, available only when availability function is true.
This simple shop recipe includes a trade for every Shop Token that it can have, so any multiple of 5 copper, 5 silver or 5 gold.
other than mod and shopName, availability can be null to be ignored, and Categories are optional, but will make the item easier to find.
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - AddPartRecipe(Item toAdd, int? count, bool? irreversible, int? PartPairsCount, (Item partToSwap, int? count)*PartPairsCount, string mod, Func<bool> availability, string... categories)
Creates the Part recipe -> (toAdd * count) <=> (toSwap[1] * count[1]) + (toSwap[2] * count[2])... +(toSwap[PartPairsCount] * count[PartPairsCount])
Can be used to override existing recipes (same output and parts, but different counts). Cannot be used to remove recipes.

[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - AddPartToPlayer(Player player, Item part, optional long count)
Adds count number of the part to the player.
Returns the amount that the player has of that part (total), or -count if it would overflow (and will not add anything to the player in that case).
If count is ommited, it is treated as +1
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - RemovePartFromPlayer(Player player, Item part, optional long count)
Decreases count number of the part from the player.
Returns the amount that the player has of that part (total), or -count if it would underflow (and will not remove anything from the player in that case).
If count is ommited, it is treated as +1
[21:09:56] [12/INFO] [ARareItemSwapJPANs]: - DebugDump()
Writes a few files in the Log folder containing the items that do not have crafting recipes for all mods.
Useful for making mod-compatibility for this mod.

I also updated Battlerods with an example of compatibilty. It covers most functions provided by the "API". Just check out "PartModCompat.cs" and the "Items/Parts" folder for how everything is done.


EDIT:
V2.0.1 just changes the item tooltip search to match that of Research from 1.4; it shouldn't affect much right now as there are less than 2000 items total in each section, but in future this could become a problem, so "nip it in the bud" as they say.
 
Last edited:
Too bad there's no download so that i can play (my mod browser don't work so...);( looks cool tho.
For mods that have a GitHub linked (the ones with icons on mod browser all have one) you can also download them from the GitHub Releases page. You can find all my mods here.

V2.1 Changelog
- Changed the way the mod Unloads, so that it is less likely to have garbage after loading/unloading/reloading the mod with changes in total mods, specially if they have compatibility with this mod. I couldn't fix all instances of this itemID related bug, so if you encounter something wierd with the parts (such as items requiring non-part items, like in my case shadowflame staffs from thorium instead of Grand Thunderbird parts), just exit and reload the whole game with the mods you wish to play already enabled. I'll try to find a permanent solution in the meantime.
- Changed some interactions with Research from 1.4 in order to prevent duplicate parts, and to take advantage of the 2.0 release features.
 
V2.1.0.1
- Small update fixing a bug with Calamity Support.
- Changed Darksun Fragments to be obtained with Post-DOG parts.

I'm unsure when I'll have the time to fully update the Thorium and Calamity support for this mod, so sorry for now with the non-existing items still present and some missing.
 
Back
Top Bottom