Fertilizer runtime
Server-owned growth, bounded plot treatment and bone meal's material-only contract.
FertilizerGrowth is an internal implementation, called by FertilizerItem.useOnBlock. It mutates existing plants during item use and owns no persistent crop state or ticking manager.
What it does
Four Grade values select crop progress or botanical growth. Fertilizers lists the player-facing effects and merchant offers. Registration lives in IsekaiMiscItems, and SimpleModelProvider generates each misc-item model from its existing texture.
BoneMealMaterialMixin cancels the two static vanilla helpers BoneMealItem.useOnFertilizable and useOnGround only when the stack is Items.BONE_MEAL. This closes the hand, dispenser and vanilla farmer paths through those helpers while allowing the Mystic Fertilizer stack to use the underwater helper. It does not remove bone meal or its recipes.
Runtime model
| Grade | Crop operation | Other plants |
|---|---|---|
COMMON | Current age + 1, capped at maximum | Pass |
PREMIUM | Current age + 3, capped at maximum | Pass |
VERDANT | Same-height 3×3, each age + 1 | Pass |
MYSTIC | Maximum age | Native Fertilizable attempt, then supported underwater growth |
The client predicts an action result. The server performs block writes, emits WorldEvents.BONE_MEAL_USED and consumes one item for a successful crop treatment. A valid native botanical attempt consumes a dose even if canGrow returns false. Creative players keep the stack.
Contracts
The clicked position requires a player who may modify blocks, world modification permission and ProtectedAction.BUILD. DungeonWorldPolicy rejects dungeon worlds. Verdant treatment additionally checks loaded chunks and building permission for each of its at most 9 cells. Its centre must be a CropBlock; mature centre crops may still admit immature neighbours.
growCrop returns false for mature or unsupported blocks and when the server refuses the state write. finish spends nothing if no crop changed. Native multi-block growth remains inside the existing ProtectionItemUseMixin player scope, which checks destination writes through ProtectionScope. The underwater helper receives a copied stack, so its internal decrement does not double-charge the real stack.
No legacy growth configuration, item NBT or alternate bone-meal route is introduced. No fertilizer dispenser behaviour is registered.
Extending it
Add a distinct grade only when it needs different growth behaviour; keep registration, tooltip, merchant offer and misc-model generation together. Fertilizers have no crafting recipe. Their Farmer and Horticulturist offers are authored in .agents/skills/isekai-expansion-trade-authoring/scripts/generate_ktm2_trade_overrides.py, which writes trade_overrides/vanilla/farmer.json and trade_overrides/compat/villagersplus_horticulturist.json. Plants derived from CropBlock use their own maximum age automatically. Other plants must implement Fertilizable to enter Mystic Fertilizer’s native plant path.
Do not bypass the per-cell permission checks for area growth. Native growth routines can make several writes, so retain the player protection scope rather than checking only the clicked block.
Verifying
Compile with gradlew.bat compileJava and regenerate misc models with gradlew.bat generateMiscItemModels. In a development world, test immature and mature crops, mixed plots across a protected boundary, Creative consumption, a sapling whose growth fails, underwater vegetation and bone meal in a dispenser. Check that a refused treatment spends nothing and that a plot treatment spends only one item.
Related
See Fertilizers for merchant offers and Protection runtime for the shared write policy.