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

Tutorial [NEW-API] old api events and function to new api

Comments in 'Resources' started by swagboy47, Jul 11, 2014.

?

what do you think of this ?

  1. it's good :)

    6 vote(s)
    75.0%
  2. it's useless :P

    2 vote(s)
    25.0%
  1. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i well try my best to show you guys the changes between the old api and new api , there you go :) :

    blocks events
    pocketmine\event\block\BlockBreakEvent this is called when a player break's a block it's player.block.break in the old API , you could get the player who did the event by $event->getPlayer(), and you can get the item that the block got broke with with $event->getItem(), and you could get the block (data) with
    $event->getBlock that well get the data not the id or the name you can get the id by
    $event->getBlock->getID

    pocketmine\event\block\BlockPlaceEvent this is called when a player break's a block it's player.block.break in the old API , you can get the info the same way on pocketmine\event\block\BlockBreakEvent

    pocketmine\event\block\BlockEvent is called when any block event have been called and you can get the block by $event->getBlock()

    entity events
    pocketmine\event\entity\EntityArmorChangeEvent is called when a player change his armor from something to another, you can get the old armor by $event->getOldItem(), and you can get the new armor by $event->getNewItem() and you can also set the new armor by $event->setNewItem() , and you can get the entity by $event->getEntity() (note: entity could be anything it's not neccerily for players only )

    pocketmine\event\entity\EntityDamageByEntityEvent is called when an entity get damaged by another entity and you you can get the the entity that did the damage by $event->getDamager

    pocketmine\event\entity\EntityDamageEvent is called when an entity get damaged by anything (causes) you can get the cause withing $event->getCause() the causes ids are below
    CAUSE_CONTACT = 0
    CAUSE_ENTITY_ATTACK = 1
    CAUSE_PROJECTILE = 2
    CAUSE_SUFFOCATION = 3
    CAUSE_FALL = 4
    CAUSE_FIRE = 5
    CAUSE_FIRE_TICK = 6
    CAUSE_LAVA = 7
    CAUSE_DROWNING = 8
    CAUSE_BLOCK_EXPLOSION = 9
    CAUSE_ENTITY_EXPLOSION = 10
    CAUSE_VOID = 11
    CAUSE_SUICIDE = 12
    CAUSE_MAGIC = 13
    CAUSE_CUSTOM = 14
    ( and yes i did copy and paste from the docs -_-)

    it well be completed after i get a good feed back (otherwise it would be a waste of time) and i get some sleep

    18wyj2 and Pausbacke like this.
  2. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    It is getBlock()->getID() not getBlock->getID.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Note that handlers of EntityDamageEvent do not listen to calls of EntityDamageByEntityEvent.
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    getCuase() can return a(n) (constant) integer but could also return an instance of EntityDamageByEntityEvent.
  5. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    ops :p
  6. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    why not?

    edit
    never mind
  7. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i am aware of that :)
  8. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,306
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Look at the source yourself. The handler list is saved as a static instance.
  9. swagboy47
    Offline

    swagboy47 Active Member

    Joined:
    Jun 10, 2014
    Posts:
    445
    Minecraft User:
    swagking
    i have edited as you can see

Share This Page

Advertisement