#what MinecraftClient.getInstance().getWindow().setIcon(); expects?

7 messages · Page 1 of 1 (latest)

empty stag
#

I tryed lot of thing to set as icon whithout result

package ponchisaohosting.xyz.pzoom;

import net.fabricmc.api.ModInitializer;
import net.minecraft.client.MinecraftClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.awt.image.BufferedImage;
import javax.imageio.ImageIO;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;


public class PZoom implements ModInitializer {
    public static final String MOD_ID = "pzoom";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    private static final String ICON_URL = "https://ponchisaohosting.com/icon.png";


    @Override
    public void onInitialize() {
        LOGGER.info("PZOOM: Iniciando...");
        LOGGER.info("Autor: PonchisaoHosting (Ponchisao326)");
        MinecraftClient.getInstance().getWindow().setTitle("BLANCHINIILAND 3");
        try {
            BufferedImage iconImage = loadImageFromURL(ICON_URL);
            if (iconImage != null) {
                MinecraftClient.getInstance().getWindow().setIcon(iconImage);
            } else {
                LOGGER.error("No se pudo cargar el ícono del juego.");
            }
        } catch (IOException e) {
            LOGGER.error("Error al cargar el ícono del juego", e);
        }
    }

    private BufferedImage loadImageFromURL(String url) throws IOException {
        InputStream inputStream = new URL(url).openStream();
        BufferedImage image = ImageIO.read(inputStream);
        inputStream.close();
        return image;
    }
}
warm sierra
#

search for its usages and see

empty stag
warm sierra
empty stag
#

How can I do that?

placid wyvern
#

Double click on the mouse wheel (or long press can't remember) on the method you want to search for.
You need to have generated the sources with the genSources task first, and selected them.
(To select them the way I do it is do the middle click thing on a class and click on the select sources in top bar that appears(

empty stag
#
package ponchisaohosting.xyz.pzoom;

import net.fabricmc.api.ModInitializer;
import net.minecraft.client.MinecraftClient;
import net.minecraft.resource.InputSupplier;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import ponchisaohosting.xyz.pzoom.client.IconDownloader;

import java.io.IOException;
import java.io.InputStream;

public class PZoom implements ModInitializer {
    public static final String MOD_ID = "pzoom";
    public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
    private static final String SMALL_ICON_URL = "https://ponchisaohosting.xyz/blanchiniiland/mod_resources/small-icon.png";
    private static final String BIG_ICON_URL = "https://ponchisaohosting.xyz/blanchiniiland/mod_resources/big-icon.png";
    private InputStream smallIconStream;
    private InputStream bigIconStream;

    @Override
    public void onInitialize() {
        LOGGER.info("PZOOM: Iniciando...");
        LOGGER.info("Autor: PonchisaoHosting (Ponchisao326)");

        try {
            smallIconStream = IconDownloader.downloadIcon(SMALL_ICON_URL);
            bigIconStream = IconDownloader.downloadIcon(BIG_ICON_URL);
        } catch (IOException e) {
            LOGGER.error("No se ha podido descargar el icono ", e);
        }

        if (smallIconStream != null && bigIconStream != null) {
            MinecraftClient.getInstance().getWindow().setIcon((InputSupplier<InputStream>) smallIconStream, (InputSupplier<InputStream>) bigIconStream);
        } else {
            LOGGER.error("Los flujos de entrada de los iconos son nulos. No se puede establecer el ícono.");
        }
    }
}

Okay, I've tryed lots of things based on what did you tell me, but I'm still stucked.

When I checked for the usage I found that 'setIcon' is designed to stablish a window icon by using GLFW, it expects args like 'InputSupplier<InputStream>'