本文整理汇总了PHP中pocketmine\event\player\PlayerAnimationEvent::getAnimationType方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerAnimationEvent::getAnimationType方法的具体用法?PHP PlayerAnimationEvent::getAnimationType怎么用?PHP PlayerAnimationEvent::getAnimationType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerAnimationEvent
的用法示例。
在下文中一共展示了PlayerAnimationEvent::getAnimationType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handleDataPacket
//.........这里部分代码省略.........
}
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
}
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
if ($cancelled) {
$ev->setCancelled();
}
$target->attack($ev->getFinalDamage(), $ev);
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($item->isTool() and $this->isSurvival()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
} else {
$this->inventory->setItemInHand($item, $this);
}
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or $this->dead === true) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk);
break;
case ProtocolInfo::SET_HEALTH_PACKET:
//Not used
break;
case ProtocolInfo::ENTITY_EVENT_PACKET:
if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
break;
}
$this->craftingType = 0;
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
//TODO: check if this should be true
switch ($packet->event) {
case 9:
//Eating
$this->eatFoodInHand();
break;
}
break;
case ProtocolInfo::DROP_ITEM_PACKET:
if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
break;
}
if (!$this->inventory->contains($packet->item)) {
$this->inventory->sendContents($this);
break;
}
$slot = $this->inventory->first($packet->item);
if ($slot == -1) {
break;
}
$item = $this->inventory->getItem($slot);
示例2: handleDataPacket
//.........这里部分代码省略.........
}
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
}
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
if ($cancelled) {
$ev->setCancelled();
}
$target->attack($ev->getFinalDamage(), $ev);
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($item->isTool() and $this->isSurvival()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
} else {
$this->inventory->setItemInHand($item, $this);
}
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or $this->dead === true) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk);
break;
case ProtocolInfo::RESPAWN_PACKET:
if ($this->spawned === false or $this->dead === false) {
break;
}
$this->craftingType = 0;
$this->server->getPluginManager()->callEvent($ev = new PlayerRespawnEvent($this, $this->getSpawn()));
$this->teleport($ev->getRespawnPosition());
$this->fireTicks = 0;
$this->airTicks = 300;
$this->deadTicks = 0;
$this->setHealth(20);
$this->dead = false;
$this->sendMetadata($this->getViewers());
$this->sendMetadata($this);
$this->sendSettings();
$this->inventory->sendContents($this);
$this->inventory->sendArmorContents($this);
$this->blocked = false;
$this->spawnToAll();
$this->scheduleUpdate();
break;
case ProtocolInfo::SET_HEALTH_PACKET:
//Not used
break;
case ProtocolInfo::ENTITY_EVENT_PACKET:
if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
break;
}
$this->craftingType = 0;
if ($this->inAction === true) {
示例3: handleDataPacket
//.........这里部分代码省略.........
}
}
}
$ev->useArmors();
}
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($this->isSurvival()) {
if ($item->isTool()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
} else {
$this->inventory->setItemInHand($item);
}
}
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk);
break;
case ProtocolInfo::SET_HEALTH_PACKET:
//Not used
break;
case ProtocolInfo::ENTITY_EVENT_PACKET:
if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
break;
}
$this->craftingType = self::CRAFTING_SMALL;
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
//TODO: check if this should be true
switch ($packet->event) {
case EntityEventPacket::USE_ITEM:
//Eating
$slot = $this->inventory->getItemInHand();
if ($slot->canBeConsumed()) {
$ev = new PlayerItemConsumeEvent($this, $slot);
if (!$slot->canBeConsumedBy($this)) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if (!$ev->isCancelled()) {
$slot->onConsume($this);
} else {
$this->inventory->sendContents($this);
}
}
break;
}
break;
case ProtocolInfo::DROP_ITEM_PACKET:
示例4: handleDataPacket
//.........这里部分代码省略.........
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($this->isSurvival()) {
if ($item->isTool()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
} else {
$this->inventory->setItemInHand($item);
}
}
$this->exhaust(0.3, PlayerExhaustEvent::CAUSE_ATTACK);
}
}
break;
default:
break;
//TODO: handle other actions
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk);
break;
case ProtocolInfo::SET_HEALTH_PACKET:
//Not used
break;
case ProtocolInfo::ENTITY_EVENT_PACKET:
if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
break;
}
$this->craftingType = self::CRAFTING_SMALL;
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
//TODO: check if this should be true
switch ($packet->event) {
case EntityEventPacket::USE_ITEM:
//Eating
$slot = $this->inventory->getItemInHand();
if ($slot->canBeConsumed()) {
$ev = new PlayerItemConsumeEvent($this, $slot);
if (!$slot->canBeConsumedBy($this)) {
$ev->setCancelled();
}
$this->server->getPluginManager()->callEvent($ev);
if (!$ev->isCancelled()) {
$slot->onConsume($this);
} else {
$this->inventory->sendContents($this);
}
}
break;
}
break;
case ProtocolInfo::DROP_ITEM_PACKET:
示例5: handleDataPacket
//.........这里部分代码省略.........
}
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
}
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
if ($cancelled) {
$ev->setCancelled();
}
$target->attack($ev->getFinalDamage(), $ev);
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($item->isTool() and $this->isSurvival()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1), $this);
} else {
$this->inventory->setItemInHand($item, $this);
}
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or $this->dead === true) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk->setChannel(Network::CHANNEL_WORLD_EVENTS));
break;
case ProtocolInfo::SET_HEALTH_PACKET:
//Not used
break;
case ProtocolInfo::ENTITY_EVENT_PACKET:
if ($this->spawned === false or $this->blocked === true or $this->dead === true) {
break;
}
$this->craftingType = 0;
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
//TODO: check if this should be true
switch ($packet->event) {
case 9:
//Eating
$items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 10, Item::BEETROOT_SOUP => 10, Item::BREAD => 5, Item::RAW_PORKCHOP => 3, Item::COOKED_PORKCHOP => 8, Item::RAW_BEEF => 3, Item::STEAK => 8, Item::COOKED_CHICKEN => 6, Item::RAW_CHICKEN => 2, Item::MELON_SLICE => 2, Item::GOLDEN_APPLE => 10, Item::PUMPKIN_PIE => 8, Item::CARROT => 4, Item::POTATO => 1, Item::BAKED_POTATO => 6, Item::COOKIE => 2, Item::COOKED_FISH => [0 => 5, 1 => 6], Item::RAW_FISH => [0 => 2, 1 => 2, 2 => 1, 3 => 1]];
$slot = $this->inventory->getItemInHand();
if ($this->getHealth() < $this->getMaxHealth() and isset($items[$slot->getId()])) {
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $slot));
if ($ev->isCancelled()) {
$this->inventory->sendContents($this);
break;
}
$pk = new EntityEventPacket();
$pk->eid = $this->getId();
$pk->event = 9;
$pk->setChannel(Network::CHANNEL_WORLD_EVENTS);
$this->dataPacket($pk);
Server::broadcastPacket($this->getViewers(), $pk);
$amount = $items[$slot->getId()];
if (is_array($amount)) {
$amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0;
示例6: handleDataPacket
//.........这里部分代码省略.........
$thornsEvent->useArmors();
$ev->setThornsArmorUse();
}
}
}
}
$ev->useArmors();
}
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($item->isTool() and $this->isSurvival()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
} else {
$this->inventory->setItemInHand($item);
}
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk);
break;
case ProtocolInfo::SET_HEALTH_PACKET:
//Not used
break;
case ProtocolInfo::ENTITY_EVENT_PACKET:
if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
break;
}
$this->craftingType = 0;
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
//TODO: check if this should be true
switch ($packet->event) {
case 9:
//Eating
$this->consumeHeldItem();
break;
}
break;
case ProtocolInfo::DROP_ITEM_PACKET:
if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
break;
}
if (!$this->inventory->contains($packet->item) or $this->isCreative() and $this->server->limitedCreative) {
$this->inventory->sendContents($this);
break;
}
$slot = $this->inventory->first($packet->item);
if ($slot == -1) {
$this->inventory->sendContents($this);
break;
}
示例7: handleDataPacket
//.........这里部分代码省略.........
}
$damage[EntityDamageEvent::MODIFIER_ARMOR] = -floor($damage[EntityDamageEvent::MODIFIER_BASE] * $points * 0.04);
}
$ev = new EntityDamageByEntityEvent($this, $target, EntityDamageEvent::CAUSE_ENTITY_ATTACK, $damage);
if ($cancelled) {
$ev->setCancelled();
}
$target->attack($ev->getFinalDamage(), $ev);
if ($ev->isCancelled()) {
if ($item->isTool() and $this->isSurvival()) {
$this->inventory->sendContents($this);
}
break;
}
if ($item->isTool() and $this->isSurvival()) {
if ($item->useOn($target) and $item->getDamage() >= $item->getMaxDurability()) {
$this->inventory->setItemInHand(Item::get(Item::AIR, 0, 1));
} else {
$this->inventory->setItemInHand($item);
}
}
}
break;
case ProtocolInfo::ANIMATE_PACKET:
if ($this->spawned === false or !$this->isAlive()) {
break;
}
$this->server->getPluginManager()->callEvent($ev = new PlayerAnimationEvent($this, $packet->action));
if ($ev->isCancelled()) {
break;
}
$pk = new AnimatePacket();
$pk->eid = $this->getId();
$pk->action = $ev->getAnimationType();
Server::broadcastPacket($this->getViewers(), $pk);
break;
case ProtocolInfo::SET_HEALTH_PACKET:
//Not used
break;
case ProtocolInfo::ENTITY_EVENT_PACKET:
if ($this->spawned === false or $this->blocked === true or !$this->isAlive()) {
break;
}
$this->craftingType = 0;
$this->setDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION, false);
//TODO: check if this should be true
switch ($packet->event) {
case 9:
//Eating
$items = [Item::APPLE => 4, Item::MUSHROOM_STEW => 10, Item::BEETROOT_SOUP => 10, Item::BREAD => 5, Item::RAW_PORKCHOP => 3, Item::COOKED_PORKCHOP => 8, Item::RAW_BEEF => 3, Item::STEAK => 8, Item::COOKED_CHICKEN => 6, Item::RAW_CHICKEN => 2, Item::MELON_SLICE => 2, Item::GOLDEN_APPLE => 10, Item::PUMPKIN_PIE => 8, Item::CARROT => 4, Item::POTATO => 1, Item::BAKED_POTATO => 6, Item::COOKIE => 2, Item::COOKED_FISH => 5, Item::COOKED_SALMON => 6, Item::RAW_FISH => 2, Item::RAW_SALMON => 2, Item::CLOWN_FISH => 1, Item::PUFFER_FISH => 1];
$slot = $this->inventory->getItemInHand();
if ($this->getHealth() < $this->getMaxHealth() and isset($items[$slot->getId()])) {
$this->server->getPluginManager()->callEvent($ev = new PlayerItemConsumeEvent($this, $slot));
if ($ev->isCancelled()) {
$this->inventory->sendContents($this);
break;
}
$pk = new EntityEventPacket();
$pk->eid = $this->getId();
$pk->event = EntityEventPacket::USE_ITEM;
$this->dataPacket($pk);
Server::broadcastPacket($this->getViewers(), $pk);
$amount = $items[$slot->getId()];
$ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING);
$this->heal($ev->getAmount(), $ev);
--$slot->count;