[Proposal] CanBurnInLava hook rework
See original GitHub issueDescription
Currently in ItemLoader there exists the CanBurnInLava hook: public static bool CanBurnInLava(Item item)
. This is the place where it’s called:
if (owner == Main.myPlayer && type != 312 && type != 318 && type != 173 && type != 174 && type != 175 && type != 2701 && rare == 0 || ItemLoader.CanBurnInLava(this)
It returns false by default. Modders can override it and return true to force an item to burn in contact with lava, bar the vanilla exceptions above. Vanilla behavior is that items with a rarity of 0 (White) always burn bar the vanilla exceptions above. The hook is currently very limited in application scope: The only case where it makes sense to return true is if you want an item with higher than 0 rarity to burn.
If a modder would want to prevent items from being burned regardless of rarity, this is not possible via this hook currently.
A modder could instead “hack” the system and swap out the rarity in ItemLoader.Update
, and change it back in ItemLoader.PostUpdate
, but that’s not in the spirit of tml.
Proposal
Change the return type to bool?
, similar to a bunch of other tml hooks, it would introduce new behavior:
- defaults to null: not overriding means vanilla behavior
- return true: force the item to burn regardless of any conditions
- return false: force the item to never burn regardless of any conditions
The place where it’s called would have to be slightly changed to accomodate this.
What does this proposal attempt to solve or improve?
More control over which items burn and don’t without “hacking” the item rarity temporarily
Which (other) solutions should be considered?
It will require a change of the return type, so this isn’t sensible to do for current tml but for 1.4 tml.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5 (4 by maintainers)
I think a mod that attempts to force some items to burn should take precedence. A mod like that would be implementing some sort of game mode, whereas a mod attempting to force an item to not burn is just suggesting some attribute of the item in question.
This should probably be closed, since decent solution is merged now.