Navigation

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups

    SOLVED Faire un temps d'attendre apres l'utilisation d'un objet

    1.7.x
    1.7.10
    4
    7
    1417
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • pulgan
      pulgan last edited by

      bonjour a tous

      je cherche le moyen de faire en sorte que si le joeur utilise un item il doivent attendre un moment avant de pouvoir réutiliser l’itm
      et faire en sorte également que si le joueurarrete le temps d’attente cela recommence
      pour l’action j’ai regarder au  niveau de l’arc il y l’event canceled

      merci pour vos réponses

      1 Reply Last reply Reply Quote 0
      • Deleted
        Deleted last edited by

        Une condition qui valide un timer je pense

        1 Reply Last reply Reply Quote 0
        • pulgan
          pulgan last edited by

          timer ? j’ai jamais fait de timer tu sait comment faire?

          1 Reply Last reply Reply Quote 0
          • robin4002
            robin4002 Administrateurs Rédacteurs Moddeurs confirmés last edited by

            Je ne vois pas ce qu’il y a de compliqué dans l’arc …

            ​    public int getMaxItemUseDuration(ItemStack stack)
            
                {
                    return 72000;
                }
            

            Temps maximum d’utilisation

            ​    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
            
                {
                    player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
                    return stack;
                }
            

            Fait que le joueur utilise l’item lors du clic droit

            ​    public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time)
                {
            // lorsque le joueur lâche le clic droit, time correspond au temps durant lequel il a chargé l'item
                }
            
            1 Reply Last reply Reply Quote 0
            • pulgan
              pulgan last edited by

              @‘robin4002’:

              Je ne vois pas ce qu’il y a de compliqué dans l’arc …

              ​    public int getMaxItemUseDuration(ItemStack stack)
              
                  {
                      return 72000;
                  }
              

              Temps maximum d’utilisation

              ​    public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player)
              
                  {
                      player.setItemInUse(stack, this.getMaxItemUseDuration(stack));
                      return stack;
                  }
              

              Fait que le joueur utilise l’item lors du clic droit

              ​    public void onPlayerStoppedUsing(ItemStack stack, World world, EntityPlayer player, int time)
                  {
              // lorsque le joueur lâche le clic droit, time correspond au temps durant lequel il a chargé l'item
                  }
              

              je sais que rien n’est compliquer dans l’arc je ne sais juste pas faire de timer

              1 Reply Last reply Reply Quote 0
              • Ama
                Ama last edited by

                ​public class ItemTestCoolDown extends Item
                
                {
                protected int cooldown = 0;
                protected int twentyMin = 24000; //20 minutes d'attente avant chaques utilisations 24000 = ticks minecraft
                
                public ItemTestCoolDown() 
                {
                super();
                this.setCreativeTab(BOTICore.blocks);
                }
                
                @Override
                public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
                {
                cooldown = cooldown + 1;
                if(cooldown == twentyMin)
                {
                ((EntityPlayer) entity).addChatMessage((new ChatComponentText(EnumChatFormatting.GREEN + "You can use it now !")));
                }
                
                }
                
                @Override
                public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
                
                if(!par2World.isRemote)
                {
                //CODE ICI
                cooldown = 0; 
                }
                return par1ItemStack;
                }
                

                Cadeau !

                1 Reply Last reply Reply Quote 0
                • pulgan
                  pulgan last edited by

                  @‘ZeAmateis’:

                  ​public class ItemTestCoolDown extends Item
                  
                  {
                  protected int cooldown = 0;
                  protected int twentyMin = 24000; //20 minutes d'attente avant chaques utilisations 24000 = ticks minecraft
                  
                  public ItemTestCoolDown() 
                  {
                  super();
                  this.setCreativeTab(BOTICore.blocks);
                  }
                  
                  @Override
                  public void onUpdate(ItemStack stack, World world, Entity entity, int par4, boolean par5)
                  {
                  cooldown = cooldown + 1;
                  if(cooldown == twentyMin)
                  {
                  ((EntityPlayer) entity).addChatMessage((new ChatComponentText(EnumChatFormatting.GREEN + "You can use it now !")));
                  }
                   
                  }
                  
                  @Override
                  public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) {
                  
                  if(!par2World.isRemote)
                  {
                  //CODE ICI
                  cooldown = 0; 
                  }
                  return par1ItemStack;
                  }
                  

                  Cadeau !

                  Merci beaucoup ! Sa va me faire avancer je change le sujet en résolu

                  1 Reply Last reply Reply Quote 0
                  • 1 / 1
                  • First post
                    Last post
                  Design by Woryk
                  Contact / Mentions Légales / Faire un don

                  MINECRAFT FORGE FRANCE © 2018

                  Powered by NodeBB