
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
About this Mod
For 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
}
Available Versions
How to Install CodeEffect on Your Server
Order Server
Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).
Set fabric Loader
In the panel under "Egg", select the fabric loader and matching Minecraft version (1.21.1).
Install Mod
Open the mod browser in the dashboard and search for "CodeEffect". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.
Compatibility
Mod Loaders
Minecraft Versions
1.21.1, 1.21, 24w18a
Server-side
✓ RequiredRecommended RAM
4 GB(min. 3 GB)Frequently Asked Questions
CodeEffect server crashes on startup – what to do?
Most common cause: wrong fabric version or insufficient RAM. Check the server log (latest.log) for "OutOfMemoryError" or "Mixin" errors. With Mado Hosting: ensure at least 3 GB RAM is allocated and the loader matches the mod version (1.21.1). You can switch loaders with one click in the panel.
Is CodeEffect compatible with fabric?
CodeEffect officially supports fabric for Minecraft 1.21.1, 1.21, 24w18a. The Mado dashboard automatically detects incompatible loader combinations.
Server lagging with CodeEffect – how to optimize performance?
Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if CodeEffect consumes the most tick time. Common fixes: reduce server view-distance to 8-10, install "performant" or "starlight" as supplementary mods on Forge. With Mado Hosting, your server runs on NVMe SSDs with dedicated CPU cores for minimal latency.
Similar Mods
Rent Modded Server
Install CodeEffect with just one click on your server.