-
-
Notifications
You must be signed in to change notification settings - Fork 1
Using the API
FireManager
is a utility class with many methods to retrieve data from all registered Fire
s.
Each method comes with a Javadoc explaining its use, most are getters, here some important/useful methods are seen in more depth:
-
createCampfireBlock(String, Properties)
(in Fabric it'sSettings
instead ofProperties
)
Utility to create aCampfireBlock
with the correct Fire Id. -
isValidFireId(String)
Checks if the givenString
is a valid Fire Id.
Does not check if there's aFire
registered with it. -
isFireId(String)
Checks if the givenString
is a valid Fire Id and if there's aFire
registered with it. -
sanitizeFireId(String)
Returns a valid Fire Id from the givenString
.
This does not ensure that aFire
is registered with it. -
ensureFireId(String)
Returns a valid and registered Fire Id from the givenString
.
All base cases are handled by this mod once a Fire is registered, for example you don't have to worry about setting an entity on fire when it goes into your fire source block.
However you may wish to set on a specific Fire a certain entity in a different situation from the base ones, for example with Torch hit! torch hits represent a new use case where handling setting on fire is needed.
To set on fire an entity while keeping this mod features you just need to call FireManager.setOnFire(Entity, int, String)
passing it the entity you wish to set on fire, the amount of seconds the fire should last for and the Fire Id of the Fire.
Removing any fire from any entity is as easy as using base Minecraft method Entity.clearFire()
(Entity.extinguish()
on Fabric).
There are 3 ways to hurt/heal an entity with your custom Fire:
- Set the entity on fire as explained above and let the mod handle the rest
- Using
FireManager.damageInFire(Entity, String, DamageSource, float)
- Using
FireManager.damageOnFire(Entity, String, DamageSource, float)
The difference between damageInFire
and damageOnFire
is the use context: damageInFire
should be used when the entity is taking damage because it's inside or above a block considered as a fire source, like a campfire or a Fire block, while damageOnFire
should be used when an entity is burning.
The API will take care of using the proper DamageSource, damage and choosing between hurting or healing.
You just need to pass to those methods the Entity you wish to hurt/heal, the Fire Id, the default DamageSource and default damage to use when no Fire was registered with the provided Fire Id.
If you have any suggestions or questions about this wiki, please open an issue following the Documentation enhancement template.