Back to mods
HookLib project artwork

CurseForge · Minecraft mod

HookLib

Framework for coremods

Choose a version Pick your version below, then grab the matching file.

Quick answer

Which HookLib release should I use?

Updated 9 months ago
Latest stable file hooklib 3.28
Game version 1.12.2
Loader Forge

hooklib 3.28 targets 1.12.2 with Forge. The project page does not say whether this file belongs on the client, dedicated server, or both. No extra mods listed for this file.

Where it goes

Is HookLib required on the client, server, or both?

The project page does not say whether this file belongs on the client, dedicated server, or both.

Client Source doesn’t say
Dedicated server Source doesn’t say
Loader for this release Forge
Required install it here Optional supported, not mandatory Not supported do not install here Source doesn’t say do not assume

The source does not explicitly classify this release as client-only or server-only.

What else does hooklib 3.28 need?

hooklib 3.28. Change the file and its required mods may change too.

No extra mods listed for this file

This file does not list any required mods. Do not add a library just because a different file uses it.

This file does not list any required or optional mods.

Before you install it

Add HookLib without breaking your instance.

Built for hooklib 3.28. Pick another file and the loader, install side or required mods may change.

  1. 01

    Stick to this file

    Use hooklib 3.28. It targets 1.12.2 with Forge; another release may have different loader, side or dependency requirements.

  2. 02

    Bring the mods it needs

    This file does not list any required mods. Do not add a library just because a different file uses it.

  3. 03

    Put it on the correct side

    The project page does not say whether this file belongs on the client, dedicated server, or both.

  4. 04

    Pick the file you checked

    Use the “Get this file” button beside hooklib 3.28. It opens that exact file at the source.

About this project

What does HookLib add?

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!

Project description from CurseForge.

Pick your setup

HookLib by Minecraft version and loader

Choose the version and loader you play, then open the matching release.

1 available setups

Check the dependencies, then try the file in a copied instance before changing a world you care about.

Recent files

HookLib versions and loaders

5 of 5 releases match

Looking for an older file? The official CurseForge project page is in Resources.