-
Notifications
You must be signed in to change notification settings - Fork 0
C | Creating Custom Items
Sartaj Singh edited this page May 31, 2025
·
2 revisions
- 1. Overview
- 2. FXItemDefinition: All Options & Parameters
- 3. FXItemBehavior: Custom Logic
- 4. FXItemRecipe: Recipes & Crafting
- 5. Registering Your Item
- 6. Real-World Examples
- 7. Advanced Features
- 8. Troubleshooting & FAQ
- 9. See Also
Every custom item in FXItems is defined and configured using the FXItemDefinition class.
FXItems does not use attribute files or YAML for items: everything is in code, with clear API options for every aspect of appearance, lore, behavior, and crafting.
public FXItemDefinition(
String id,
String displayName,
Material material,
Rarity rarity,
FXItemBehavior behavior,
Integer customModelData,
boolean oneTimeCraft,
boolean unbreakable,
boolean hideFlags,
List<String> lore,
FXItemRecipe recipe
)| Parameter | Type | Required | Description |
|---|---|---|---|
| id | String | Yes | Unique identifier for the item. Lowercase, no spaces recommended. |
| displayName | String | Yes | Name shown in-game. Supports § color codes. |
| material | Material | Yes | Minecraft material (Material.DIAMOND_SWORD, etc.). |
| rarity | Rarity | No | Enum: COMMON, UNCOMMON, RARE, EPIC, LEGENDARY. |
| behavior | FXItemBehavior | No | Custom logic for the item (see below). |
| customModelData | Integer (nullable) | No | For resource-pack custom models. Null for none. |
| oneTimeCraft | boolean | No | If true, only craftable once per player/server. |
| unbreakable | boolean | No | If true, item never takes durability damage. |
| hideFlags | boolean | No | If true, hides vanilla item flags in tooltip. |
| lore | List | No | Tooltip text. Color codes supported. |
| recipe | FXItemRecipe | No | Crafting recipe. See below. |
- Only
id,displayName, andmaterialare strictly required. - All other fields can be
nullor left as default. - For best practice, fill out all fields for clarity and documentation.
Custom logic for items (active abilities, passives, events, etc.) is implemented by your own class that implements FXItemBehavior.
public interface FXItemBehavior {
default void onRightClick(Player player, ItemStack item, Block block, Action action) {}
default void onLeftClick(Player player, ItemStack item, Block block, Action action) {}
default void onAttack(EntityDamageByEntityEvent event, Player player, ItemStack item) {}
default void onPassive(Player player, ItemStack item) {}
// ...extend as FXItems is updated!
}public class MythrilSwordBehavior implements FXItemBehavior {
@Override
public void onRightClick(Player player, ItemStack item, Block clickedBlock, Action action) {
player.getWorld().strikeLightning(player.getLocation());
player.sendMessage("§bYou called lightning!");
}
}- Any method not relevant can be left unimplemented (they default to empty).
- Many hooks are supported: right/left click, attack, damage taken, passive tick, etc.
- See Advanced: Custom Effects in FXItems for more.
public FXItemRecipe(
List<ItemStack> ingredients, // 9 elements, top-left to bottom-right
boolean shaped,
int outputAmount,
boolean enabled
)| Parameter | Description |
|---|---|
| ingredients | List of 9 ItemStacks (use Material.AIR for empty slot). |
| shaped | true = shaped, false = shapeless recipe. |
| outputAmount | How many items produced per craft. |
| enabled | Enables/disables the recipe. |
- Supports custom items as ingredients (must match by displayName + material).
- Recipes can be updated by re-registering the item.
Registry registry = new RegistryAPI();
registry.registerItem("mythril_sword", mythrilSwordDefinition);- Place registration in your plugin's
onEnable()or similar setup.
Recommended for large codebases.
-
Annotate your behavior class:
@AutoRegister public class MythrilSwordBehavior implements FXItemBehavior { ... }
-
In your plugin's main class:
BehaviorAutoRegistrar.registerAll(this, "your.base.package");
- All annotated behaviors in the package are discovered and registered.
FXItemDefinition simpleSword = new FXItemDefinition(
"simple_sword",
"§bSimple Sword",
Material.IRON_SWORD,
Rarity.UNCOMMON,
new SimpleSwordBehavior(),
null, // customModelData
false, // oneTimeCraft
false, // unbreakable
true, // hideFlags
Arrays.asList("§7A basic enchanted sword."),
null // recipe
);FXItemDefinition mythrilSword = new FXItemDefinition(
"mythril_sword",
"§bMythril Sword",
Material.DIAMOND_SWORD,
Rarity.RARE,
new MythrilSwordBehavior(),
5, // customModelData (resource pack)
false,
true,
true,
Arrays.asList(
"§7A sword forged from mythril.",
"",
"§fRight Click: Shoots a beam!"
),
new FXItemRecipe(
Arrays.asList(
new ItemStack(Material.AIR),
new ItemStack(Material.DIAMOND),
new ItemStack(Material.AIR),
new ItemStack(Material.IRON_BLOCK),
new ItemStack(Material.STICK),
new ItemStack(Material.IRON_BLOCK),
new ItemStack(Material.AIR),
new ItemStack(Material.STICK),
new ItemStack(Material.AIR)
),
true, // shaped
1, // outputAmount
true // enabled
)
);- Custom Model Data: Integrate with resource packs for truly unique visuals.
- One-Time Craft: Use for legendary or quest items (see OneTimeCraftUtils).
- Hide Flags: Make tooltips clean for custom items (e.g., hide vanilla enchantments/attributes).
-
Passives: Use
onPassivefor effects that apply while held or in inventory.
-
"My item isn't working":
- Check that the ID is unique and matches in registration/crafting.
- Make sure you re-register your item after any code change.
- Confirm your behavior class is correct and not missing required methods.
-
"Recipe isn't showing up":
- Double-check ingredient order (3x3, top-left to bottom-right).
- Confirm that all custom ingredients are also registered items.
-
"Color codes not working":
- Use
§for color codes in displayName and lore.
- Use
-
"How do I change rarity colors?":
- Edit
RarityLang.ymlin the plugin folder.
- Edit
- B | The Registry System: Items, Foods, Commands, Events
- D | Creating Custom Foods
- E | Advanced: Custom Effects in FXItems
- S | Auto-Registration System
- L | OneTimeCraftUtils
- Home
- A | Getting Started & Plugin Overview
- B | The Registry System: Items, Foods, Commands, Events
- C | Creating Custom Items
- D | Creating Custom Foods
- E | Advanced: Custom Effects in FXItems
- F | Creating Custom Commands
- G | Creating Custom Events & Behaviors
- H | Utility: CooldownUtils
- I | Utility: CustomItemUtils
- J | Utility: EffectUtils
- K | Utility: ManaUtils
- L | Utility: OneTimeCraftUtils
- M | Utility: TeleportUtils
- N | Utility: ProjectileUtils
- O | Utility: GammaUtils
- P | Utility: EntitySizeUtils
- Q | FXItems API (com.noctify.API) & Making Addons
- R | Advanced Techniques, Gotchas & FAQ
- S | Auto-Registration System
- T | Migration Guide (v1.1 → v1.2+)
- U | Changelog