Skip to content

feat: support item model keys and namespaced materials for blueprint bundle icon#2941

Merged
tastybento merged 5 commits intodevelopfrom
feature/blueprint-bundle-item-model-icon
Apr 14, 2026
Merged

feat: support item model keys and namespaced materials for blueprint bundle icon#2941
tastybento merged 5 commits intodevelopfrom
feature/blueprint-bundle-item-model-icon

Conversation

@tastybento
Copy link
Copy Markdown
Member

Summary

Resolves #2940

The "icon" field in blueprint bundle JSON files now accepts three formats without any change to existing configs:

  • Plain material name (existing): "icon": "DIAMOND"
  • Vanilla namespaced material (new): "icon": "minecraft:diamond"
  • Custom item model key (new): "icon": "myserver:island_tropical"

How it works

Material.matchMaterial() is tried first — this handles both plain names and vanilla namespaced keys. If the string contains a : and is not a recognised vanilla material, it is treated as a custom item model key applied to a PAPER base item via ItemMeta.setItemModel(NamespacedKey).

Backward compatibility

  • getIcon() (returns Material) is unchanged in signature — existing addons that call this continue to work, receiving PAPER for custom model keys.
  • New getIconItemStack() method returns the full ItemStack with model data applied.
  • setIcon(Material) overload preserved; new setIcon(String) overload added.
  • Panels (BlueprintManagementPanel, IslandCreationPanel) updated to call getIconItemStack() so custom model icons actually render.

Test plan

  • New BlueprintBundleTest covers: plain name, minecraft: namespaced, custom model key, null/fallback cases
  • Existing BlueprintManagementPanelTest and IslandCreationPanelTest updated with getIconItemStack() stubs
  • All three test classes pass

🤖 Generated with Claude Code

tastybento and others added 4 commits April 14, 2026 03:58
…bundle icon

The "icon" field in blueprint bundle JSON files now accepts three formats:
- Plain material name: "DIAMOND"
- Vanilla namespaced material: "minecraft:diamond"
- Custom item model key: "myserver:island_tropical"

Material.matchMaterial() is tried first, handling plain names and vanilla
namespaced keys. If the string contains a colon and is not a recognised
vanilla material, it is treated as a custom item model key applied to a
PAPER base item via ItemMeta.setItemModel().

getIcon() (returning Material) is preserved for binary compatibility.
getIconItemStack() is the new method that returns the full ItemStack with
model data applied. Panels now call getIconItemStack() to render icons.

Closes #2940

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
When an admin clicks an item from their inventory to set a blueprint bundle
icon, IconChanger now checks ItemMeta.hasItemModel() first. If the item
carries a custom model key (e.g. paper[item_model="myserver:island_tropical"]),
that NamespacedKey string is stored instead of the plain Material name,
preserving the full item model through to getIconItemStack().

Plain material items continue to work exactly as before.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Applies the same logic as BlueprintBundle to Blueprint.java:
- icon field changed from Material to String internally
- getIcon() preserved (returns Material, backward compatible)
- getIconItemStack() added — resolves plain names, minecraft: keys,
  and custom item-model keys (PAPER base + ItemMeta.setItemModel)
- setIcon(Material) and setIcon(String) both fluently return Blueprint

BlueprintManagementPanel now calls blueprint.getIconItemStack() so
custom-model icons are visible to admins in the management GUI.

IconChanger also applies item-model detection in the blueprint branch,
so admins can click a datapacked item to set a blueprint icon the same
way as a bundle icon.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@tastybento
Copy link
Copy Markdown
Member Author

Example blueprint bundle JSON:

{
  "uniqueId": "test",
  "icon": "bentobox:island_star",
  "displayName": "test",
  "description": [
    "Okay here's a description <blue>blue!</blue>"
  ],
  "requirePermission": false,
  "blueprints": {
    "NORMAL": "island"
  },
  "slot": 9,
  "times": 0,
  "cost": 7.0,
  "commands": []
}
Screenshot 2026-04-14 at 4 28 07 AM

Also works just by clicking on the icon in the blueprint admin GUI to set the icon.

…ation

SonarCloud flagged 8.9% code duplication and repeated "PAPER" literals.

- Add ItemParser.parseIconMaterial() and parseIconItemStack() as the
  single source of truth for icon string resolution
- Both BlueprintBundle and Blueprint now delegate to these methods
  instead of duplicating the logic
- Replace repeated "PAPER" string literals with a DEFAULT_ICON constant
  in each class
- Remove unused Sound import from IconChangerTest

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sonarqubecloud
Copy link
Copy Markdown

@tastybento tastybento merged commit 0dbb116 into develop Apr 14, 2026
3 checks passed
@tastybento tastybento deleted the feature/blueprint-bundle-item-model-icon branch April 14, 2026 11:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

add Blueprint support custom model data & ItemModel

1 participant