Enchantments
Minecraft enchantments modify game mechanics by altering item behavior, applying effects or changing damage calculations. Kore provides a fully type‐safe, Kotlin-based DSL for creating custom enchantments that can be used in datapacks. This documentation explains how to create enchantments in Kore, and presents a detailed example for every available enchantment effect.
For general concepts on creating datapacks with Kore, please refer to the other documentation pages (e.g. Predicates, Components). This article is dedicated exclusively to creating enchantments.
Basic Enchantment Creation
Creating an enchantment in Kore is as simple as calling the enchantment
function inside a data pack. A basic enchantment is defined by its description, what items it supports, and additional properties such as exclusive sets, primary items, and equipment slots.
For example:
This snippet creates a simple enchantment named “test” that can be applied to a diamond sword or axe, with additional restrictions on the type of items and slots.
Enchantment Effects
An enchantment’s power is defined in the effects
block. Kore supports a wide range of effects – each affecting a different aspect of gameplay. You can combine multiple effects by using functions within the effects { ... }
builder. Below is an exhaustive list of every supported enchantment effect along with a precise Kotlin example.
Attributes
Modifies or adds attribute modifiers to items. For example, increasing an item’s scale.
Armor Effectiveness
Modifies the effectiveness of armor when the enchantment is active.
Block Experience
Calculates and awards experience based on block-related factors using a combination of level-based providers. This effect demonstrates the DSL’s advanced capabilities by combining several sub-effects:
Crossbow Charging Sounds
Changes the sounds produced when a crossbow is charged.
Crossbow Charge Time
Alters the time required to charge a crossbow.
Damage
Applies an additional damage effect when the enchanted item is used.
Damage Immunity
Gives temporary immunity from damage; can also trigger a sound effect when activated.
Equipment Drops
Modifies the probability and quantity of equipment drops when an entity is defeated.
Fishing Luck Bonus
Increases luck when fishing.
Fishing Time Reduction
Reduces the time required to catch fish.
Hit Block
A multifaceted effect triggered when the enchanted item is used to hit a block. It supports many sub-effects including applying mob effects, damaging entities, modifying item durability, explosions, igniting blocks, playing sounds, changing block states, and summoning particles or entities.
Item Damage
Inflicts additional damage (i.e. worsening the item's condition).
Knockback
Applies extra knockback to the target when attacking.
Mob Experience
Increases the experience dropped by mobs upon death.
Post Attack
Executes effects immediately after an attack is completed. This effect can both apply a mob effect and cause damage.
Prevent Armor Change
Prevents armor slots from being modified.
Prevent Equipment Drop
Stops equipment from being dropped on death.
Projectile Count
Modifies the number of projectiles produced (for example, by a crossbow).
Projectile Spread
Alters the spread angle of projectiles fired.
Repair with XP
Repairs an item using player experience when the item is used.
Smash Damage Per Fallen Block
Increases damage based on the number of blocks fallen before impact.
Tick
Executes an effect periodically (every game tick). For example, dealing damage over time.
Trident Return Acceleration
Accelerates the return speed of a thrown trident.
Trident Spin Attack Strength
Boosts the strength of a trident’s spin attack.
Trident Sound
Modifies the sound played when a trident is thrown or returns.
Further Reading
• For more on item components and matchers, see Components.
• For advanced predicate conditions that may be used in requirements for enchantment effects, see Predicates.
• For complete source code examples and more detailed API information, visit the Kore GitHub repository.
Using Kore, you can create a nearly limitless variety of enchantments by mixing and matching these effects. The examples above illustrate each individual effect available in the library. Combine them as needed to design your custom gameplay mechanics with full type-safety and a clean, Kotlin-based DSL.
Happy enchanting!