-
Notifications
You must be signed in to change notification settings - Fork 29
Developer API 2.7.x Core Registry
While the CoreRegistry doesn't offer much right off the bat, it is meant as a core/base for other modules and offers common functionality for the other modules.
The API is accesible via:
import growthcraft.api.core.CoreRegistry;
CoreRegistry.instance();
If you'd like to create new item effects, then you can leverage Growthcraft's IEffect API in your project, or if you'd like to extend Growthcraft with new effects.
The main interface is IEffect
, it has 4 methods:
// IEffect
void apply(World world, Entity entity, Random random, Object data);
// IDescribable
void getDescription(List<String> list);
// INBTSerializableContext
void readFromNBT(NBTTagCompound data, String name);
void writeToNBT(NBTTagCompound data, String name);
All effects SHOULD be serializable via NBT data, this is to ensure that your effect is simple enough doesn't include something that cannot be explained easily in basic data.
Stock Effects:
-
EffectAddPotionEffect
: This effect is used to add a PotionEffect to the target. -
EffectChance
: Given a chance, the effect MAY apply. -
EffectList
: Applies all effects contained. -
EffectNull
: Does nothing, and will never do anything. -
EffectRandomList
: Applies a random effect from it's contained. -
EffectRemovePotionEffect
: Opposite of EffectAddPotionEffect, this will remove a PotionEffect. -
EffectWeightedRandomList
: Similar to EffectRandomList, but requires weights for each effect present.
Effects are meant to be composed of other effects, such as wrapping an EffectList
in a EffectChance
.
Effect descriptions have a similar function when applied, lets say you have an EffectChance
, which applies an EffectList
, its description could look like this:
25% of applying (
Potion Effect #1
Potion Effect #2
)
You could further place that EffectChance
into an EffectRandomList
along with an EffectRemovePotionEffect
:
Randomly applies one of (
25% of applying (
Potion Effect #1
Potion Effect #2
)
OR
Removes "Poison"
)
By creating a simple interface and smaller primitives, the system allows the creation of complex effects using smaller parts. The best part, the call signature never changes:
myAwesomeEffect.apply(world, entity, world.rand, null);
Doesn't matter if myAwesomeEffect
, is EffectNull
or EffectUberAwesomeThingThatWouldBringYourServerToItsKnees
.
In order to reload serialized effects, all effects are registered here:
final IEffectRegistry efr = CoreRegistry.instance().getEffectsRegistry();
// An example of how to register your effect.
efr.register("my_custom_effect", EffectMyCustomEffect.class);
[General Information](General Information)
In-Game Documentation
Growthcraft Apples
Growthcraft Bamboo
Growthcraft Bees
Growthcraft Cellar
Growthcraft Cellar - Yeast
Growthcraft Fishtrap
Growthcraft Grapes
Growthcraft Hops
Growthcraft Milk
Growthcraft Rice
API Documentation
Dev Documentation
Module Contribution Guide
How-To Build Growthcraft
Modpack Documentation