search

linkEnchantments

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.

linkBasic 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:

dataPack("my_datapack") {
    enchantment("test") {
        description("This is a test enchantment.")
        exclusiveSet(Tags.Enchantment.IN_ENCHANTING_TABLE)
        supportedItems(Items.DIAMOND_SWORD, Items.DIAMOND_AXE)
        primaryItems(Tags.Item.AXES)
        slots(EquipmentSlot.MAINHAND, EquipmentSlot.OFFHAND)
    }
}
Kotlin

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.

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

linkAttributes

Modifies or adds attribute modifiers to items. For example, increasing an item’s scale.

enchantment("attributes") {
    effects {
        attributes {
            attribute("my_modifier", name, Attributes.SCALE, AttributeModifierOperation.ADD_VALUE, 5)
        }
    }
}
Kotlin

linkArmor Effectiveness

Modifies the effectiveness of armor when the enchantment is active.

enchantment("armor_effectiveness") {
    effects {
        armorEffectiveness {
            add(5) {
                requirements {
                    weatherCheck(raining = true)
                }
            }
            allOf {
                add(5)
                allOf {
                    add(5)
                }
            }
            multiply(2)
            removeBinomial(2)
            set(2)
        }
    }
}
Kotlin

linkBlock 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:

enchantment("block_experience") {
    effects {
        blockExperience {
            allOf {
                add(clampedLevelBased(5, 0.0, 10.0))
                add(constantLevelBased(5))
                add(fractionLevelBased(1, 5))
                add(levelsSquaredLevelBased(2))
                add(linearLevelBased(2, 2))
                add(lookupLevelBased(2, 2, fallback = 2))
            }
        }
    }
}
Kotlin

linkCrossbow Charging Sounds

Changes the sounds produced when a crossbow is charged.

enchantment("crossbow_charging_sounds") {
    effects {
        crossbowChargingSounds {
            crossbowChargingSound {
                start(SoundEvents.Item.Crossbow.QUICK_CHARGE_3)
            }
        }
    }
}
Kotlin

linkCrossbow Charge Time

Alters the time required to charge a crossbow.

enchantment("crossbow_charge_time") {
    effects {
        crossbowChargeTime {
            add(5)
        }
    }
}
Kotlin

linkDamage

Applies an additional damage effect when the enchanted item is used.

enchantment("damage") {
    effects {
        damage {
            add(5)
        }
    }
}
Kotlin

linkDamage Immunity

Gives temporary immunity from damage; can also trigger a sound effect when activated.

enchantment("damage_immunity") {
    effects {
        damageImmunity {
            sound {
                requirements {
                    weatherCheck(raining = true)
                }
            }
        }
    }
}
Kotlin

linkEquipment Drops

Modifies the probability and quantity of equipment drops when an entity is defeated.

enchantment("equipment_drops") {
    effects {
        equipmentDrops {
            add(EquipmentDropsSpecifier.ATTACKER, 5) {
                requirements {
                    weatherCheck(raining = true)
                }
            }
            allOf(EquipmentDropsSpecifier.VICTIM) {
                add(5)
                allOf {
                    add(5)
                }
            }
        }
    }
}
Kotlin

linkFishing Luck Bonus

Increases luck when fishing.

enchantment("fishing_luck_bonus") {
    effects {
        fishingLuckBonus {
            add(5)
        }
    }
}
Kotlin

linkFishing Time Reduction

Reduces the time required to catch fish.

enchantment("fishing_time_reduction") {
    effects {
        fishingTimeReduction {
            add(5)
        }
    }
}
Kotlin

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

