CodeEffect

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

by
300 Downloads
fabriclibrary
Rent Server with this Mod

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

[1.21] Version 1.0release
MC 1.21, 1.21.1fabric
July 8, 2024
[24w18a] Version 1.0release
MC 24w18afabric
May 5, 2024

How to Install CodeEffect on Your Server

1

Order Server

Order a Minecraft Java server with at least 3 GB RAM (4 GB recommended).

2

Set fabric Loader

In the panel under "Egg", select the fabric loader and matching Minecraft version (1.21.1).

3

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

fabric

Minecraft Versions

1.21.1, 1.21, 24w18a

Server-side

Required

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

Rent Modded Server

Install CodeEffect with just one click on your server.

Recommended RAM
4 GBab €8/mo
Min. 3 GB | +1 GB pro 8 Spieler
Create Server Now
1-Click Mod Install
NVMe SSD Storage
DDoS Protection included

Details

License
GNU Lesser General Public License v3.0 only
Server-side
Required

Supported Versions

1.21.11.2124w18a