Non résolu RE:Timer
-
Bonjour, je voudrais faire un timer mais sans succes.
package com.extremium.mod; import org.lwjgl.opengl.GL11; import com.extremium.mod.init.DisplayHelper; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; import net.minecraftforge.event.entity.living.LivingEvent.LivingUpdateEvent; public class GuiStamina extends Gui { int stamina = 0; int Timer = 0; final ResourceLocation FullStamina = new ResourceLocation(Reference.MOD_ID + ":textures/items/StaminaFull.png"); final ResourceLocation Stamina1 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina1.png"); final ResourceLocation Stamina2 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina2.png"); final ResourceLocation Stamina3 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina3.png"); final ResourceLocation Stamina4 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina4.png"); final ResourceLocation Stamina5 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina5.png"); final ResourceLocation Stamina6 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina6.png"); final ResourceLocation Stamina7 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina7.png"); final ResourceLocation Stamina8 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina8.png"); final ResourceLocation Stamina9 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina9.png"); final ResourceLocation Stamina10 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina10.png"); final ResourceLocation Stamina11 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina11.png"); final ResourceLocation Stamina12 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina12.png"); final ResourceLocation Stamina13 = new ResourceLocation(Reference.MOD_ID + ":textures/items/Stamina13.png"); final ResourceLocation StaminaVide = new ResourceLocation(Reference.MOD_ID + ":textures/items/StaminaVide.png"); public void onUpdate(ItemStack stack, World world, Entity entity, int id, boolean isCurrent) { if(Timer < 60) { Timer ++; } if (Timer == 60) { stamina ++; Timer = 0; } } public GuiStamina(Minecraft mc) { GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F); GL11.glDisable(2896); GL11.glEnable(3042); GL11.glBlendFunc(770, 771); if(stamina == 0) { mc.getTextureManager().bindTexture(this.StaminaVide); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65, 0.0D); } if(stamina == 1) { mc.getTextureManager().bindTexture(this.Stamina1); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 2) { mc.getTextureManager().bindTexture(this.Stamina2); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 3) { mc.getTextureManager().bindTexture(this.Stamina3); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 4) { mc.getTextureManager().bindTexture(this.Stamina4); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 5) { mc.getTextureManager().bindTexture(this.Stamina5); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 6) { mc.getTextureManager().bindTexture(this.Stamina6); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 7) { mc.getTextureManager().bindTexture(this.Stamina7); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 8) { mc.getTextureManager().bindTexture(this.Stamina8); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 9) { mc.getTextureManager().bindTexture(this.Stamina9); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 10) { mc.getTextureManager().bindTexture(this.Stamina10); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 11) { mc.getTextureManager().bindTexture(this.Stamina11); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 12) { mc.getTextureManager().bindTexture(this.Stamina12); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 13) { mc.getTextureManager().bindTexture(this.Stamina13); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } if(stamina == 14) { mc.getTextureManager().bindTexture(this.FullStamina); DisplayHelper.drawTexturedQuadFit(5, 50, 60.0D, 65.0D, 0.0D); } } }
-
Tu doit je pense utiliser les extends Entity Properties pour stocker ton timer sur le joueur (tuto: https://www.minecraftforgefrance.fr/topic/799/extended-entity-properties) car si non ton timer ne seras pas prit en compte sur un serveur (supposition)