Aller au contenu
chaos90

[1.x] Inserer le rendu 3D du joueur en jeu

Recommended Posts

Pas mal sa m'aide beaucoup , j'essaye d'afficher la durabiliter de chaque piece d'armure a coter du bonhome mais je n'y arrive pas :/ si quelqun a une idee...

un truc comme çà ?

http://youtu.be/hwl3J85-rMo

  • Upvote 1

Partager ce message


Lien à poster
Partager sur d’autres sites
package net.minecraft.client.gui.inventory;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.achievement.GuiAchievements;
import net.minecraft.client.gui.achievement.GuiStats;
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.client.resources.I18n;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;

import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

public class GuiInventory extends InventoryEffectRenderer
{
    private float field_147048_u;
    private float field_147047_v;
    private static final String __OBFID = "CL_00000761";
    private int decay;
    private int maxDecay;
    private boolean showArmorStats;
    private boolean statsSelected;
    
    public GuiInventory(EntityPlayer par1EntityPlayer)
    {
        super(par1EntityPlayer.inventoryContainer);
        this.field_146291_p = true;
    }

    /**
     * Called from the main game loop to update the screen.
     */
    public void updateScreen()
    {
        if (this.mc.playerController.isInCreativeMode())
            this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
        if (this.field_147003_i > 0 && this.field_147003_i != maxDecay)
        	maxDecay = this.field_147003_i;
        if (decay > 0 && showArmorStats)
        	decay -= maxDecay / 10;
        if (decay < maxDecay && !showArmorStats)
        	decay += maxDecay / 10;
        decay = decay < 0 ? 0 : (decay > maxDecay ? maxDecay : decay);
    }

    /**
     * Adds the buttons (and other controls) to the screen in question.
     */
    public void initGui()
    {
        this.buttonList.clear();

        if (this.mc.playerController.isInCreativeMode())
        {
            this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
        }
        else
        {
            super.initGui();
        }
        decay = maxDecay = this.field_147003_i;
    }

