-
Notifications
You must be signed in to change notification settings - Fork 29
Developer API 2.4.x
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.
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, the main interface IEffect
has 2 methods, apply
, and getDescription
. apply
takes a World, Entity, Random and an optional data Object
void apply(World world, Entity entity, Random random, Object data);
void getDescription(List<String> list);
Now you must be saying "whats so great about 2 methods!?"
These 2 methods are more powerful than you think.
For example EffectList
implements IEffect, it will apply
each of its sub-effects to the target.
"Great, so you can apply multiple effects to a target, Woooop."
EffectRandomList
, is similar to EffectList, however it randomly applies one of its sub-effects to the target.
EffectAddPotionEffect
, as its name implies adds a PotionEffect to the target
EffectRemovePotionEffect
, removes a potion effect from the target
EffectChance
, as a chance of applying its sub-effect to a target.
EffectNull
, I (IceDragon), don't like using null
, I prefer the Null object pattern, so you can have an Effect that does nothing and says it does nothing, all without having to add some conditional.
Notice I mentioned "sub-effect", this means most of these effects are meant to be composed to create complex effects. All of this is done by using a simple interface.
"That's pretty awesome!, but what about getDescription!?"
Get description has a similar benefit, you are only given a list, however, it doesn't mean the children of the effect have to get the same list, this allows you to patch their descriptions going up the line.
Lets say you have an EffectChance, which applies a EffectList, its description could look like this
25% of applying (
Potion Effect #1
Potion Effect #2
)
You could further place that EffectChance
into a EffectRandomList
along with another Potion Effect
Randomly applies one of (
25% of applying (
Potion Effect #1
Potion Effect #2
)
OR
Removes "Poison"
)
Why stop there, you could wrap it in another chance!
As you can see, by creating a simple interface, you can create very complex and dynamic effects.
And you NEVER have to change your call signature
myAwesomeEffect.apply(world, entity, world.rand, null);
Doesn't matter if myAwesomeEffect, is EffectNull
or EffectUberAwesomeThingThatWouldBringYourServerToItsKnees
The BeesRegistry allows you to manipulate the Growthcraft|Bees side of things, such as adding new bees, honey combs and flowers.
If you want to make booze, brew up something, ferment something, or in general mess around with the Growthcraft|Cellar, then you are looking into the CellarRegistry.
So, you would like to add some nice booze to the Growthcraft registry, fear not its not that hard!
All you need is Growthcraft
(as in the the Growthcraft core
) and Growthcraft|Cellar
to get started.
import growthcraft.api.cellar.booze.BoozeEffect;
import growthcraft.api.cellar.booze.BoozeEntry;
import growthcraft.api.cellar.booze.BoozeTag;
import growthcraft.api.cellar.booze.effect.EffectTipsy;
import growthcraft.api.cellar.booze.BoozeRegistry;
import growthcraft.api.cellar.CellarRegistry;
import growthcraft.api.core.effect.EffectList;
...
final BoozeRegistry br = CellarRegistry.instance().booze();
br.registerBooze(yourBooze);
That's it your done. HOWEVER, ensure that your booze is registered to the Forge fluid regisry first, or else, ALL HELL WILL BREAK LOOSE. Growthcraft will fail with an exception, we refuse to register any fluid that isn't in the FluidRegistry.
So you've registered your booze, and you'd like to leverage the rest of the API.
When you register a Booze, you also get a BoozeEntry (which automatically gives you a BoozeEffect and therefore the IEffect API, neat ain't it)
final BoozeEntry be = br.getBoozeEntry(booze);
final BoozeEffect beff = be.getEffect();
// Note you can also fetch the effect directly using br.getEffect(booze);
A BoozeEffect is composed of 2 effects, the first being the EffectTipsy
which adds the tipsy effect to the target, this is normally null by default, being "no tipsy effect", the second effect, is an EffectList
, this is where you add your own effects to the booze.
final EffectList effectList = beff.getEffects();
// BoozeEffect also offers some convience methods for creating special PotionEffect entries
beff.addPotionEntry(potionInstance, time, level);
// This adds a new EffectAddPotionEffect using a BoozePotionEffectFactory
BoozePotionEffectFactory
is a implementation of the IPotionEffectFactory
interface, which is used by EffectAddPotionEffect
to create PotionEffects, simple enough right?
Booze entries also have tags.
Now tags are VERY important for booze, since they can have complex effects, which make it hard to find out what they are, we have BoozeTags
.
Growthcraft identifies booze characteristics via its tags, (even if they are misleading sometimes).
For example if a Booze has the FERMENTED
tag, then Growthcraft knows that its a fermented booze, and therefore prevents it from being used for creating yeast, instead a Booze must be tagged with YOUNG
in order to be used for creating yeast.
Tags have no Hard rule, just don't do something like FERMENTED and YOUNG
, which makes no sense.
// Tagging your booze
br.addTags(myYoungBooze, BoozeTag.YOUNG);
br.addTags(myFermentedBooze, BoozeTag.FERMENTED);
br.addTags(myPotentBooze, BoozeTag.FERMENTED, BoozeTag.POTENT);
// Checking tags
br.hasTags(myYoungBooze, BoozeTag.YOUNG); // true
br.hasTags(myYoungBooze, BoozeTag.YOUNG, BoozeTag.FERMENTED); // false
br.hasTags(myPotentBooze, BoozeTag.POTENT); // true
br.hasTags(myPotentBooze, BoozeTag.FERMENTED, BoozeTag.POTENT); // true
When you tag your booze accordingly, you also get the benefits of other helper methods, such as generating Thaumcraft Aspects for your Booze Entries, however that is a topic for later.
You can always define your own tags by creating a new BoozeTag, seriously
final BoozeTag EPIC = new BoozeTag("epic");
br.addTags(myEpicBooze, EPIC);
DO NOT CREATE A NEW BOOZETAG PER BOOZE. While we have no reason to enforce it, its a good idea to have a reusable tag to reduce memory usage.
In addition you can get the Tags LocalizedName
, which is pulled from grc.booze.tag.name
, for our EPIC tag, it would be grc.booze.tag.epic
, yes, it uses the name you passed in.
Tags are great and all, but they also serve a secondary function.
BoozeTag.POTENT.setModifierFunction(new ModifierPotent());
Yes, modifier functions, these functions are used to dynamically manipulate Booze Potion Effects, while you could just define each and every potion effect yourself, you can also just set your entire booze array to the base level of the Potion Effect and let the modifier functions scale them for you.
For example, if you added regeneration
to your booze effects at level 1, and you tag it with POTENT
, then your booze will be scaled to Level 2
.
We use multiple boozes with this, you set all of them to the same thing potion and the modifier function will scale them for you, so EXTENDED
booze will have their time doubled, and POTENT
will have their level increased, HYPER_EXTENDED
, will have the effect of POTENT
and EXTENDED
. POISONED
will tell Growthcraft that the booze is dangerous, but it doesn't have a modifier function.
Modifier functions only change level
and time
, if you want your booze to be poisoned
you must poison it yourself.
For example, Growthcraft|Nether
has Vile Slop, which is considered a POISONED
booze, however it applies negative buffs instead, it is only marked as POISONED
because it used Nether Rash
as its fermenting item.
All in, the Booze API is only 1 layer of the Growthcraft Cellar APIs.
TODO
TODO
Adding new recipes for the Fruit Press is done via the Pressing Registry, accessible via:
import growthcraft.api.cellar.CellarRegistry;
import growthcraft.api.cellar.pressing.IPressingRegistry;
final IPressingRegistry reg = CellarRegistry.instance().pressing();
IPressingRegistry
has 3 methods
// New recipes are added via this method
void addPressingRecipe(ItemStack src, FluidStack result, int time, Residue residue);
// You obtain a pressing recipe result using this method
PressingResult getPressingResult(ItemStack src);
// You can check if there is a pressing recipe available for this ItemStack
boolean hasPressingRecipe(ItemStack src);
NOTE getPressingResult
and hasPressingRecipe
WILL IGNORE STACK SIZE.
You must enforce the proper stack size checks in your code, the registry is meant only for retrieval of these results without much interference checks.
For the upcoming Growthcraft|Dairy module, you'll be able to add cheese, LOTS and LOTS of CHEESE!
If you'd like to add new items to the Growthcraft|Fishtrap, this is the place to be.
[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