aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/moe/nea/firmament/init/RiserUtils.java
blob: 4c68dd478b910e65e806ec4e13848cd75421bb84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
 * SPDX-FileCopyrightText: 2024 Linnea Gräf <nea@nea.moe>
 *
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

package moe.nea.firmament.init;

import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.MappingResolver;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.ClassNode;
import org.objectweb.asm.tree.MethodNode;

public abstract class RiserUtils {
    protected Type getTypeForClassName(String className) {
        return Type.getObjectType(className.replace('.', '/'));
    }

    protected MappingResolver remapper = FabricLoader.getInstance().getMappingResolver();

    public abstract void addTinkerers();

    protected MethodNode findMethod(ClassNode classNode, String name, Type desc) {
        for (MethodNode method : classNode.methods) {
            if (method.name.equals(name) && desc.getDescriptor().equals(method.desc))
                return method;
        }
        return null;
    }

}