    protected void func_146979_b(int p_146979_1_, int p_146979_2_)
    {
        this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 86, 16, 4210752);
    }

    /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int par1, int par2, float par3)
    {
    	
        super.drawScreen(par1, par2, par3);
        this.field_147048_u = (float)par1;
        this.field_147047_v = (float)par2;
    }
    
    private void drawArmorStats()
    {
        float height = 0;
        String properties = "";
    	ItemArmor armor = null;
    	ArmorMaterial material = null;
    	String damage = "";
    	String reduce = "";
    	String durability = "";
    	String enchantability = "";
    	this.drawRect(decay, this.field_147009_r - 10, 20 + decay, this.field_147009_r + 1, 0xff989898);
    	GL11.glPushMatrix();
		GL11.glTranslatef(decay + 10, this.field_147009_r - 7, 0);
		GL11.glScalef(0.7f,  0.7f,  1);
    	this.drawCenteredString(this.mc.fontRenderer, "Stats", 0, 0, 0xffffffff);
    	GL11.glPopMatrix();
    	this.drawRect(decay, this.field_147009_r + 1, maxDecay + 1 + decay > maxDecay ? maxDecay : maxDecay + 1 + decay, this.field_147009_r + 84, 0xff989898);
    	this.drawRect(2 + decay, this.field_147009_r + 7, maxDecay - 2 + decay > maxDecay ? maxDecay : maxDecay - 2 + decay, this.field_147009_r + 79, 0xffdedede);
    	this.drawRect(3 + decay, this.field_147009_r + 8, maxDecay - 3 + decay > maxDecay ? maxDecay : maxDecay - 3 + decay, this.field_147009_r + 78, 0xff757575);
    	for (int i = 0; i < 3; ++i)
    		this.drawHorizontalLine(2 + decay, maxDecay - 3 + decay > maxDecay ? maxDecay : maxDecay - 3 + decay, this.field_147009_r + 24 + i * 18, 0xffdedede);
    	for (int i = 0; i < 4; ++i)
    	{
    		if (i > 0)
    			this.drawVerticalLine(60 + ((maxDecay - 60) / 3) * (i - 1) + decay > maxDecay ? maxDecay : 60 + (maxDecay - 60) / 3 * (i - 1) + decay, this.field_147009_r + 7, this.field_147009_r + 79, 0xffdedede);
    		ItemStack is = this.mc.thePlayer.getCurrentArmor(i);
    		if (is != null)
    		{
    			height = this.height / 2 - 69 + (4 - i - 1) * 17.8f;
    			armor = ((ItemArmor)is.getItem());
    			material= armor.getArmorMaterial();
    			damage = is.getMaxDamage() - is.getItemDamage() + "/" + is.getMaxDamage();
    			reduce = "" + armor.damageReduceAmount;
    			durability =  "" + material.getDurability(i);
    			enchantability = "" + armor.getItemEnchantability();
    			if (5 + decay > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(31.5f + decay, height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawCenteredString(this.mc.fontRenderer, damage, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    			if (60 + decay + ((maxDecay - 60) / 3) / 2 > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(60 + decay + ((maxDecay - 60) / 3) / 2, height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawCenteredString(this.mc.fontRenderer, reduce, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    			if (60 + decay + ((maxDecay - 60) / 2) > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(60 + decay + ((maxDecay - 60) / 2), height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawCenteredString(this.mc.fontRenderer, durability, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    			if (maxDecay - 4.5f - ((maxDecay - 60) / 3) / 2 > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(maxDecay - 4.5f - ((maxDecay - 60) / 3) / 2, height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawString(this.mc.fontRenderer, enchantability, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    		}
    	}
    }

    protected void func_146976_a(float p_146976_1_, int p_146976_2_, int p_146976_3_)
    {
    	drawArmorStats();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.getTextureManager().bindTexture(field_147001_a);
        int var4 = this.field_147003_i;
        int var5 = this.field_147009_r;
        this.drawTexturedModalRect(var4, var5, 0, 0, this.field_146999_f, this.field_147000_g);
        func_147046_a(var4 + 51, var5 + 75, 30, (float)(var4 + 51) - this.field_147048_u, (float)(var5 + 75 - 50) - this.field_147047_v, this.mc.thePlayer);
    }

    public static void func_147046_a(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_)
    {
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        GL11.glPushMatrix();
        GL11.glTranslatef((float)p_147046_0_, (float)p_147046_1_, 50.0F);
        GL11.glScalef((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_);
        GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
        float var6 = p_147046_5_.renderYawOffset;
        float var7 = p_147046_5_.rotationYaw;
        float var8 = p_147046_5_.rotationPitch;
        float var9 = p_147046_5_.prevRotationYawHead;
        float var10 = p_147046_5_.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)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
        p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F;
        p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F;
        p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F;
        p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw;
        p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw;
        GL11.glTranslatef(0.0F, p_147046_5_.yOffset, 0.0F);
        RenderManager.instance.playerViewY = 180.0F;
        RenderManager.instance.func_147940_a(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
        p_147046_5_.renderYawOffset = var6;
        p_147046_5_.rotationYaw = var7;
        p_147046_5_.rotationPitch = var8;
        p_147046_5_.prevRotationYawHead = var9;
        p_147046_5_.rotationYawHead = var10;
        GL11.glPopMatrix();
        RenderHelper.disableStandardItemLighting();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    }
    
    @Override
    public void handleMouseInput()
    {
	int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
	int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;

	statsSelected = false;
    	if (x >= decay && x <= 20 + decay && y >= this.field_147009_r - 10 && y <= this.field_147009_r + 1)
    	    statsSelected = true;
    	super.handleMouseInput();
    }
	
    @Override
    public void mouseClicked(int x, int y, int k)
    {
	if (statsSelected)
	    showArmorStats = !showArmorStats;
	super.mouseClicked(x, y, k);
    }

    protected void actionPerformed(GuiButton p_146284_1_)
    {
        if (p_146284_1_.id == 0)
        {
            this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.func_146107_m()));
        }

        if (p_146284_1_.id == 1)
        {
            this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.func_146107_m()));
        }
    }
}

Partager ce message


Lien à poster
Partager sur d’autres sites

ba c'est le même genre de code mais dans GuiIngame à peu près où tu veut dans renderGameOverlay:

    	for (int i = 0; i < 4; ++i)
    	{
    		ItemStack is = this.mc.thePlayer.getCurrentArmor(4 - i - 1);
    		if (is != null)
    		{
    			ItemArmor armor = ((ItemArmor)is.getItem());
    			material= armor.getArmorMaterial();
    			durability =  "" + material.getDurability(i);
                        this.mc.fontRenderer.drawString(durability, posX, posY + i * 10, 0xffffffff); // posX et posY sont les coordonnées du premier affichage
    		}
    	}

Partager ce message


Lien à poster
Partager sur d’autres sites

ba c'est le même genre de code mais dans GuiIngame à peu près où tu veut dans renderGameOverlay:

    	for (int i = 0; i < 4; ++i)
    	{
    		ItemStack is = this.mc.thePlayer.getCurrentArmor(i);
    		if (is != null)
    		{
    			ItemArmor armor = ((ItemArmor)is.getItem());
    			material= armor.getArmorMaterial();
    			durability =  "" + material.getDurability(i);
                        this.mc.fontRenderer.drawString(durability, posX, posY + i * 10, 0xffffffff); // posX et posY sont les coordonnées du premier affichage
    		}
    	}

sa ne marche pas chez moi rien ne s'affiche.

Partager ce message


Lien à poster
Partager sur d’autres sites

Un tuto oral c'est une raison pour dire "ça sert a rien de comprendre tant que ça marche" limite ?

Non, un tuto oral ou écrit c'est pareil, il n'a aucun intéret de suivre un tuto pour apprendre a copier coller. De plus on apprends rien..

  • Downvote 1

Partager ce message


Lien à poster
Partager sur d’autres sites

Uitlisation abusive du mot 'truc', confusion entre launcher et client, trop sommaire explication des paramètres des fonctions, confusion entre fields et fonctions, beaucoup de choses sont « totalement normales » sans pour autant que tu nous expliques pourquoi, explication de l'imposibilité de mettre le joueur en bas à droite et qu'il y reste alors que c'est possible, copie d'une même fonction alors qu'il aurait suffit de faire un appel static...

Essaye de plus expliquer ce que tu dis, ça aidera beaucoup ceux qui te regardent. ;)

  • Upvote 1
  • Downvote 1

Partager ce message


Lien à poster
Partager sur d’autres sites
package net.minecraft.client.gui.inventory;

import net.minecraft.client.gui.GuiButton;
import net.minecraft.client.gui.achievement.GuiAchievements;
import net.minecraft.client.gui.achievement.GuiStats;
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.client.resources.I18n;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemArmor;
import net.minecraft.item.ItemArmor.ArmorMaterial;
import net.minecraft.item.ItemStack;

import org.lwjgl.input.Mouse;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;

public class GuiInventory extends InventoryEffectRenderer
{
    private float field_147048_u;
    private float field_147047_v;
    private static final String __OBFID = "CL_00000761";
    private int decay;
    private int maxDecay;
    private boolean showArmorStats;
    private boolean statsSelected;
    
    public GuiInventory(EntityPlayer par1EntityPlayer)
    {
        super(par1EntityPlayer.inventoryContainer);
        this.field_146291_p = true;
    }

    /**
     * Called from the main game loop to update the screen.
     */
    public void updateScreen()
    {
        if (this.mc.playerController.isInCreativeMode())
            this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
        if (this.field_147003_i > 0 && this.field_147003_i != maxDecay)
        	maxDecay = this.field_147003_i;
        if (decay > 0 && showArmorStats)
        	decay -= maxDecay / 10;
        if (decay < maxDecay && !showArmorStats)
        	decay += maxDecay / 10;
        decay = decay < 0 ? 0 : (decay > maxDecay ? maxDecay : decay);
    }

    /**
     * Adds the buttons (and other controls) to the screen in question.
     */
    public void initGui()
    {
        this.buttonList.clear();

        if (this.mc.playerController.isInCreativeMode())
        {
            this.mc.displayGuiScreen(new GuiContainerCreative(this.mc.thePlayer));
        }
        else
        {
            super.initGui();
        }
        decay = maxDecay = this.field_147003_i;
    }

    protected void func_146979_b(int p_146979_1_, int p_146979_2_)
    {
        this.fontRendererObj.drawString(I18n.format("container.crafting", new Object[0]), 86, 16, 4210752);
    }

    /**
     * Draws the screen and all the components in it.
     */
    public void drawScreen(int par1, int par2, float par3)
    {
    	
        super.drawScreen(par1, par2, par3);
        this.field_147048_u = (float)par1;
        this.field_147047_v = (float)par2;
    }
    
    private void drawArmorStats()
    {
        float height = 0;
        String properties = "";
    	ItemArmor armor = null;
    	ArmorMaterial material = null;
    	String damage = "";
    	String reduce = "";
    	String durability = "";
    	String enchantability = "";
    	this.drawRect(decay, this.field_147009_r - 10, 20 + decay, this.field_147009_r + 1, 0xff989898);
    	GL11.glPushMatrix();
		GL11.glTranslatef(decay + 10, this.field_147009_r - 7, 0);
		GL11.glScalef(0.7f,  0.7f,  1);
    	this.drawCenteredString(this.mc.fontRenderer, "Stats", 0, 0, 0xffffffff);
    	GL11.glPopMatrix();
    	this.drawRect(decay, this.field_147009_r + 1, maxDecay + 1 + decay > maxDecay ? maxDecay : maxDecay + 1 + decay, this.field_147009_r + 84, 0xff989898);
    	this.drawRect(2 + decay, this.field_147009_r + 7, maxDecay - 2 + decay > maxDecay ? maxDecay : maxDecay - 2 + decay, this.field_147009_r + 79, 0xffdedede);
    	this.drawRect(3 + decay, this.field_147009_r + 8, maxDecay - 3 + decay > maxDecay ? maxDecay : maxDecay - 3 + decay, this.field_147009_r + 78, 0xff757575);
    	for (int i = 0; i < 3; ++i)
    		this.drawHorizontalLine(2 + decay, maxDecay - 3 + decay > maxDecay ? maxDecay : maxDecay - 3 + decay, this.field_147009_r + 24 + i * 18, 0xffdedede);
    	for (int i = 0; i < 4; ++i)
    	{
    		if (i > 0)
    			this.drawVerticalLine(60 + ((maxDecay - 60) / 3) * (i - 1) + decay > maxDecay ? maxDecay : 60 + (maxDecay - 60) / 3 * (i - 1) + decay, this.field_147009_r + 7, this.field_147009_r + 79, 0xffdedede);
    		ItemStack is = this.mc.thePlayer.getCurrentArmor(i);
    		if (is != null)
    		{
    			height = this.height / 2 - 69 + (4 - i - 1) * 17.8f;
    			armor = ((ItemArmor)is.getItem());
    			material= armor.getArmorMaterial();
    			damage = is.getMaxDamage() - is.getItemDamage() + "/" + is.getMaxDamage();
    			reduce = "" + armor.damageReduceAmount;
    			durability =  "" + material.getDurability(i);
    			enchantability = "" + armor.getItemEnchantability();
    			if (5 + decay > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(31.5f + decay, height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawCenteredString(this.mc.fontRenderer, damage, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    			if (60 + decay + ((maxDecay - 60) / 3) / 2 > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(60 + decay + ((maxDecay - 60) / 3) / 2, height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawCenteredString(this.mc.fontRenderer, reduce, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    			if (60 + decay + ((maxDecay - 60) / 2) > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(60 + decay + ((maxDecay - 60) / 2), height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawCenteredString(this.mc.fontRenderer, durability, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    			if (maxDecay - 4.5f - ((maxDecay - 60) / 3) / 2 > maxDecay)
    				continue;
    			GL11.glPushMatrix();
    			GL11.glTranslatef(maxDecay - 4.5f - ((maxDecay - 60) / 3) / 2, height, 0);
    			GL11.glScalef(0.7f,  0.7f,  1);
    			this.drawString(this.mc.fontRenderer, enchantability, 0, 0, 0xffffffff);
    			GL11.glPopMatrix();
    		}
    	}
    }

    protected void func_146976_a(float p_146976_1_, int p_146976_2_, int p_146976_3_)
    {
    	drawArmorStats();
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        this.mc.getTextureManager().bindTexture(field_147001_a);
        int var4 = this.field_147003_i;
        int var5 = this.field_147009_r;
        this.drawTexturedModalRect(var4, var5, 0, 0, this.field_146999_f, this.field_147000_g);
        func_147046_a(var4 + 51, var5 + 75, 30, (float)(var4 + 51) - this.field_147048_u, (float)(var5 + 75 - 50) - this.field_147047_v, this.mc.thePlayer);
    }

    public static void func_147046_a(int p_147046_0_, int p_147046_1_, int p_147046_2_, float p_147046_3_, float p_147046_4_, EntityLivingBase p_147046_5_)
    {
        GL11.glEnable(GL11.GL_COLOR_MATERIAL);
        GL11.glPushMatrix();
        GL11.glTranslatef((float)p_147046_0_, (float)p_147046_1_, 50.0F);
        GL11.glScalef((float)(-p_147046_2_), (float)p_147046_2_, (float)p_147046_2_);
        GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F);
        float var6 = p_147046_5_.renderYawOffset;
        float var7 = p_147046_5_.rotationYaw;
        float var8 = p_147046_5_.rotationPitch;
        float var9 = p_147046_5_.prevRotationYawHead;
        float var10 = p_147046_5_.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)(p_147046_4_ / 40.0F))) * 20.0F, 1.0F, 0.0F, 0.0F);
        p_147046_5_.renderYawOffset = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 20.0F;
        p_147046_5_.rotationYaw = (float)Math.atan((double)(p_147046_3_ / 40.0F)) * 40.0F;
        p_147046_5_.rotationPitch = -((float)Math.atan((double)(p_147046_4_ / 40.0F))) * 20.0F;
        p_147046_5_.rotationYawHead = p_147046_5_.rotationYaw;
        p_147046_5_.prevRotationYawHead = p_147046_5_.rotationYaw;
        GL11.glTranslatef(0.0F, p_147046_5_.yOffset, 0.0F);
        RenderManager.instance.playerViewY = 180.0F;
        RenderManager.instance.func_147940_a(p_147046_5_, 0.0D, 0.0D, 0.0D, 0.0F, 1.0F);
        p_147046_5_.renderYawOffset = var6;
        p_147046_5_.rotationYaw = var7;
        p_147046_5_.rotationPitch = var8;
        p_147046_5_.prevRotationYawHead = var9;
        p_147046_5_.rotationYawHead = var10;
        GL11.glPopMatrix();
        RenderHelper.disableStandardItemLighting();
        GL11.glDisable(GL12.GL_RESCALE_NORMAL);
        OpenGlHelper.setActiveTexture(OpenGlHelper.lightmapTexUnit);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        OpenGlHelper.setActiveTexture(OpenGlHelper.defaultTexUnit);
    }
    
    @Override
    public void handleMouseInput()
    {
	int x = Mouse.getEventX() * this.width / this.mc.displayWidth;
	int y = this.height - Mouse.getEventY() * this.height / this.mc.displayHeight - 1;

	statsSelected = false;
    	if (x >= decay && x <= 20 + decay && y >= this.field_147009_r - 10 && y <= this.field_147009_r + 1)
    	    statsSelected = true;
    	super.handleMouseInput();
    }
	
    @Override
    public void mouseClicked(int x, int y, int k)
    {
	if (statsSelected)
	    showArmorStats = !showArmorStats;
	super.mouseClicked(x, y, k);
    }

    protected void actionPerformed(GuiButton p_146284_1_)
    {
        if (p_146284_1_.id == 0)
        {
            this.mc.displayGuiScreen(new GuiAchievements(this, this.mc.thePlayer.func_146107_m()));
        }

        if (p_146284_1_.id == 1)
        {
            this.mc.displayGuiScreen(new GuiStats(this, this.mc.thePlayer.func_146107_m()));
        }
    }
}

Tu la en 1.8 SVP

Partager ce message


Lien à poster
Partager sur d’autres sites

ba c'est le même genre de code mais dans GuiIngame à peu près où tu veut dans renderGameOverlay:

    	for (int i = 0; i < 4; ++i)
    	{
    		ItemStack is = this.mc.thePlayer.getCurrentArmor(4 - i - 1);
    		if (is != null)
    		{
    			ItemArmor armor = ((ItemArmor)is.getItem());
    			material= armor.getArmorMaterial();
    			durability =  "" + material.getDurability(i);
                        this.mc.fontRenderer.drawString(durability, posX, posY + i * 10, 0xffffffff); // posX et posY sont les coordonnées du premier affichage
    		}
    	}

Bonsoir,

Je m'excuse mais le code fournis en haut ne correspond pas à celui de votre vidéo

Merci de donner les bonnes sources

Partager ce message


Lien à poster
Partager sur d’autres sites

Créer un compte ou se connecter pour commenter

Vous devez être membre afin de pouvoir déposer un commentaire

Créer un compte

Créez un compte sur notre communauté. C’est facile !

Créer un nouveau compte

Se connecter

Vous avez déjà un compte ? Connectez-vous ici.

Connectez-vous maintenant

×