Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/main/java/com/hfstudio/guidenh/ClientProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,14 @@ public void init(FMLInitializationEvent event) {
SceneScript sceneScript = new SceneScript();
lytHost.registerScript("Scene", sceneScript);
lytHost.registerScript("GameScene", sceneScript);
// Phase 3: RecipeScript handles Recipe, RecipeFor, RecipeUsage, RecipesFor
// Phase 3: RecipeScript handles Recipe, Usage, RecipeFor, RecipeUsage, RecipesFor, RecipesUsage
RecipeScript recipeScript = new RecipeScript();
lytHost.registerScript("Recipe", recipeScript);
lytHost.registerScript("Usage", recipeScript);
lytHost.registerScript("RecipeFor", recipeScript);
lytHost.registerScript("RecipeUsage", recipeScript);
lytHost.registerScript("RecipesFor", recipeScript);
lytHost.registerScript("RecipesUsage", recipeScript);

MinecraftForge.EVENT_BUS.register(this);
GuideDebugLog.infoAlways(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ public class RecipeCompiler extends BlockTagCompiler {

@Override
public Set<String> getTagNames() {
return new HashSet<>(Arrays.asList("Recipe", "RecipeFor", "RecipeUsage", "RecipesFor"));
return new HashSet<>(
Arrays.asList("Recipe", "Usage", "RecipeFor", "RecipeUsage", "RecipesFor", "RecipesUsage"));
}

@Override
Expand Down Expand Up @@ -61,8 +62,8 @@ protected void compile(PageCompiler compiler, LytBlockContainer parent, MdxJsxEl
}

String tagName = el.name();
boolean multi = "RecipesFor".equals(tagName);
boolean usageQuery = "RecipeUsage".equals(tagName);
boolean multi = tagName != null && tagName.startsWith("Recipes");
boolean usageQuery = tagName != null && tagName.endsWith("Usage");

String handlerNameFilter = trimToNull(MdxAttrs.getString(compiler, parent, el, "handlerName", null));
String handlerIdFilter = trimToNull(MdxAttrs.getString(compiler, parent, el, "handlerId", null));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,8 +343,9 @@ public String render(MdxJsxElementFields element, String defaultNamespace) {
return fallbackParagraph(fallbackText);
}

boolean multi = "RecipesFor".equals(element.name());
boolean usageQuery = "RecipeUsage".equals(element.name());
String tagName = element.name();
boolean multi = tagName != null && tagName.startsWith("Recipes");
boolean usageQuery = tagName != null && tagName.endsWith("Usage");
int limit = multi ? Integer.MAX_VALUE : 1;
if (parsedLimit != null && parsedLimit > 0) {
limit = parsedLimit;
Expand Down
36 changes: 21 additions & 15 deletions wiki/Recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,39 @@ GuideNH can render crafting and NEI-backed recipes directly inside guide pages.
## Supported Tags

- `<Recipe>`
- `<Usage>`
- `<RecipeFor>`
- `<RecipeUsage>`
- `<RecipesFor>`
- `<RecipesUsage>`

All three share the same compiler and attribute set.

## Tag Semantics

| Tag | Behavior |
| --- | --- |
| `<Recipe>` | render a single recipe for the target item |
| `<RecipeFor>` | same single-recipe behavior, more author-friendly name |
| `<RecipesFor>` | render multiple matching recipes |
| Tag | Behavior |
|------------------|--------------------------------------------------------|
| `<Recipe>` | render a single recipe for the target item |
| `<Usage>` | render a single recipe using the target item |
| `<RecipeFor>` | same single-recipe behavior, more author-friendly name |
| `<RecipeUsage>` | same single-recipe behavior, more author-friendly name |
| `<RecipesFor>` | render multiple matching recipes |
| `<RecipesUsage>` | render multiple matching recipes |

If multiple recipes exist and you use the single-recipe forms, GuideNH renders only one result unless filters narrow it further.

## Common Attributes

| Attribute | Required | Meaning |
| --- | --- | --- |
| `id` | yes | target item reference |
| `fallbackText` | no | text shown when no usable recipe is found |
| `handlerName` | no | case-insensitive substring filter on handler name |
| `handlerId` | no | exact overlay/handler id filter, case-insensitive |
| `handlerOrder` | no | 0-based index after handler filtering |
| `input` | no | ingredient filter expression |
| `output` | no | result filter expression |
| `limit` | no | positive integer max number of rendered recipes |
| Attribute | Required | Meaning |
|----------------|----------|---------------------------------------------------|
| `id` | yes | target item reference |
| `fallbackText` | no | text shown when no usable recipe is found |
| `handlerName` | no | case-insensitive substring filter on handler name |
| `handlerId` | no | exact overlay/handler id filter, case-insensitive |
| `handlerOrder` | no | 0-based index after handler filtering |
| `input` | no | ingredient filter expression |
| `output` | no | result filter expression |
| `limit` | no | positive integer max number of rendered recipes |

## Item Id Syntax

Expand Down