Skip to content

Mod Devs

benbenlaw edited this page Apr 3, 2026 · 2 revisions

Mod Devs

I have tried to make the system as modular as i can, Most of the modifier hook into the events system. Extending a modifier and then you can hook into any of the options that the modifier class makes available including, LivingDamageEvent.Post and Pre, BlockEvent.BreakEvent, PlayerInteractEvent.LeftClickBlock, RightClickBlock, RightClickItem and event more! After you have created the Modifier class you need to register it. Then lastly you need to create a modifier json saved in data/namespace/modifier/my_new_modifier.json . And thats basically it of course any help contact me on discord and will try my best to help

public class FortuneModifier extends Modifier {

    @Override
    public void onCalculateDrops(ItemStack fakeStack, ModifierData data, Level world, int toolLevel) {
        int effectiveLevel = Math.min(toolLevel, data.maxLevel());
        if (effectiveLevel > 0) {
            fakeStack.enchant(world.registryAccess().lookupOrThrow(Registries.ENCHANTMENT)
                    .getOrThrow(Enchantments.FORTUNE), effectiveLevel);
        }
    }

}
    public static final ResourceKey<Registry<Modifier>> KEY =
            ResourceKey.createRegistryKey(Identifier.parse("modifiers"));

    public static final DeferredRegister<Modifier> MODIFIERS =
            DeferredRegister.create(KEY, CastingTools.MOD_ID);

    public static final DeferredHolder<Modifier, FortuneModifier> FORTUNE = MODIFIERS.register("fortune", FortuneModifier::new);
{
  "description": "modifier.castingtools.fortune.description",
  "display_name": "modifier.castingtools.fortune",
  "experience_cost": 3000,
  "fluid": "casting:molten_lapis",
  "fluid_amount": 1350,
  "incompatible_modifiers": [
    "castingtools:silk_touch"
  ],
  "max_level": 3,
  "valid_items": [
    "#minecraft:pickaxes",
    "#minecraft:axes",
    "#minecraft:shovels",
    "#minecraft:hoes"
  ]
}

Clone this wiki locally