Back to mods
Fallen Lib project artwork

CurseForge · Minecraft mod

Fallen Lib

A library providing runtime extension utilities

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

Quick answer

Which Fallen Lib release should I use?

Updated last month
Latest stable file fallen_lib-1.4.6.jar
Game version 1.20.1
Loader Forge

Fallen Lib fallen_lib-1.4.6.jar targets 1.20.1 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 Fallen Lib 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 Fallen Lib fallen_lib-1.4.6.jar need?

fallen_lib-1.4.6.jar. 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 Fallen Lib without breaking your instance.

Built for Fallen Lib fallen_lib-1.4.6.jar. Pick another file and the loader, install side or required mods may change.

  1. 01

    Stick to this file

    Use fallen_lib-1.4.6.jar. It targets 1.20.1 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 fallen_lib-1.4.6.jar. It opens that exact file at the source.

About this project

What does Fallen Lib add?

Fallen Lib is a small developer utility library.
It is currently used during development of Fallen Gems & Affixes.

This mod provides some ASM realted APIs and also runtime utilities for mod development.
It does not add any gameplay content and is not intended for normal players.

Development environment

Gradle

repositories {
    maven { url "https://rtxyd.github.io/maven-repo" }
}
dependencies {
    implementation fg.deobf("io.github.rtxyd:fallen-lib:1.4.6:core")
    implementation fg.deobf("io.github.rtxyd:fallen-lib:1.4.6:runtime")
}

Or you can download them in Additional Files section.

For normal gameplay or distribution, use the normal JAR.

Features

FallenPatch

A delegating API for patching mod classes.

It can hook exact classes or all subclasses,
which helps reduce repeated patches when extending mod behavior.

To use the API, you must implement the IFallenPatch interface, then the class must have the annotation @FallenPatch with correct parameters.

For example:

@FallenPatch(
        priority = 1000,
        targets = @Targets(
                exact = {SomeClass.class},
                subclass = {SuperClass.class}),
        inserters = {FallenInserters.class})
public class FallenPatch implements IFallenPatch {
    private final IPatchDescriptor desc;
    // Here you must provide a constructor like this.
    public FallenPatch(IFallenPatchCtorContext iFallenPatchCtorContext) {
        desc = iFallenPatchCtorContext.currentPatch();
    }

    @Override
    public void apply(ClassNode cn, IFallenPatchContext iFallenPatchContext) {
        MethodInsnNode hook = iFallenPatchContext.getFallenInserter(
                InserterKey.of("xxx.xxx.FallenInserters",
                        "hook",
                        InserterType.STANDARD_VOID));
        for (MethodNode method : cn.methods) {
            InsnList insns = method.instructions;
            if (insns == null) continue;
            PatchUtil.insertMethodHook(cn,
                    method,
                    m -> m instanceof MethodInsnNode mn
                            && mn.owner.equals("xxx.xxx.ClassName")
                            && mn.name.equals("methodName")
                            && mn.desc.startsWith("(Ljava/lang/Object;")
                            && Type.getReturnType(mn.desc).getSort() != Type.VOID,
                    InserterType.STANDARD_VOID,
                    hook,
                    false,
                    false);
        }
    }
}

The inserters targets a class which has at least 1 method with @FallenInserter annotation.
For example the FallenInserters.class:

public class FallenInserters {
    @FallenInserter(type = InserterType.STANDARD_VOID)
    public static void hook(IInserterContext<Object, Object> ctx, Object... args) {        Object rec = ctx.receiver();
    }
}

Then there should have an **xxx.fallen.json** file in your resource root.
Fomated as:

{
  "required": true,
  "min_version": "1.2.0",
  "package": "xxx.package.name",
  "fallen_patches": [
    "FallenPatch",
    "PatchClassName"
  ]
}

Currently, FallenPatch only supports patching mod classes.
Further support may be added in the future.

FallenInserter

Along with FallenPatch, use @FallenInserter on a method with correct parameter types and return type,

There are now 2 types of InserterType:

**InserterType.STANDARD**

**InserterType.STANDARD\_VOID**

the default is standard, which should be like following formats:

@FallenInserter(type = InserterType.STANDARD)
public static Object hook(IInserterContext<Object, Object> ctx, Object... args) {
    return ctx.ret();
}
@FallenInserter(type = InserterType.STANDARD_VOID)
public static void hook(IInserterContext<Object, Object> ctx, Object... args) {
}

the **ctx** has **ctx.receiver()** and **ctx.ret()** methods, which gives you the **this(may be null)** and return Object of the method you inserted, if it has return value and replaceReturn flag is true in the method, the return will replace the return value of orginal method, you can try following util **ObjectModifierFactory** to modify the numeric fields of this Object and return.

the **args** is an **Object[]** which contains all parameters of the method you inserted, InserterType.STANDARD is invoked after the method, so they are just a view, do not change them.

If you correctly configured and implement the IFallenPatch interface with correct annotation and then you can

 MehtodInsnNode hookMethod = iFallenPatchContext.getFallenInserter(
                InserterKey.of("your.class.name", 
                               "methodName", 
                               InserterType));

To get your hookMethod (if they have correct parameter types and return type, they will be buit by fallen lib)

Then use

PatchUtil.insertMethodHook()

To make easier patch (not as easy as mixin tho).


RuntimeUtility

Some runtime utilities.

**ObjectModifierFactory**:

Copies an object

Modifies numeric fields

Uses cache and field name filters

For example:

public class FallenInserters {    // this needs a Predicate<String>   private static final ObjectModifierFactory FACTORY = new ObjectModifierFactory(s -> {            String filedName = s.toLowerCase();            if (name.contains("xxx")) return true;            return false;});
   @FallenInserter(type = InserterType.STANDARD)
    public static Object hook(IInserterContext<Object, Object> ctx, Object... args) {        Object ret = ctx.ret()        return FACTORY.doSomething(ret);
    }
}

This is mainly used for runtime adjustments without modifying the original object.

Delegated Mixin Connector Registry: (above verison 1.3.2)

A service like registry, this makes you able to test in IDEA with conditionally loaded mixins configs by implementing the official IMixinConnector class in your mod.

Use like below, target a class that implements IMixinConnector, then config with a json in resources root with following format

{
  "required": true,
  "min_version": "1.3.2",
  "mixin_connector": "net.kayn.apotheotic_hostility.FGAMixinConnector"
}

the key "mixin_connector" should be your class reference.


Apotheosis Addon (Apotheosis installed only)

Extra Gem Bonus

You can now register extra gem bonuses in apotheosis 1.20.1 with a datapack just like 1.21.1

the structure should be **resources/namespace/extra\_gem\_bonuses/somegembonus.json**


Notes

This project has reached a usable state,
but APIs may still change as development continues.

Project description from CurseForge.

Pick your setup

Fallen Lib 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

Fallen Lib versions and loaders

10 of 10 releases match

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