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

    Solved Potion inbuvable!!!

    1.7.x
    1.7.10
    3
    5
    1049
    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.
    • Yeyvo
      Yeyvo last edited by

      je n’arrive pas a boire ma potion

      import cpw.mods.fml.relauncher.Side;
      import cpw.mods.fml.relauncher.SideOnly;
      import net.minecraft.entity.player.EntityPlayer;
      import net.minecraft.init.Items;
      import net.minecraft.item.*;
      import net.minecraft.potion.Potion;
      import net.minecraft.potion.PotionEffect;
      import net.minecraft.world.World;
      
      public class Potionlait extends Item
      {
      
         public Potionlait()
         {
             setMaxStackSize(1);
         }
      
         @SideOnly(Side.CLIENT)
         public boolean hasEffect(ItemStack item)
         {
      
             return item != null;
         }
      
         public ItemStack onItemUseFinish(ItemStack itemstack, World World, EntityPlayer player)
         {
             player.clearActivePotions();
      
             player.addPotionEffect(new PotionEffect(Potion.confusion.id, 40, 1));
      
             return itemstack.stackSize <= 1 ? new ItemStack(Items.glass_bottle) : itemstack ;
         }
      
         public int getMaxItemUseDuration(ItemStack p_77626_1_)
         {
             return 25;
         }
      
         public EnumAction getItemUseAction(ItemStack p_77661_1_)
         {
             return EnumAction.drink;
         }
      
         public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player)
         {
             player.setItemInUse(itemstack, getMaxItemUseDuration(itemstack));
             return itemstack;
         }
      }
      

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

        Déjà ta méthode hasEffect est inutile, car jamais son stack stack en paramètre sera null car jamais cette méthode serait appelée avec un item null.
        Ensuite vire tous tes espaces et retour à la ligne, ton code sera plus lisible ainsi. Pour réaliser ceci un simpe aperçu de la classe ItemBucketMilk m’a suffi à réaliser cette classe. Après tu l’adaptes comme tu souhaites 😉

        
        public class TestSoda extends Item
        {
        public ItemStack onEaten(ItemStack stack, World world, EntityPlayer player)
        {
        if (!player.capabilities.isCreativeMode)
        {
        –stack.stackSize;
        }
        
        if (!world.isRemote)
        {
        player.clearActivePotions();
        player.addPotionEffect(new PotionEffect(Potion.confusion.id, 40, 1));
        }
        
        return stack.stackSize <= 0 ? new ItemStack(Items.glass_bottle) : stack;
        }
        
        /**
        * How long it takes to use or consume an item
        */
        public int getMaxItemUseDuration(ItemStack p_77626_1_)
        {
        return 25;
        }
        
        /**
        * returns the action that specifies what animation to play when the items is being used
        */
        public EnumAction getItemUseAction(ItemStack p_77661_1_)
        {
        return EnumAction.drink;
        }
        
        /**
        * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
        */
        public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
        {
        p_77659_3_.setItemInUse(p_77659_1_, this.getMaxItemUseDuration(p_77659_1_));
        return p_77659_1_;
        }
        }
        
        
        1 Reply Last reply Reply Quote 1
        • Yeyvo
          Yeyvo last edited by

          Bah voila grace a plaignon ça marche merci

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

            C’est Plaigon, sans ‘n’ et avec majuscule 😃

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

              @‘Plaigon’:

              C’est Plaigon, sans ‘n’ et avec majuscule 😃

              Plaignon XD

              Envoyé de mon 6039Y en utilisant Tapatalk

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

              MINECRAFT FORGE FRANCE © 2018

              Powered by NodeBB