/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.fabricmc.loader.api.FabricLoader
 *  net.fabricmc.loader.api.MappingResolver
 */
package meteordevelopment.meteorclient.asm;

import meteordevelopment.meteorclient.asm.Descriptor;
import net.fabricmc.loader.api.FabricLoader;
import net.fabricmc.loader.api.MappingResolver;
import org.objectweb.asm.tree.FieldInsnNode;

public class FieldInfo {
    private String owner;
    private String name;
    private String descriptor;

    public FieldInfo(String owner, String name, Descriptor descriptor, boolean map) {
        if (map) {
            MappingResolver mappings = FabricLoader.getInstance().getMappingResolver();
            String ownerDot = owner.replace('/', '.');
            if (owner != null) {
                this.owner = mappings.mapClassName("intermediary", ownerDot).replace('.', '/');
            }
            if (name != null && descriptor != null) {
                this.name = mappings.mapFieldName("intermediary", ownerDot, name, descriptor.toString(false, false));
            }
        } else {
            this.owner = owner;
            this.name = name;
        }
        if (descriptor != null) {
            this.descriptor = descriptor.toString(false, map);
        }
    }

    public boolean equals(FieldInsnNode insn) {
        return !(this.owner != null && !insn.owner.equals(this.owner) || this.name != null && !insn.name.equals(this.name) || this.descriptor != null && !insn.desc.equals(this.descriptor));
    }
}

