Effects System
Effects System
This guide explains how the zItems effects system works and how to configure effects for your custom items.
What are Effects?
Effects are reusable abilities that can be applied to items. They define behaviors like:
Mining in a 3x3 area (Hammer)
Auto-selling drops (Auto-Sell)
Automatically smelting ores (Melt Mining)
And much more...
Key Concepts
Effect Definitions (
effects/*.yml) - Reusable effect templatesItem Configuration (
items/*.yml) - Items reference effects by IDEffect Handlers - Java classes that implement the behavior
Effect Context - Shared data during effect execution
Effect File Structure
Effects are defined in plugins/zItems/effects/*.yml:
Minimal Effect
That's it! The effect will use default settings.
Complete Effect Template
Using Effects in Items
Method 1: Base Effects
Add effects directly to item configuration:
When applied: During item creation (ZItem.build())
Shown in lore: Controlled by base-effects-visible setting
Method 2: Additional Effects
Apply effects via commands or smithing:
When applied: After item creation Shown in lore: Controlled by additional-effects-visible setting
Effect Display Control
Per-Item Settings
Global Default
In config.yml:
Effect Lore Customization
In messages.yml:
Result in item lore:
Effect Types
Effects come in three handler types:
SingleEventEffectHandler
Listens to one specific event type.
Example: Hammer effect listens to BlockBreakEvent
Common Single-Event Effects:
Hammer (BlockBreakEvent)
Vein Mining (BlockBreakEvent)
Silk Spawner (BlockBreakEvent)
XP Boost (BlockBreakEvent)
MultiEventEffectHandler
Listens to multiple event types.
Example: Auto-Sell listens to both BlockBreakEvent and EntityDeathEvent
Common Multi-Event Effects:
Auto-Sell (BlockBreakEvent, EntityDeathEvent)
Absorption (BlockBreakEvent, BlockDropItemEvent, EntityDropItemEvent)
Farming Hoe (BlockBreakEvent, PlayerInteractEvent)
NoEventEffectHandler
Applied once when effect is added to item (no events).
Example: Unbreakable effect sets item meta immediately
Common NoEvent Effects:
Unbreakable
Attributes Applicator
Enchants Applicator
Effect Execution Pipeline
How Effects Work Together
When an event occurs (e.g., mining a block):
Effect Context
The EffectContext is shared across all handlers for one event:
Key Point: Each handler sees modifications from previous handlers!
Example Flow:
Effect Priority
Priority determines execution order (higher = earlier):
1
First
Hammer, Vein Mining, Attributes Applicator
0
Middle
Most effects (Silk Spawner, XP Boost, etc.)
-1
Last
Auto-Sell, Absorption
Why This Matters:
If Auto-Sell ran first, it would sell before Melt Mining could smelt!
Effect Incompatibilities
Some effects cannot work together:
Built-in Incompatibilities
Result: Cannot have both Hammer and Vein Mining on same item.
Incompatibility Table
Hammer
Vein Mining
Both modify block breaking
Vein Mining
Hammer
Both modify block breaking
Auto-Sell
Absorption
Both modify drops
Absorption
Auto-Sell
Both modify drops
Checking Compatibility
Effect Representation
Effects can be represented as physical items that players apply via smithing tables.
Basic Representation
Giving Effect Items
Players receive a physical item they can use in a smithing table.
Smithing Table Usage
Place template (e.g., Netherite Upgrade Template)
Place tool (e.g., Diamond Pickaxe)
Place effect stone (Hammer Enhancement)
Take enhanced tool
Applicator Types
Applicability Restrictions
Limit which items can receive the effect:
Effect Settings
Each effect type has its own settings structure.
Common Settings Pattern
Most mining effects use:
Examples by Type
Hammer:
Vein Mining:
Auto-Sell:
XP Boost:
For complete settings documentation, see Effect Handlers Reference.
Creating Effects
Step 1: Create Effect File
Create plugins/zItems/effects/my_hammer.yml:
Step 2: Reload Plugin
Check console for:
Step 3: Use in Item
Create plugins/zItems/items/my_pickaxe.yml:
Step 4: Test
Mine a stone block - it should break a 3x3 area!
Advanced Effect Configuration
Multiple Effects
Execution Order (by priority):
Hammer (1) - Collects blocks
Melt Mining (0) - Smelts
XP Boost (0) - Multiplies XP
Auto-Sell (-1) - Sells smelted drops
Effect with Representation
Best Practices
1. Descriptive IDs
2. Clear Display Names
3. Test Incrementally
Create effect file
Reload:
/zitems reloadCheck console for errors
Create test item
Test in-game
Iterate
4. Document Your Effects
5. Use Consistent Naming
Troubleshooting
Effect Not Loading
Console Error: "Unknown effect type: HAMMMER"
Solutions:
Check spelling of
typefieldEnsure handler is registered (
@AutoEffect)Verify effect type exists
Valid Types: See Effect Handlers Reference
Effect Not Working on Item
Symptoms: Item has effect in lore but doesn't work
Checklist:
Is the effect ID correct in item config?
Does the effect have required settings?
Is the item material compatible?
Check console for errors
Debug:
Effect Not Showing in Lore
Symptoms: Effect works but not shown in lore
Causes:
nb-effects-view: 0(hides all)base-effects-visible: falseEffect has no
display-name
Solution:
Effect Applied But Nothing Happens
Checklist:
Does the effect require specific conditions? (e.g., Hammer needs breakable blocks)
Is the effect compatible with item type? (e.g., Farming Hoe on hoes only)
Check console for runtime errors
Enable debug mode in
config.yml
Performance Considerations
Effect Overhead
NoEventEffects: Applied once, no overhead
SingleEventEffects: Minimal overhead per event
MultiEventEffects: Slightly more overhead (multiple event types)
Optimizing Effects
Good:
Bad:
Block Limit
For Vein Mining, use reasonable limits:
Next Steps
Effect Handlers Reference - All available effects and their settings
Commands - Effect-related commands
Creating Items - Using effects in items
Need help? Join our Discord or check GitHub Issues!
Last updated