/*
 * Decompiled with CFR 0.152.
 * 
 * Could not load the following classes:
 *  net.minecraft.class_10090
 *  net.minecraft.class_10799
 *  net.minecraft.class_1806
 *  net.minecraft.class_1937
 *  net.minecraft.class_22
 *  net.minecraft.class_2960
 *  net.minecraft.class_327
 *  net.minecraft.class_332
 *  net.minecraft.class_5684
 *  net.minecraft.class_9209
 */
package meteordevelopment.meteorclient.utils.tooltip;

import meteordevelopment.meteorclient.MeteorClient;
import meteordevelopment.meteorclient.systems.modules.Modules;
import meteordevelopment.meteorclient.systems.modules.render.BetterTooltips;
import meteordevelopment.meteorclient.utils.tooltip.MeteorTooltipData;
import net.minecraft.class_10090;
import net.minecraft.class_10799;
import net.minecraft.class_1806;
import net.minecraft.class_1937;
import net.minecraft.class_22;
import net.minecraft.class_2960;
import net.minecraft.class_327;
import net.minecraft.class_332;
import net.minecraft.class_5684;
import net.minecraft.class_9209;

public class MapTooltipComponent
implements class_5684,
MeteorTooltipData {
    private static final class_2960 TEXTURE_MAP_BACKGROUND = class_2960.method_60654((String)"textures/map/map_background.png");
    private final int mapId;
    private final class_10090 mapRenderState = new class_10090();

    public MapTooltipComponent(int mapId) {
        this.mapId = mapId;
    }

    public int method_32661(class_327 textRenderer) {
        double scale = Modules.get().get(BetterTooltips.class).mapsScale.get();
        return (int)(144.0 * scale) + 2;
    }

    public int method_32664(class_327 textRenderer) {
        double scale = Modules.get().get(BetterTooltips.class).mapsScale.get();
        return (int)(144.0 * scale);
    }

    @Override
    public class_5684 getComponent() {
        return this;
    }

    public void method_32666(class_327 textRenderer, int x, int y, int width, int height, class_332 context) {
        float scale = Modules.get().get(BetterTooltips.class).mapsScale.get().floatValue();
        int size = (int)(144.0f * scale);
        context.method_25290(class_10799.field_56883, TEXTURE_MAP_BACKGROUND, x, y, 0.0f, 0.0f, size, size, size, size);
        class_22 mapState = class_1806.method_7997((class_9209)new class_9209(this.mapId), (class_1937)MeteorClient.mc.field_1687);
        if (mapState == null) {
            return;
        }
        context.method_51448().pushMatrix();
        context.method_51448().translate((float)x, (float)y);
        context.method_51448().scale(scale, scale);
        context.method_51448().translate(8.0f, 8.0f);
        MeteorClient.mc.method_61965().method_62230(new class_9209(this.mapId), mapState, this.mapRenderState);
        context.method_70857(this.mapRenderState);
        context.method_51448().popMatrix();
    }
}

