1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Teaspoon in does not work for the enchant

Discussion in 'Development' started by manyDARK, Jul 24, 2018.

  1. manyDARK

    manyDARK Spider

    Messages:
    8
    GitHub:
    many1337
    I transcribed 1.4 things to 1.2, and entityDamageByEntityEvent can not execute it.
    Error Code:
    Code:
    Could not pass event 'pocketmine\event\entity\EntityDamageByEntityEvent' to 'TeaSpoon v1.0.0': Call to undefined method pocketmine\event\entity\EntityDamageByEntityEvent::getModifier() on CortexPE\handlers\EnchantHandler
    2018-07-24 [08:28:02] [Server thread/CRITICAL]: Error: "Call to undefined method pocketmine\event\entity\EntityDamageByEntityEvent::getModifier()" (EXCEPTION) in "TeaSpoon-master/src/CortexPE/handlers/EnchantHandler" at line 123
    Plugin PHP:
    PHP:
        public function onDamage(EntityDamageEvent $ev){
            
    $e $ev->getEntity();
            if(
    $ev->isCancelled()){
                return;
            }
            if(
    $ev instanceof EntityDamageByEntityEvent){
                
    $d $ev->getDamager();
                if(!(
    $d instanceof Entity) || !$d->isAlive()){
                    return;
                }
                if(
    $d instanceof PMPlayer && $e instanceof Living){
                    
    $i $d->getInventory()->getItemInHand();
                    
    $damage $ev->getModifier(EntityDamageEvent::MODIFIER_ARMOR);
                    
    $knockback $ev->getKnockBack();
                    foreach(
    Utils::getEnchantments($i) as $ench){
                        
    $lvl $ench->getLevel();
                        switch(
    $ench->getId()){
                            case 
    Enchantment::FIRE_ASPECT:
                                
    $e->setOnFire(($lvl 4) * 20);
                                break;
                            case 
    Enchantment::KNOCKBACK:
                                
    $ev->setKnockBack(($knockback 0.3) * $lvl);
                                break;
                            case 
    Enchantment::PUNCH:
                                if(
    $d->getInventory()->getItemInHand()->getId() == Item::BOW){
                                    
    $ev->setKnockBack(($knockback 0.2) * $lvl);
                                }
                                break;
                            case 
    Enchantment::BANE_OF_ARTHROPODS:
                                if(
    Utils::in_arrayi($e->getName(), self::BANE_OF_ARTHROPODS_AFFECTED_ENTITIES)){
                                    
    $ev->setModifier($damage + ($lvl 2.5), EntityDamageEvent::MODIFIER_ARMOR);
                                }
                                break;
                            case 
    Enchantment::POWER:
                                if(
    $i->getId() == Item::BOW){
                                    
    $ev->setModifier($damage + ((($damage 0.25) * $lvl) + 1), EntityDamageEvent::MODIFIER_ARMOR);
                                }
                                break;
                            case 
    Enchantment::SMITE:
                                
    $ev->setModifier($damage + ($lvl 2.5), EntityDamageEvent::MODIFIER_ARMOR);
                                break;
                            case 
    Enchantment::SHARPNESS:
                                
    $ev->setModifier($damage + (($lvl 0.4) + 1), EntityDamageEvent::MODIFIER_ARMOR);
                                break;
                        }
                    }
    Server Software basic 1.2 EntityDamageByEntityEvent file.
     
  2. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    EntityDamageEvent::getModifier() and relevant methods weren't implemented until May of this year, quite a while after the version you're currently using. This means you need to no longer use getModifier and instead use getDamage(EntityDamageEvent::MODIFIER_ARMOR). I'm not sure why you want to use such an old version, because it'll be a pain to revert all the API changes in your plugin.
     
    Awzaw likes this.
  3. manyDARK

    manyDARK Spider

    Messages:
    8
    GitHub:
    many1337
    My server is version 1.2, and plugins were solved with AllAPPLoader. Soo no problem i just need to have the enchant and I can not solve it with mas plugin. There are other plugins, only the more problems this is the easy one.
     
  4. Awzaw

    Awzaw Zombie Pigman Poggit Admin

    Messages:
    726
    GitHub:
    awzaw
    I doubt very much you are going to get any help with such a messy setup. There's no telling what bad side-effects you'll have using AllAPILoader to force recent plugins to run with such an outdated version of PocketMine, and nobody in their right mind is going to waste time fixing Teaspoon for that; you could revert all the changes since 1.2, but you'll lose all the fixes that were made since.
     
  5. manyDARK

    manyDARK Spider

    Messages:
    8
    GitHub:
    many1337
    I resolved without help..
     
    Last edited by a moderator: Jul 28, 2018
  6. artulloss

    artulloss Witch

    Messages:
    63
    GitHub:
    artulloss
    Just look through old GitHub commit files if u need old versions...
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.