CraftRecipeEvent
CraftRecipeEvent
Section titled “CraftRecipeEvent”Package:
com.hypixel.hytale.server.core.event.events.ecsExtends:CancellableEcsEventImplements:ICancellableEcsEventCancellable: Yes
ECS event superclass for crafting operations. Uses a Pre/Post pattern:
CraftRecipeEvent.Pre— Fired before crafting occurs. Can be cancelled to prevent the craft.CraftRecipeEvent.Post— Fired after crafting succeeds. Informational — while technically cancellable (inherited fromCancellableEcsEvent), the craft has already completed.
Fields / Accessors (Base Class)
Section titled “Fields / Accessors (Base Class)”| Field | Type | Accessor | Mutable | Nullable |
|---|---|---|---|---|
craftedRecipe | CraftingRecipe | getCraftedRecipe() | No | No |
quantity | int | getQuantity() | No | No |
- craftedRecipe — The recipe being crafted.
- quantity — The number of times the recipe is being crafted in this operation.
CraftRecipeEvent.Pre
Section titled “CraftRecipeEvent.Pre”Extends:
CraftRecipeEventCancellable: Yes (inherited)
Fired before the crafting operation takes effect. Cancelling this event prevents the craft from occurring — ingredients are not consumed and no output is produced.
Fired By
Section titled “Fired By”CraftingManager(line 155) viacomponentAccessor.invoke(ref, event)— ECS dispatch before a crafting operation executes.
Listening
Section titled “Listening”public class MyCraftPreHandler extends EntityEventSystem<EntityStore, CraftRecipeEvent.Pre> { @Override public Query<EntityStore> getQuery() { return MY_COMPONENT_TYPE; }
@Override public void handle(int index, ArchetypeChunk<EntityStore> chunk, Store<EntityStore> store, CommandBuffer<EntityStore> commandBuffer, CraftRecipeEvent.Pre event) { CraftingRecipe recipe = event.getCraftedRecipe(); int quantity = event.getQuantity();
// Example: prevent crafting of restricted recipes if (isRestrictedRecipe(recipe)) { event.setCancelled(true); } }}
// Register in plugin setup():getEntityStoreRegistry().registerSystem(new MyCraftPreHandler());CraftRecipeEvent.Post
Section titled “CraftRecipeEvent.Post”Extends:
CraftRecipeEventCancellable: Yes (inherited, but craft has already completed)
Fired after the crafting operation has completed successfully. The ingredients have already been consumed and the output produced. While this event inherits cancellability from CancellableEcsEvent, cancelling it at this stage does not undo the craft. This event is primarily useful for logging, analytics, or triggering side effects.
Fired By
Section titled “Fired By”CraftingManager(line 184) viacomponentAccessor.invoke(ref, event)— ECS dispatch after a crafting operation completes.
Listening
Section titled “Listening”public class MyCraftPostHandler extends EntityEventSystem<EntityStore, CraftRecipeEvent.Post> { @Override public Query<EntityStore> getQuery() { return MY_COMPONENT_TYPE; }
@Override public void handle(int index, ArchetypeChunk<EntityStore> chunk, Store<EntityStore> store, CommandBuffer<EntityStore> commandBuffer, CraftRecipeEvent.Post event) { CraftingRecipe recipe = event.getCraftedRecipe(); int quantity = event.getQuantity();
// Example: track crafting statistics craftingStats.recordCraft(recipe, quantity); }}
// Register in plugin setup():getEntityStoreRegistry().registerSystem(new MyCraftPostHandler());Related Events
Section titled “Related Events”PlayerCraftEvent— Deprecated standard-event predecessor. UseCraftRecipeEventinstead.