• S'inscrire
    • Se connecter
    • Recherche
    • Récent
    • Mots-clés
    • Populaire
    • Utilisateurs
    • Groupes

    Résolu Durabilités items

    1.7.x
    1.7.10
    2
    2
    595
    Charger plus de messages
    • Du plus ancien au plus récent
    • Du plus récent au plus ancien
    • Les plus votés
    Répondre
    • Répondre à l'aide d'un nouveau sujet
    Se connecter pour répondre
    Ce sujet a été supprimé. Seuls les utilisateurs avec les droits d'administration peuvent le voir.
    • ?
      Un Ancien Utilisateur dernière édition par

      j’ai créer un item voici sa class

      
      package com.adamitemod.mod.items;
      
      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import net.minecraft.entity.Entity;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.item.Item;
      import net.minecraft.item.ItemStack;
      import net.minecraft.nbt.NBTTagCompound;
      import net.minecraft.potion.Potion;
      import net.minecraft.potion.PotionEffect;
      import net.minecraft.util.ChatComponentTranslation;
      import net.minecraft.world.World;
      
      public class SpeedStick extends Item
      {
      
      public SpeedStick()
      {
      this.setMaxDamage(16);
      this.setMaxStackSize(1);
      }
      
      @Override
      public void onUpdate(ItemStack item, World world, Entity player, int slotIndex, boolean inHand)
      {
      if(item.hasTagCompound())//Si ton item n'a pas de tag alors on ne fait rien
      {
      if(item.stackTagCompound.getInteger("timer") > 0)//si ton timer est supérieur à 0 (après un clic droit logiquement)
      {
      item.stackTagCompound.setInteger("timer", (int) (item.stackTagCompound.getInteger("timer") + 1));//On l'incrémente de 1 à chaque tick
      }
      if(item.stackTagCompound.getInteger("timer") >= (int) (26*20))//Remplace 6 par le nombre de secondes du timer souhaité
      {
      item.stackTagCompound.setInteger("timer", 0);//On remet à 0 si le timer est arrivé à la limite souhaitée
      }
      }
      super.onUpdate(item, world, player, slotIndex, inHand);
      }
      
      public ItemStack onItemRightClick(ItemStack item, World world, EntityPlayer player)
      {
      if(!item.hasTagCompound())
      {
      item.setTagCompound(new NBTTagCompound());
      item.stackTagCompound.setInteger("timer", 0);
      }
      if(item.stackTagCompound.getInteger("timer") == 0)
      {
      player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 3));
      item.stackTagCompound.setInteger("timer", 1);
      }
      else
      {
      if(world.isRemote)
      player.addChatComponentMessage(new ChatComponentTranslation("Tu dois attendre que le baton se recharge !"));
      }
      return item;
      }
      
      @SideOnly(Side.CLIENT)
      public boolean hasEffect(ItemStack item)
      {
      return true;
      }
      }
      
      

      Mais il ne perd pas de dura comment faire sans les metadata ?

      1 réponse Dernière réponse Répondre Citer 0
      • Superloup10
        Superloup10 Modérateurs dernière édition par

        Dans la condition

        if(item.stackTagCompound.getInteger("timer") == 0)
        {
        player.addPotionEffect(new PotionEffect(Potion.moveSpeed.id, 200, 3));
        item.stackTagCompound.setInteger("timer", 1);
        }
        

        ajoute item.damageItem(1, player);

        Si vous souhaitez me faire un don, il vous suffit de cliquer sur le bouton situé en dessous.

        Je suis un membre apprécié et joueur, j'ai déjà obtenu 17 points de réputation.

        1 réponse Dernière réponse Répondre Citer 0
        • 1 / 1
        • Premier message
          Dernier message
        Design by Woryk
        Contact / Mentions Légales

        MINECRAFT FORGE FRANCE © 2018

        Powered by NodeBB