Skip to content

Custom Enchants customenchants

This feature provides configurable custom enchants.

Config

Overview

This feature was designed to give a vast amount of configurability for how custom enchants function. Here's an example of the inquisitive enchant. Its intent is to boost XP from slain mobs.

    inquisitive:
      display-name: '&a&lInquisitive'
      max-level: 1
      #This part can be left out of the config,
      #If it is, no message will be sent.
      #You can use {LEVEL_ROMAN} and {LEVEL}
      activation-message: '&a&lEXP Boost! &7(Inquisitive {LEVEL_ROMAN})'
      description: 'Gives extra XP for &eblaze &7kills!'
      application-types:
        - 'SWORD'
        - 'AXE'
      effects:
        ef-1:
          #The event to listen to.
          event: 'entitydeath'
          #What type of application should we do?
          apply: 'BOOST_XP'
          #Boosts the XP by this amount.
          data:
            BOOST_XP: "{LEVEL} + 1"
          #The conditions that MUST be met for the enchant to apply.
          conditions:
            #Chance, this is applicable and available to ALL conditions.
            #You don't have to specify it, if left out, it will default to 100.0.
            chance: 100.0
            #The entity attacked MUST equal these!
            ENTITY_TYPE:
              - 'BLAZE'
Inline comments have been added for some extra context on how an enchant is configured.

Let's break down what's going on.

Starting off, application-types. This is a list of item types that the enchantment should be applicable to. Here's the list of all valid types.

ARMOR
ALL
HELMET
CHESTPLATE
LEGGINGS
BOOTS
WEAPON
SWORD
AXE
BOW
TOOL
PICKAXE

The functionality of any enchant is defined under its effects section. This section should define a set of effects.

        ef-1:
          #The event to listen to.
          event: 'entitydeath'
          #What type of application should we do?
          apply: 'BOOST_XP'
          #Boosts the XP by this amount.
          data:
            BOOST_XP: "{LEVEL} + 1"
          #The conditions that MUST be met for the enchant to apply.
          conditions:
            #Chance, this is applicable and available to ALL conditions.
            #You don't have to specify it, if left out, it will default to 100.0.
            chance: 100.0
            #The entity attacked MUST equal these!
            ENTITY_TYPE:
              - 'BLAZE'

Note

The name ef-1 is disregarded. It is not used and must only be unique by YAML standards.

The event value defines the type of the event the custom enchant is triggered by. These will be explored further and detailed in a bit.

Under data, you can define a set of things to happen under the given event. In this case, we use BOOST_XP. This boosts the amount of XP the entity death yields by the given multiplier. The value {LEVEL} + 1 defines the multiplier. The {LEVEL} placeholder refers to the level of the custom enchant the player had when triggered.

Note

Every data section has {LEVEL} available. Depending on the event, others may also be available. You're also able to use mathematical expressions for these values as well, hence the + 1.

Finally, the conditions section defines the conditions that must be met for the enchantment to activate. The chance value is always available to all events and simply allows for random chance in activation. Other than that, each event provides certain conditions depending on what was available. E.g. ENTITY_TYPE in entitydeath forces the enchantment to only activate for blazes.

Events

These are all the events that can be used. Along with the listed event, the variables and effects that are available to it are listed. There are also two effects that are available to all of these events.

CANCEL - Cancels the event entirely.

CANCEL_CHANCE - Has a chance to cancel an event.

POTION_GIVE - Gives the potion effect to the entity involved.

GIVE_MOBCOIN - Only applicable to player events. Gives the amount of mobcoins to the player.

RUN_COMMAND - Runs a list of commands for the player. {PLAYER} placeholder for the player's name.

entitydeath

Called when a player kills an entity and when you, as a player, dies.

Effects

BOOST_XP - Boosts the XP from the entity that died.
BOOST_DROPS - Boosts the drops the entity drops when dying.

Available Variables

{LEVEL} - The level of the custom enchant.

entitydamage

Called when a player takes damage.

Effects

DAMAGE_MOD - Modifies the damage the entity takes by the given modifier. DAMAGE - Applies the given amount of damage to the entity. HEAL - Heals the entity the given amount.

Variables

{LEVEL} - The level of the custom enchant.
{DAMAGE} - The raw damage the entity will take. (Pre armor calculation)
{FDAMAGE} - The final damage the entity will take. (Post armor calculation)
{MAX_HEALTH} - The maximum health of the entity.

entitydamagebyentity

Called when a player either takes damage from an entity or does damage to an entity.

Effects

Aside from the effects to be listed, all effects from entitydamage are available. POTION_GIVE_OTHER - Like POTION_GIVE, but gives it to the OTHER entity. (If you're the attacker, the attacked and vice versa) DAMAGE_OTHER - Like DAMAGE, but gives it to the other entity. HEAL_OTHER - Like HEAL, but gives it to the other entity. HEAL_ATTACKER - Heals the attacker by the given amount.

Variables

All that are available in entitydamage.

interact

Called when a player interacts with a block. Useful for insta-break enchants.

Effects

SET_BLOCK - Sets the given block to the material type. BREAK_BLOCK - Breaks the block naturally. Useful for insta-break as it will properly drop the block and animate it.

Variables

There are no specific variables available.

equip

Called when a player equips a piece of armor. Useful for generic potion enchants.

Effects

Only generic effects.

Variables

There are no specific variables available.

held

Called when a player holds an item. Useful for generic potion events.

Effects

Only generic effects.

Variables

There are no specific variables available.

Conditions

You are able to specify conditions that must be met for the effect of an enchantment to work. Aside from the aforementioned chance condition, varying conditions are available based upon the event.

General Conditions

These conditions are applicable to all events.

ENTITY_TYPE

Available to all events that involve entities.

Note

If this is used in an entitydamagebyentity, this will always be the type of the entity that was attacked.

entitydamage

DAMAGE_AMOUNT

Acts as a minimum threshold for the amount of damage that occurred.

KILLS

Enforces that the damage received by the entity would have killed it.

DAMAGE_CAUSE

Matches the damage cause of the event.

interact

CLICKED_TYPE

Matches the clicked block's material.

CLICK_TYPE

Either LEFT_CLICK_BLOCK, RIGHT_CLICK_BLOCK, LEFT_CLICK_AIR, RIGHT_CLICK_AIR, and PHYSICAL.

CAN_BUILD

If the player can build at the clicked block's location.

itemdamage

Just listens for when items are damaged.

entitydamagebyentity

Aside from these conditions, all conditions from entitydamage are available as well.

ATTACKER_TYPE

Matches the attacker's entity type.

ATTACKED_TYPE

Matches the attacked entity's type.

IS_ATTACKER

Checks if the entity who activated the enchantment was the attacker entity.

IS_ATTACKED

Checks if the entity who activated the enchantment was the attacked entity.

Command

  • /ce - Opens the built in custom enchant menu.
  • /ce list - Lists all available custom enchants on the server.
  • /ce givebook (player) (type) (level) - Gives an enchant book to the given player.

Permissions

  • Base Level - Some commands.
  • Admin Level - Some commands.