-
Notifications
You must be signed in to change notification settings - Fork 26
Using the AppleCore API
A brief overview of the types of things that can be done with the currently implemented events:
- Modify food values, react to food being eaten, or control food stats changes
- Control how the exhaustion, health regen, and starvation mechanics work
- Control or react to plant growth ticks
The events added by AppleCore are used in the same way as Forge events. They are also fired on the Forge event bus, so the event handler should be registered using MinecraftForge.EVENT_BUS.register.
@SubscribeEvent
public void onFoodEaten(FoodEvent.FoodEaten event)
{
if (event.hungerAdded >= 1)
event.player.heal(1);
}All of the available events can be found in the various subpackages of the AppleCore API package, and example usage of each event can be found in the AppleCore example package.
The AppleCoreAPI.accessor can be used to retrieve various values dealing with food/hunger mechanics/etc.
return AppleCoreAPI.accessor.isFood(itemStack);A list of available methods can be found in the IAppleCoreAccessor interface.
The AppleCoreAPI.mutator can be used to modify various values dealing with food/hunger mechanics/etc.
AppleCoreAPI.mutator.setHunger(player, 10);A list of available methods can be found in the IAppleCoreMutator interface.
The AppleCoreAPI.dispatcher can be used to fire AppleCore events in a standardized way.
Event.Result allowGrowthResult = AppleCoreAPI.dispatcher.validatePlantGrowth(this, world, x, y, z, random);A list of available methods can be found in the IAppleCoreDispatcher interface.