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

  1. Effect Definitions (effects/*.yml) - Reusable effect templates

  2. Item Configuration (items/*.yml) - Items reference effects by ID

  3. Effect Handlers - Java classes that implement the behavior

  4. 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):

Priority
Execution
Common Effects

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

Effect
Incompatible With
Reason

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

  1. Place template (e.g., Netherite Upgrade Template)

  2. Place tool (e.g., Diamond Pickaxe)

  3. Place effect stone (Hammer Enhancement)

  4. 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):

  1. Hammer (1) - Collects blocks

  2. Melt Mining (0) - Smelts

  3. XP Boost (0) - Multiplies XP

  4. Auto-Sell (-1) - Sells smelted drops

Effect with Representation


Best Practices

1. Descriptive IDs

2. Clear Display Names

3. Test Incrementally

  1. Create effect file

  2. Reload: /zitems reload

  3. Check console for errors

  4. Create test item

  5. Test in-game

  6. Iterate

4. Document Your Effects

5. Use Consistent Naming


Troubleshooting

Effect Not Loading

Console Error: "Unknown effect type: HAMMMER"

Solutions:

  • Check spelling of type field

  • Ensure 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:

  1. Is the effect ID correct in item config?

  2. Does the effect have required settings?

  3. Is the item material compatible?

  4. 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: false

  • Effect has no display-name

Solution:

Effect Applied But Nothing Happens

Checklist:

  1. Does the effect require specific conditions? (e.g., Hammer needs breakable blocks)

  2. Is the effect compatible with item type? (e.g., Farming Hoe on hoes only)

  3. Check console for runtime errors

  4. 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