Mineuniverse
Log in Register
Mods

HookLib

Framework for coremods
by hohserg1
Download Claim this project
122,139 downloads
0 likes
Updated Jul 6, 2026
0 hypes
API and Library Utility & QoL

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

  • <s>make HookLib to modloader for coremods</s>
  • <s>injection point at method call</s>
  • <s>way to print possible @LocalVariable arguments</s>
  • <s>injection point at expression</s>
  • <s>way to access to private variables</s>
  • 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!
hooklib 3.28
MC Forge, 1.12.2
Release 2026-02-11 Get
hooklib 3.4
MC Forge, 1.12.2
Beta 2024-04-14 Get

More from hohserg1

Soulkeeper 2
775
Ender Compass (EnderCompass)
76,977
CursedSnow
327
ElegantNetworking
183,208
DimensionalLayers
1,162

You Might Also Like

Vivecraft
A Minecraft VR mod on a loader of your choice!
9,988,339
Athena
A crossplatform (Forge/Fabric) solution to connected block textures for 1.19.4+
99,799,527
Lodestone
A collection of code used throughout projects under the Lodestar team.
9,914,417
TheDragonLib
A library for most of sokratis12GR's Mods
9,910,232
Multi Mob Library
A library mod containing essential files for Daveyx0's mob mods
9,892,767
FTB Library (Forge) (Legacy)
FTB Library is a library mod that is used for some of our mods.
98,265,314