Interface FarmingRegistry
public interface FarmingRegistry
What takes part in farming, and how: the
FarmingBehaviour attached to each block type,
and what items do to the land.
Whatever a plugin declares here is in effect until it is disabled, or until it takes it back
with detachAll(Plugin). The latest declaration wins, and the previous one is in effect
again once the latest is taken back, so that a plugin can override a built-in plant and give it
back.
- Since:
- 0.1.0
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionvoidattach(TypedKey<BlockType> block, FarmingBehaviour behaviour, Plugin owner) Attaches a behaviour to a block type, in place of the one in effect.Returns the behaviour in effect for a block type, empty for a block taking no part in farming.default Optional<FarmingBehaviour> Returns the behaviour in effect for the type of a state, empty for a block taking no part in farming.blocks()Returns an immutable snapshot of the block types that have a behaviour.booleanDetaches the behaviours an owner attached to a block type.voidTakes back everything an owner declared: the behaviours it attached, and its seeds, fertilizers, hoes and tillable soils.voidfertilizer(TypedKey<Item> item, Plugin owner) Declares an item as a fertilizer: using it on a block that takes fertilizer feeds the block and uses one item up.voidDeclares an item as a hoe: using it on tillable soil tills it and wears the item.booleanisFertilizer(TypedKey<Item> item) Returnstrueif an item is a fertilizer.booleanReturnstrueif an item is a hoe.Returns the block type an item plants, empty for an item that is not a seed.voidDeclares an item as the seed of a plant: using it on a block plants the default state of the plant against the clicked face, where the plant can stand, and uses one item up.voidDeclares what a hoe does to a block type.Returns what a hoe does to a block type, empty for a block a hoe does nothing to.
-
Method Details
-
attach
Attaches a behaviour to a block type, in place of the one in effect.- Parameters:
block- the block typebehaviour- its farming behaviourowner- the owner of the attachment, usually thePlugininstance; it is released bydetachAll(Plugin)- Since:
- 0.1.0
-
detach
-
detachAll
Takes back everything an owner declared: the behaviours it attached, and its seeds, fertilizers, hoes and tillable soils.- Parameters:
owner- the owner given when declaring- Since:
- 0.1.0
-
behaviour
Returns the behaviour in effect for a block type, empty for a block taking no part in farming.- Parameters:
block- the block type- Returns:
- the behaviour in effect for a block type, empty for a block taking no part in farming
- Since:
- 0.1.0
-
behaviour
Returns the behaviour in effect for the type of a state, empty for a block taking no part in farming.- Parameters:
data- the state- Returns:
- the behaviour in effect for the type of a state, empty for a block taking no part in farming
- Since:
- 0.1.0
-
blocks
-
seed
Declares an item as the seed of a plant: using it on a block plants the default state of the plant against the clicked face, where the plant can stand, and uses one item up.- Parameters:
item- the itemplant- the block type it plantsowner- the owner of the declaration- Since:
- 0.1.0
-
plant
-
fertilizer
Declares an item as a fertilizer: using it on a block that takes fertilizer feeds the block and uses one item up.- Parameters:
item- the itemowner- the owner of the declaration- Since:
- 0.1.0
-
isFertilizer
-
hoe
-
isHoe
-
tillable
-
tillage
-