HookLib

HookLib

Framework for coremods

by
445 Downloads
forgelibrary
Rent Server with this Mod

About this Mod

Introduction

This is framework for coremods at MinecraftForge.

Basicaly, useful for mod developers.

Goal of this project is to provide an easy way to modify existing logic without directly changing code of it, but by writing your additional code.

Doesn't require knowledge of jvm bytecode.

Welp, kinda I'm late with publishing it project, bc Mixins took over the world, but I found out HookLib more handy, and I still have unimplemented good ideas, which will make it even better. So maybe it makes sense

Getting started

Understanding of hooks

When exists some code which you wanna to change, but its part of Minecraft or other mod, you can write something like:

@HookContainer
public class MyHooks {
    @Hook
    @OnBegin
    public static void resize(Minecraft mc, int x, int y) {
        System.out.println("Resize, x=" + x + ", y=" + y);
    }
}

HookLib will find method with name `resize` with two `int`'s arguments in class `Minecraft` and will insert call of MyHooks#resize to begin of found
target method.

Then you will see in console message when window resized.

Adding to project

  • Add dependency to build.gradle:

    repositories {
    maven {
    url "https://cursemaven.com"
    }
    }
    dependencies {
    implementation "curse.maven:hooklib:12345"
    }

  • Add VM option `-Dfml.coreMods.load=gloomyfolken.hooklib.minecraft.MainHookLoader`

It's possible by gradle too:

minecraft {
    mappings channel: 'snapshot', version: '20171003-1.12'

    runs {
        client {
            workingDirectory project.file('run')
            property "fml.coreMods.load", "gloomyfolken.hooklib.minecraft.MainHookLoader" //here
        }

        server {
            workingDirectory project.file('run')
            property "fml.coreMods.load", "gloomyfolken.hooklib.minecraft.MainHookLoader" //here
        }
    }
}
  • Perform Gradle Refresh in your ide

Next learning

Check our wiki for api details and advanced techniques

Roadmap

  • make HookLib to modloader for coremods

  • injection point at method call

  • way to print possible @LocalVariable arguments

  • injection point at expression

  • way to access to private variables

  • port to new versions of Minecraft

  • annotation processor for compile-time validation

  • configs for coremods

  • caching of target classes with applied hooks

Gratitudes

  • Thanks @GloomyFolken for original HookLib development!
  • Thanks @Foreck for cool logo!

Available Versions

hooklib 3.28release
MC 1.12.2forge
February 11, 2026
hooklib 3.17release
MC 1.12.2forge
April 13, 2025
hooklib 3.7release
MC 1.12.2forge
November 25, 2024

How to Install HookLib on Your Server

1

Order Server

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

2

Set forge Loader

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

3

Install Mod

Open the mod browser in the dashboard and search for "HookLib". Click "Install" – done! Alternatively, upload the .jar via SFTP to the /mods folder.

Compatibility

Mod Loaders

forge

Minecraft Versions

1.12.2

Server-side

~ Optional

Recommended RAM

4 GB(min. 3 GB)

Frequently Asked Questions

HookLib server crashes on startup – what to do?

Most common cause: wrong forge 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.12.2). You can switch loaders with one click in the panel.

Is HookLib compatible with forge?

HookLib officially supports forge for Minecraft 1.12.2. The Mado dashboard automatically detects incompatible loader combinations.

Server lagging with HookLib – how to optimize performance?

Recommended RAM: 4 GB (per 8 players). Use /spark profiler to check if HookLib 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 HookLib 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
MIT License
Server-side
Optional

Supported Versions

1.12.2