跳到正文

Create: Recipe Hooks

作者:Aarow

Create library for recipe-based mods/addons/scripts etc...

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

Create Recipe Hooks

Create Recipe Hooks is a server-side library for Minecraft 1.20.1 (Forge and Fabric) that fires

events whenever a Create machine finishes processing a recipe, and whenever a Create machine processes a world
block: Drill mining, Harvester reaping, Saw felling trees. It provides a unified API so that integration mods –
such as quest books, automation scripts, and analytics tools, can react to Create production without writing
their own mixins.

What it does

The mod hooks into Create’s machines at the bytecode level and fires three events:

  • recipeFinished – a Create machine completed a recipe (Basin, Fan, Press, Millstone, Crushing Wheels, Saw, Crafter, Deployer, Spout, Item Drain, Sand Paper, Sequenced Assembly, CEI Printer)
  • blockProcessed – a machine processed a world block: one event per block broken by a Mechanical Drill, per plant cut by a Mechanical Harvester, per lone block cut by a horizontal Mechanical Saw
  • treeCut – a Mechanical Saw felled a whole tree, with the exact log and leaf counts

Every event carries:

  • Source – which machine did the work
  • Player attribution – the UUID of the player who placed the machine (for Crushing Wheels: who threw the item, with a fallback to whoever placed the wheels for belt and hopper input). Persisted across server restarts and carried along inside moving contraptions
  • Recipe ID, item inputs and outputs, fluid outputs – for recipe events
  • Block id, block state, contraption flag, log count – for block events
  • Block position – where it happened in the world

Supported machines

Machine Source constant Event
Basin (Mixing / Compacting) BASIN recipeFinished
Crushing Wheels CRUSHING_WHEEL recipeFinished
Mechanical Saw (recipes) MECHANICAL_SAW recipeFinished
Spout (recipe and bucket filling) SPOUT_FILLING recipeFinished
Millstone MILLSTONE recipeFinished
Mechanical Press (belt and world) MECHANICAL_PRESS recipeFinished
Mechanical Crafter MECHANICAL_CRAFTER recipeFinished
Deployer DEPLOYER_BELT recipeFinished
Encased Fan (belt and world) FAN_BLASTING / FAN_HAUNTING / FAN_SPLASHING / FAN_SMOKING recipeFinished
Item Drain (recipes, buckets, potions) ITEM_DRAIN_EMPTYING recipeFinished
Sand Paper SAND_PAPER recipeFinished
Sequenced Assembly (final step) SEQUENCED_ASSEMBLY recipeFinished
CEI Printer (optional, Forge only) CEI_PRINTER recipeFinished
Mechanical Drill (stationary and contraption) MECHANICAL_DRILL blockProcessed
Mechanical Harvester (contraption) MECHANICAL_HARVESTER blockProcessed
Mechanical Saw, horizontal (stationary and contraption) MECHANICAL_SAW treeCut / blockProcessed

KubeJS scripting, no addons needed

CRH registers its own KubeJS event group. The same scripts run unchanged on Forge and Fabric,
with an optional source filter and built-in owner resolution:


CRHEvents.recipeFinished('MILLSTONE', event => {
const player = event.getOwner();
if (!player) return;
player.server.runCommandSilent('give ' + player.name.string + ' minecraft:emerald 1');
});

CRHEvents.treeCut('MECHANICAL_SAW', event => {
// event.getLogCount(), event.getBlockId(), event.getOwner()
});

Ready-to-use script examples (FTB Quests integration, output filtering, per-player counters,
drill mining quests, log counting) are available in the README.

Why you might want this

If you are building a quest integration (FTB Quests etc.), you can trigger quest progress the moment
a Create machine finishes, attributed to the right player – not just when items land in an inventory.
Quests like “smelt 64 iron with a Fan”, “mine 500 stone with a Drill” or “fell 50 trees with a Saw”
become one short script each.

If you are writing analytics or logging tools for a server, you get a single reliable event stream for all Create
production.

This mod does nothing visible on its own. It is a library – you will not see any in-game UI, items, or blocks.
Install it when another mod or script requires it. It is server-side: clients without the mod can join a server
that has it. For singleplayer, install it in your instance.

Requirements

  • Minecraft 1.20.1
  • Forge file: Forge 47 or newer, Create 6.0.8 or newer. Also runs on NeoForge 1.20.1, verified on clients and dedicated servers
  • Fabric file: Fabric Loader 0.15+, Fabric API, Create Fabric 6.0.8.1 or newer. Works on Quilt
  • KubeJS – optional, only for JS scripting (no EventJS or other addons required)
  • Create Enchantment Industry – optional soft dependency on Forge; CEI Printer events are only fired when CEI is installed

For developers

Register listeners during mod initialization, identical on both loaders:


CreateRecipeHooks.register(ctx -> {
if (ctx.getSource() == RecipeSource.BASIN) {
// ctx.getRecipeId(), ctx.getItemOutputs(), ctx.getBlockPos(), ...
}
});

CreateRecipeHooks.registerBlockProcessed(ctx -> {
// ctx.getBlockId(), ctx.isContraption(), ctx.getMetadata()
});

CreateRecipeHooks.registerTreeCut(ctx -> {
// ctx.getLogCount(), ctx.getLeafCount()
});

On Forge the events are also posted on the event bus (CreateRecipeFinishedEvent,

CreateBlockProcessedEvent, CreateTreeCutEvent); on Fabric they are standard

callbacks (CreateRecipeFinishedCallback, CreateBlockProcessedCallback,

CreateTreeCutCallback).

A debug mode is available for testing on Forge. Launch with the JVM argument

-Dcrh.debug=true to write every recipe completion to
logs/crh-events.log.

Full API documentation is available in the per-loader READMEs on the

GitHub repository.

License

LGPL-3.0-or-later – free to use in public and private modpacks and as a dependency in other mods.
Forks and derivative mods must remain open source under the same license with attribution.

常见问题

Create: Recipe Hooks 支持哪些 Minecraft 版本?

Create: Recipe Hooks 支持 Minecraft Java 版 1.20.1–1.21.1,共 2 个版本,可用的加载器:Fabric / Forge / NeoForge / Quilt。下载时注意选择和你游戏版本一致的文件。

Create: Recipe Hooks 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric / Forge / NeoForge / Quilt,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:仅服务端。

评论

登录后评论和评分

Aarow 的其他作品

查看全部 →