Skip to content

Using the AppleCore API

Ryan Liptak edited this page Nov 29, 2017 · 9 revisions

Events

A brief overview of the types of things that can be done with the currently implemented events:

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.

Accessor

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.

Mutator

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.

Dispatcher

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.

Further Reading