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

Event setDamage

Comments in 'Plugin Development' started by Skullex, Feb 24, 2016.

  1. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    I wanna make sure I'm doing this right before I continue. I would have used
    Code:
    PHP_INT_MAX
    but then you can't set it (damage amount) via yml, or can you?

    PHP:
    <?php

    namespace Damage;

    use 
    pocketmine\event\entity\EntityDamageByEntityEvent;
    use 
    pocketmine\event\entity\EntityDamageEvent;
    use 
    pocketmine\Entity
    use pocketmine\event\Listener;
    use 
    pocketmine\plugin\PluginBase;

    class 
    Main extends PluginBase implements Listener{

        public function 
    onEnable(){
            
    $this->getServer()->getPluginManager()->registerEvents($this$this);
        }
       
        public function 
    onLoad(){
            
    $this->getLogger()->info("SetDamage enabled");
        }

                public function 
    onDamage(EntityDamageEvent $event){
                
    $entity $event->getEntity();
                if(
    $event instanceof EntityDamageByEntityEvent){
                
    $event->setDamage(5);
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    PHP_INT_MAX is generally used for two purposes:
    1. To represent an extremely large number without actually caring about how large it is. For example, set damage to PHP_INT_MAX and let PocketMine automatically adjust it.
    2. To use for advanced bitwise operations, which is too advanced that I won't explain here.
    Skullex likes this.
  3. Skullex
    Offline

    Skullex Active Member

    Joined:
    Nov 14, 2015
    Posts:
    212
    Minecraft User:
    Skullex
    Lol, ok thanks :D

Share This Page

Advertisement