Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How To Set A Item(s) Damage

Comments in 'Plugin Development' started by TryoneLegendZzz, Jul 18, 2015.

  1. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Ok So I Tired To Set A Items Damage (bow) And Tested It But It Didnt Work And Help?
  2. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    There Are Also No Code Errors Or Anything
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    You have to resend the item to the player's inventory.
  4. aliuly
    Offline

    aliuly Notable Member Plugin Developer

    Joined:
    Feb 8, 2014
    Posts:
    1,086
    Plugins:
    17
    This is what I do in Scorched (http://forums.pocketmine.net/plugins/scorched.1062/)
    PHP:
       // $p is a pocketmine\Player instance
        
    $hand $p->getInventory()->getItemInHand();
         if (
    $hand->getID() != Item::BOW) return;
         
    $hand->setDamage($hand->getDamage() + $this->cfg["usage"]);
         
    $p->getInventory()->setItemInHand($hand);
  5. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    Ok I Will Test This!
  6. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    is there a easier way cause i tryed this and the bow damage dosent change
  7. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Wait, do you mean the damage value of the item or the arrow's damage dealt?
  8. TryoneLegendZzz
    Offline

    TryoneLegendZzz Active Member

    Joined:
    May 31, 2015
    Posts:
    201
    Minecraft User:
    SavionLegendZzz
    arrows damage i want to change it
  9. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP:
    /**
     * @param  EntityDamageEvent
     * @ignoreCancelled true
     */
    public function onDamage(EntityDamageEvent $event){
      if(
    $event instanceof EntityDamageByChildEntityEvent){
        
    $child $event->getChild();
        if(
    $child instanceof Arrow){ // pocketmine\entity\Arrow
          
    $event->setDamage($newDamageExcludingArmorDamage);
        }
      }
    }

Share This Page

Advertisement