enchantment("hit_block") {
    effects {
        hitBlock {
            allOf {
                applyMobEffect(Effects.SPEED) {
                    maxDuration(2)
                    minAmplifier(1)
                }
                requirements {
                    weatherCheck(raining = true)
                }
            }
            damageEntity(DamageTypes.IN_FIRE, 1, 2) {
                requirements {
                    weatherCheck(raining = false)
                }
            }
            changeItemDamage(1)
            explode(
                attributeToUser = true,
                createFire = true,
                blockInteraction = BlockInteraction.TNT,
                smallParticle = Particles.ANGRY_VILLAGER,
                largeParticle = Particles.ANGRY_VILLAGER,
                sound = Sounds.Random.FUSE
            ) {
                radius(2)
            }
            ignite(2)
            playSound(SoundEvents.Entity.FireworkRocket.LAUNCH, 5f)
            replaceBlock(simpleStateProvider(Blocks.DIAMOND_BLOCK)) {
                offset(5, 5, 5)
                triggerGameEvent = GameEvents.BLOCK_PLACE
            }
            replaceDisk(simpleStateProvider(Blocks.DIAMOND_BLOCK)) {
                radius(5)
                height(2)
            }
            runFunction(FunctionArgument("function", "namespace"))
            setBlockProperties {
                properties {
                    this["test"] = "test"
                }
            }
            spawnParticles(
                Particles.ANGRY_VILLAGER,
                horizontalPositionType = ParticlePositionType.IN_BOUNDING_BOX,
                verticalPositionType = ParticlePositionType.IN_BOUNDING_BOX,
            ) {
                horizontalVelocity(base = 2.5f, movementScale = 1.2f)
            }
            summonEntity(EntityTypes.AREA_EFFECT_CLOUD)
        }
    }
}
Kotlin

linkItem Damage

Inflicts additional damage (i.e. worsening the item's condition).

enchantment("item_damage") {
    effects {
        itemDamage {
            add(5)
        }
    }
}
Kotlin

linkKnockback

Applies extra knockback to the target when attacking.

enchantment("knockback") {
    effects {
        knockback {
            add(5)
        }
    }
}
Kotlin

linkMob Experience

Increases the experience dropped by mobs upon death.

enchantment("mob_experience") {
    effects {
        mobExperience {
            add(5)
        }
    }
}
Kotlin

linkPost Attack

Executes effects immediately after an attack is completed. This effect can both apply a mob effect and cause damage.

enchantment("post_attack") {
    effects {
        postAttack {
            applyMobEffect(PostAttackSpecifier.ATTACKER, PostAttackSpecifier.DAMAGING_ENTITY, Effects.SPEED) {
                requirements {
                    weatherCheck(raining = true)
                }
            }
            damageEntity(PostAttackSpecifier.VICTIM, PostAttackSpecifier.DAMAGING_ENTITY, DamageTypes.IN_FIRE, 1, 2)
        }
    }
}
Kotlin

linkPrevent Armor Change

Prevents armor slots from being modified.

enchantment("prevent_armor_change") {
    effects {
        preventArmorChange()
    }
}
Kotlin

linkPrevent Equipment Drop

Stops equipment from being dropped on death.

enchantment("prevent_equipment_drop") {
    effects {
        preventEquipmentDrop()
    }
}
Kotlin

linkProjectile Count

Modifies the number of projectiles produced (for example, by a crossbow).

enchantment("projectile_count") {
    effects {
        projectileCount {
            add(5)
        }
    }
}
Kotlin

linkProjectile Spread

Alters the spread angle of projectiles fired.

enchantment("projectile_spread") {
    effects {
        projectileSpread {
            add(5)
        }
    }
}
Kotlin

linkRepair with XP

Repairs an item using player experience when the item is used.

enchantment("repair_with_xp") {
    effects {
        repairWithXp {
            add(5)
        }
    }
}
Kotlin

linkSmash Damage Per Fallen Block

Increases damage based on the number of blocks fallen before impact.

enchantment("smash_damage_per_fallen_block") {
    effects {
        smashDamagePerFallenBlock {
            add(5)
        }
    }
}
Kotlin

linkTick

Executes an effect periodically (every game tick). For example, dealing damage over time.

enchantment("tick") {
    effects {
        tick {
            damageEntity(DamageTypes.IN_FIRE, 1, 2)
        }
    }
}
Kotlin

linkTrident Return Acceleration

Accelerates the return speed of a thrown trident.

enchantment("trident_return_acceleration") {
    effects {
        tridentReturnAcceleration {
            add(5)
        }
    }
}
Kotlin

linkTrident Spin Attack Strength

Boosts the strength of a trident’s spin attack.

enchantment("trident_spin_attack_strength") {
    effects {
        tridentSpinAttackStrength {
            add(5)
        }
    }
}
Kotlin

linkTrident Sound

Modifies the sound played when a trident is thrown or returns.

enchantment("trident_sound") {
    effects {
        tridentSound {
            sound(SoundEvents.Entity.FireworkRocket.LAUNCH, 5f)
        }
    }
}
Kotlin

linkFurther 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!