Résolu Problème d'ouverture de Custom Inventaire / Bouton dans l'inventaire
-
Alors mon problème c’est que ça crash avec ceci (je sais que c’est n’importe quoi mais avant j’avais un code qui marchait et je ne l’ai plus et j’ai tenté des choses…) :
Le Gui Custom (inventaire):
package fr.gungamecraft.benjaminloison.common; import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL12; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.entity.EntityClientPlayerMP; import net.minecraft.client.gui.inventory.GuiContainerCreative; import net.minecraft.client.renderer.InventoryEffectRenderer; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.entity.RenderManager; import net.minecraft.entity.EntityLivingBase; import net.minecraft.inventory.Container; @SideOnly(Side.CLIENT) public class GuiInventaire extends InventoryEffectRenderer { public GuiInventaire(Container thePlayer) { super(thePlayer); } public GuiInventaire(EntityClientPlayerMP thePlayer) { super(null); } private float xSizeFloat; private float ySizeFloat; public void updateScreen() { if (this.mc.playerController.isInCreativeMode()) { this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer)); } } protected void drawGuiContainerForegroundLayer() { /* * this.fontRendererObj.drawString(Minecraft.getMinecraft().thePlayer. * getDisplayName(), 70, 40, 0xFFFFFF); */ this.fontRendererObj.drawString("NIVEAU: ", 85, 85, 0xFFFFFF); this.fontRendererObj.drawString("PV", 200, 40, 0xFFFFFF); this.fontRendererObj.drawString("XP", 200, 60, 0xFFFFFF); this.fontRendererObj.drawString("Membre", 30, 85, 0xFE9A2E); /* * this.fontRendererObj.drawString("CREDITS: 1000", 68, 60, 0xFFFFFF); * this.fontRendererObj.drawString("2562/3120", 68, 160, 0x424242); * this.fontRendererObj.drawString("8%", 68, 180, 0x424242); */ } public void drawScreen(int x, int y, float z) { this.xSizeFloat = (float) x; this.ySizeFloat = (float) y; int k = this.guiLeft; int l = this.guiTop; GL11.glColor4f(1, 1, 1, 1); /* * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, * "textures/gui/GrisFonce.png")); drawTexturedModalRect(20, 20, 0, 0, * 340, 80); mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Gris.png")); * drawTexturedModalRect(20, 100, 0, 0, 340, 110); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(220, 40, 0, 0, 100, 1); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(220, 48, 0, 0, 100, 1); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(220, 40, 0, 0, 1, 9); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(320, 40, 0, 0, 1, 9); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(220, 60, 0, 0, 100, 1); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(220, 68, 0, 0, 100, 1); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(220, 60, 0, 0, 1, 9); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Blanc.png")); * drawTexturedModalRect(320, 60, 0, 0, 1, 9); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Bleu.png")); * drawTexturedModalRect(28, 35, 0, 0, 100, 46); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/Pseudo.png")); * drawTexturedModalRect(29, 36, 0, 0, 46, 44); * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, * "textures/gui/GrisFonceU.png")); drawTexturedModalRect(20, 100, 0, 0, * 340, 2); */ joueur(k + 51, l + 150, 30, (float) (k + 51) - this.xSizeFloat, (float) (l + 150 - 50) - this.ySizeFloat, this.mc.thePlayer); /* * mc.renderEngine.bindTexture(new * ResourceLocation(ModGunGameCraft.MODID, "textures/gui/TOUT.png")); * drawTexturedModalRect(20, 0, 0, 0, 256, 256); */ drawGuiContainerForegroundLayer(); super.drawScreen(x, y, z); } public static void joueur(int int1, int int2, int int3, float flo1, float flo2, EntityLivingBase entity) { GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glPushMatrix(); GL11.glTranslatef((float) int1, (float) int2, 50.0F); GL11.glScalef((float) (-int3), (float) int3, (float) int3); GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); float f2 = entity.renderYawOffset; float f3 = entity.rotationYaw; float f4 = entity.rotationPitch; float f5 = entity.prevRotationYawHead; float f6 = entity.rotationYawHead; GL11.glRotatef(135.0F, 0.0F, 1.0F, 0.0F); RenderHelper.enableStandardItemLighting(); GL11.glRotatef(-135.0F, 0.0F, 1.0F, 0.0F); GL11.glRotatef(-((float) Math.atan((double) (flo2 / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F); entity.renderYawOffset = (float) Math.atan((double) (flo1 / 40.0F)) * 20.0F; entity.rotationYaw = (float) Math.atan((double) (flo1 / 40.0F)) * 40.0F; entity.rotationPitch = -((float) Math.atan((double) (flo2 / 40.0F))) * 20.0F; entity.rotationYawHead = entity.rotationYaw; entity.prevRotationYawHead = entity.rotationYaw; GL11.glTranslatef(0.0F, entity.yOffset, 0.0F); RenderManager.instance.playerViewY = 180.0F; RenderManager.instance.renderEntityWithPosYaw(entity, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F); entity.renderYawOffset = f2; entity.rotationYaw = f3; entity.rotationPitch = f4; entity.prevRotationYawHead = f5; entity.rotationYawHead = f6; GL11.glPopMatrix(); RenderHelper.disableStandardItemLighting(); GL11.glDisable(GL12.GL_RESCALE_NORMAL); OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit); GL11.glDisable(GL11.GL_TEXTURE_2D); OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit); } public void initGui() { buttonList.add(new GuiAC(0, 0, 0, "TEST")); super.initGui(); } @Override protected void drawGuiContainerBackgroundLayer(float flo, int x, int y) { } }
Mon ClientProxy qui permet son ouverture:
package fr.gungamecraft.benjaminloison.proxy; import cpw.mods.fml.client.FMLClientHandler; import cpw.mods.fml.common.FMLCommonHandler; import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.gameevent.TickEvent; import cpw.mods.fml.relauncher.SideOnly; import fr.gungamecraft.benjaminloison.common.GuiInventaire; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.GuiScreen; import net.minecraft.client.gui.inventory.GuiInventory; public class ClientProxy extends CommonProxy { public void registerRender() { FMLCommonHandler.instance().bus().register(this); System.out.println("Méthode côté client"); } @SubscribeEvent @SideOnly(cpw.mods.fml.relauncher.Side.CLIENT) public void onTickInv(TickEvent.ClientTickEvent event) { Minecraft mc = FMLClientHandler.instance().getClient(); GuiScreen currentScreen = mc.currentScreen; if ((mc.currentScreen != null) && (mc.currentScreen.getClass().equals(GuiInventory.class))) { Minecraft.getMinecraft().displayGuiScreen(new GuiInventaire(Minecraft.getMinecraft().thePlayer)); } } }
Voilà et sinon aussi j’aimerais rajouter un bouton dans l’inventaire mais le extends du Gui ne le permet pas et j’ai essayé quelque modifs mais ça ne marche pas des conseils ?
Merci d’avance de votre aide vous êtes géniaux ! -
public GuiInventaire(EntityClientPlayerMP thePlayer) {
super(null);
}….
Supprimes ce constructeur.
Et à la place de :
Minecraft.getMinecraft().displayGuiScreen(new GuiInventaire(Minecraft.getMinecraft().thePlayer));
mets :
Minecraft.getMinecraft().displayGuiScreen(new GuiInventaire(Minecraft.getMinecraft().thePlayer.inventory)); -
Je l’ai fait mais il y a une erreur pour le .inventory: The constructor GuiInventaire(InventoryPlayer) is undefined.
Voilà et sinon des conseils pour les boutons ?
-
Sorry, utilises inventoryContainer
-
Merci beaucoup !
EDIT: Juste maintenant ça me met le fond sombre et les slots de l’inventaire de Minecraft je fais comment pour enlever tout ça je recréer la classe InventoryEffectRenderer ?
-
Tu veux virer les slots de l’inventaire de base ? pour ça faut modifier le container.
-
Oui comment faire plus exactement ?
-