-
-
Notifications
You must be signed in to change notification settings - Fork 0
Fire Registration
To make the API aware of your custom fire you need to register it.
Registration must be done in your mod loader class to work properly.
Let's break down in small steps how registering is done:
-
Creating a
Fire:
AFireinstance is nothing more than a representation of your fire within the API.
You need to register one to make the API aware of your fire and handle its behaviors. -
Getting a
Fire.Builder:
To create aFireinstance you need aFire.Builder.
To get one simply callFireManager#fireBuilder()and pass your Fire Type. -
Tweaking the
Fire:
TheFireabout to be built will be constructed using the Fire Type provided to theFire.Builderduring initialization or reset.
However you may want to change some other properties from their default value, for example the damage. More on this below. -
Building the
Fire:
It's as simple as callingFire.Builder#build(). -
Registering the
Fire:
Once you have built yourFireinstance, pass it as parameter toFireManager#registerFire(Fire).
Here is a simple example of registering two different Fires:
public final class CommonModLoader {
/**
* Initialize common operations across loaders.
*/
public static void init() {
Fire.Builder fireBuilder = FireManager.fireBuilder(new ResourceLocation(Constants.MOD_ID, "custom_fire"));
FireManager.registerFire(fireBuilder.setLight(12).setDamage(3).build());
fireBuilder.reset("healing_fire");
FireManager.registerFire(fireBuilder.setDamage(-2).setInvertHealAndHarm(true).build());
}
}It's also possible, and suggested, to save and reuse a single FireBuilder instance if you have to register multiple fires. FireBuilder#reset() can be used to reset each value to its default. If you use the FireBuilder#reset(String) overload, like in the example, the Mod Id will not be reset.
Trying to register multiple Fires with the same Fire Id won't throw, but only the first Fire will be registered and an error will be logged for the other ones.
Here's a description of each Fire.Builder method, one by one with detailed explanation and also a description of the related Fire property:
-
setLight(int):
Related property:Fire#light, emitted light level by fire related blocks such as fire source, campfire, torch, and lantern.
Sets the light level, defaults to15.
Effective only on blocks registered via Prometheus API. -
setDamage(float):
Related property:Fire#damage, fire damage per second.
Sets the damage, defaults to1.0F.
The damage can be either positive or negative. Positive hurts, negative heals,0does nothing.
What just said can change when applied to undead mobs such as zombies and skeleton as explained below. -
setInvertHealAndHarm(boolean):
Related property:Fire#invertHealAndHarm, whether to invert harm and heal for mobs that have potion effects inverted (e.g. undead).
Sets the flag for inverting heal and harm for undeads, defaults tofalse.
Determines whether to invert heal and harm for undeads:Damage Flag Effect Positive falseHurts all entities Positive trueHurts normal entities, heals undead mobs Negative falseHeals all entities Negative trueHeals normal entities, hurts undead mobs -
setCanRainDouse(boolean):
Related property:Fire#canRainDouse, whether rain can douse the Fire.
Sets the flag for allowing rain to douse the fire, defaults tofalse.
Effective only on fire source blocks registered via Prometheus API. -
setOnCampfire():
Related property:Fire#onCampfireGetter,DamageSourcegetter for when the entity takes damage from a campfire.
Sets theonCampfireGetterDamageSourcegetter, defaults toFire.Builder#DEFAULT_ON_CAMPFIRE_GETTER. -
setInFire():
Related property:Fire#inFireGetter,DamageSourcegetter for when the entity is in or on a block providing fire.
Sets theinFireGetterDamageSourcegetter, defaults toFire.Builder#DEFAULT_IN_FIRE_GETTER. -
setOnFire():
Related property:Fire#onFireGetter,DamageSourcegetter for when the entity is burning.
Sets theonFireGetterDamageSourcegetter, defaults toFire.Builder#DEFAULT_ON_FIRE_GETTER. -
setComponent(Fire.Component<?, ?>, ResourceLocation)/removeComponent(Fire.Component<?, ?>):
Related property:Fire#components, map of all Fire Components.
Changes the value of the specified Fire Component or removes it from the Fire map.
Read more about these in the dedicated section. -
setBehavior(Predicate<Entity>)/setBehavior(Consumer<Entity>):
Related property:Fire#behavior, custom behavior to apply before the entity takes damage or heals.
Sets the custom Fire behavior, either with an explicit return or with an implicittrue.
The return value determines whether the default hurt/heal behavior should still apply.
Read more about this in the dedicated section. -
reset(ResourceLocation)/reset(String, String)/reset(String):
Resets all current values in theFire.Builderto their default.
Thereset(String)overload will not reset the Mod Id, useful if you need to register multiple fires of the same mod. -
build():
Returns a newFireinstance to register.
Once registering is done, everything is set for the Fire to work properly.
This means you can also register another mod's fire and it will work as well!
However, make sure all the Client and Server resources are there, possibly adding the missing ones.
If your mod's aim is only to register other mods Fires, you might consider using Data Driven Fires.
If you have any suggestions or questions about this wiki, please open an issue following the Documentation enhancement template.