
ModsJava
CodeEffect
Adds a new enchantment effect that runs a method registered by a mod for 24w18a's new data-driven enchantments. Similar to its run_function but with code
⬇ Download on ModrinthFor Users
This mod doesn't do anything on its own. This library allows mods to call code in data-driven enchantments.
For Devs
Registering your code:
CodeEffect.register(HOOK_ID, (world, level, context, user, pos) -> {
// Code Here
});
or
CodeEffect.register(HOOK_ID, this::stuff);
// ...
public void stuff(ServerWorld world, int level, EnchantmentEffectContext context, Entity user, Vec3d pos) {
// Code Here
}
Using it:
"effect": {
"type": "code_effect:run_code",
"hook": "HOOK_ID"
}
Full Enchantment example:
Sharpness but modified to run the code every tick
{
"anvil_cost": 1,
"description": {
"translate": "enchantment.minecraft.sharpness"
},
"effects": {
"minecraft:tick": [
{
"effect": {
"type": "code_effect:run_code",
"hook": "HOOK_ID"
}
}
]
},
"exclusive_set": "#minecraft:exclusive_set/damage",
"max_cost": {
"base": 21,
"per_level_above_first": 11
},
"max_level": 5,
"min_cost": {
"base": 1,
"per_level_above_first": 11
},
"primary_items": "#minecraft:enchantable/sword",
"slots": [
"mainhand"
],
"supported_items": "#minecraft:enchantable/weapon",
"weight": 10
}
Quick facts
- Edition: Minecraft Java
- File type: .jar
- Minecraft versions listed: 1.21, 1.21.1
- How to install: Install the matching mod loader (Forge, Fabric or NeoForge) for your Minecraft version. → Download the .jar. → Put it in the .minecraft/mods folder and launch that loader profile.
- Where to get it: Opens on Modrinth — not every file is mirrored on our own servers.
Install steps are the general flow for this file type — How to install Minecraft Java mods & modpacks walks through it step by step.
Verified by MCModsHub
- Ships as CodeEffect-1.0+1.21.jar — drop this file into the mods folder
- Download size: 20 KB
- Download link checked 7 Sept 2026 — working
These come from our own check of the pack file, not from the source page.