Package fr.fidorial.world.farming


package fr.fidorial.world.farming
Farming: soil, the plants growing on it, and the engine making them grow.

Growing is not a property of every block. Stone never changes, wheat ripens, farmland dries out. So the farming side of a block type is a FarmingBehaviour, attached to the block types that have one in the FarmingRegistry, next to and independently from their BlockBehaviour and their RedstoneBehaviour. A block type with no farming behaviour is inert: it never grows, always stands, drops nothing and ignores fertilizer.

The registry also says what items do to the land: which ones plant a block, which ones fertilize, which ones till, and what tilled soil becomes. A plugin adding a plant of its own registers its block type, attaches a behaviour to it, and declares its seed:

FarmingRegistry farming = context.server().registries().farming();
farming.attach(RICE, new RiceBehaviour(), plugin);
farming.seed(RICE_GRAINS, RICE, plugin);

The simulation itself, which blocks get a random tick and when, how a change reaches the plants around it, and what the items of players do, is the FarmingEngine service: a plugin can replace it, or wrap the built-in one, without touching the behaviours.

Everything that happens is announced by the events of fr.fidorial.event.farming.

Threading

Reading a FarmingWorld is allowed from any thread. Changing blocks, and everything a behaviour is asked to do, happens on the thread of the region owning the block; what reaches a block of another region is handed over to its thread, or skipped when the documentation of the method says so.

Since:
0.1.0
  • Interfaces
    Class
    Description
    The farming side of a block type: how it grows, what it needs to stand, how it answers to fertilizer, and what it gives when harvested.
    The farming simulation, registered as a service: which blocks get a random tick, how a block change reaches the plants around it, and what hoes and fertilizers do.
    What takes part in farming, and how: the FarmingBehaviour attached to each block type, and what items do to the land.
    A world as the farming engine drives it: what plants look at to grow, the changes they make, and what the server reports to the engine.
    What a hoe does to a block type: what the block turns into, whether it needs room above, and what falls out of it.