Bonjours je souhaite créée mon propre mod 1.7.10
cependant je constate que j'ai un un probleme avec l'affichage de mon background voici mon code
si vous avais une suggestions
cependant je constate que j'ai un un probleme avec l'affichage de mon background voici mon code
Code:
package com.seqsss.client;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiMainMenu;
import net.minecraft.client.renderer.Tessellator;
import net.minecraft.util.ResourceLocation;
public class CustomMainMenu extends GuiMainMenu {
private static final ResourceLocation BACKGROUND_TEXTURE = new ResourceLocation("client:textures/gui/custom_background.png");
@Override
public void drawScreen(int mouseX, int mouseY, float partialTicks) {
// Désactiver les effets OpenGL
Minecraft.getMinecraft().entityRenderer.disableLightmap(1.0D);
// Dessiner l'arrière-plan personnalisé
Minecraft.getMinecraft().getTextureManager().bindTexture(BACKGROUND_TEXTURE);
drawModalRectWithCustomSizedTexture(0, 0, 0, 0, width, height, 512, 256); // adapte selon la taille de ta texture
// Dessiner les éléments par défaut (boutons et autres UI)
super.drawScreen(mouseX, mouseY, partialTicks);
// Réactiver les effets OpenGL
Minecraft.getMinecraft().entityRenderer.enableLightmap(1.0D);
}
private void drawModalRectWithCustomSizedTexture(int x, int y, float u, float v, int width, int height, float textureWidth, float textureHeight) {
float f = 1.0F / textureWidth;
float f1 = 1.0F / textureHeight;
Tessellator tessellator = Tessellator.instance;
tessellator.startDrawingQuads();
tessellator.addVertexWithUV(x, y + height, 0, u * f, (v + height) * f1);
tessellator.addVertexWithUV(x + width, y + height, 0, (u + width) * f, (v + height) * f1);
tessellator.addVertexWithUV(x + width, y, 0, (u + width) * f, v * f1);
tessellator.addVertexWithUV(x, y, 0, u * f, v * f1);
tessellator.draw();
}
@Override
public void initGui() {
super.initGui();
}
}
Dernière édition par un modérateur: