本文整理汇总了PHP中pocketmine\event\player\PlayerInteractEvent::getItem方法的典型用法代码示例。如果您正苦于以下问题:PHP PlayerInteractEvent::getItem方法的具体用法?PHP PlayerInteractEvent::getItem怎么用?PHP PlayerInteractEvent::getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\player\PlayerInteractEvent
的用法示例。
在下文中一共展示了PlayerInteractEvent::getItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBlock
public function onBlock(PlayerInteractEvent $event)
{
if (!$event->getPlayer()->hasPermission("Farms") and !$event->getPlayer()->hasPermission("Farms.VIP")) {
return;
}
$block = $event->getBlock()->getSide(1);
// Cocoa been
if ($event->getItem()->getId() == Item::DYE and $event->getItem()->getDamage() == 3) {
$tree = $event->getBlock()->getSide($event->getFace());
// Jungle wood
if ($tree->getId() == Block::WOOD and $tree->getDamage() == 3) {
$event->getBlock()->getLevel()->setBlock($event->getBlock()->getSide($event->getFace()), new CocoaBeanBlock($event->getFace()), true, true);
return;
}
}
// Farmland or sand
if ($event->getBlock()->getId() == Item::FARMLAND or $event->getBlock()->getId() == Item::SAND) {
foreach ($this->crops as $crop) {
if ($event->getItem()->getId() == $crop["item"]) {
$key = $block->x . "." . $block->y . "." . $block->z;
$this->farmData[$key]['id'] = $crop["block"];
$this->farmData[$key]['damage'] = 0;
$this->farmData[$key]['level'] = $block->getLevel()->getFolderName();
$this->farmData[$key]['time'] = $this->makeTimestamp(date("Y-m-d H:i:s"));
$this->farmData[$key]['growtime'] = $this->speedData[$event->getPlayer()->hasPermission("Farms.VIP") ? "vip-growing-time" : "growing-time"];
break;
}
}
}
}
示例2: onBlock
public function onBlock(PlayerInteractEvent $event)
{
if (!$event->getPlayer()->hasPermission("Farms")) {
return;
}
$block = $event->getBlock()->getSide(1);
$blockid = $block->getID();
$itemid = $event->getItem()->getID();
$itemdamage = $event->getItem()->getDamage();
if ($itemid == 351 and $itemdamage == 3) {
$tree = $event->getBlock()->getSide($event->getFace());
if ($tree->getID() == 17 or $tree->getDamage() == 3) {
$event->getBlock()->getLevel()->setBlock($event->getBlock()->getSide($event->getFace()), new CocoaBeanBlock($event->getFace()), true, true);
return true;
}
}
if ($event->getBlock()->getID() == Item::FARMLAND or $event->getBlock()->getID() == Item::SAND) {
foreach ($this->growids as $index => $growid) {
if ($itemid == $growid) {
$this->farmdata[$block->x . "." . $block->y . "." . $block->z]['id'] = $this->blockids[$index];
$this->farmdata[$block->x . "." . $block->y . "." . $block->z]['damage'] = 0;
$this->farmdata[$block->x . "." . $block->y . "." . $block->z]['time'] = $this->configdata["growing-time"];
break;
}
}
}
}
示例3: onBlockTap
/**
* @param PlayerInteractEvent $event
*
* @priority HIGH
*/
public function onBlockTap(PlayerInteractEvent $event)
{
// PowerTool
if ($this->getAPI()->executePowerTool($event->getPlayer(), $event->getItem())) {
$event->setCancelled(true);
}
}
示例4: onPlayerInteract
public function onPlayerInteract(PlayerInteractEvent $event)
{
$p = $event->getPlayer();
$i = $event->getItem();
if ($i->getID() !== 339 || ($money = $i->getDamage()) < 1) {
return;
}
$m = "[Check] ";
$ik = $this->isKorean();
if (!isset($this->touch[$n = $p->getName()])) {
$this->touch[$n] = 0;
}
$c = microtime(true) - $this->touch[$n];
if ($c > 0) {
$m .= $ik ? "수표를 사용하시려면 다시한번눌러주세요. \n 수표 정보 : " . $money . "\$" : "If you want to use this check, One more touch block \n Check Info : " . $money . "\$";
} else {
$i->setCount($i->getCount() - 1);
$p->getInventory()->setItem($p->getInventory()->getHeldItemSlot(), $i);
$this->giveMoney($p, $money);
$m .= $ik ? "수표를 사용하셨습니다.\n 수표 정보 : " . $money . "\$" : "You use the check. \n Check Info : " . $money . "\$";
}
$this->touch[$n] = microtime(true) + 1;
if (isset($m)) {
$p->sendMessage($m);
}
$event->setCancelled();
}
示例5: onInteract
/**
* @param PlayerInteractEvent $event
*
* @priority LOW
*/
public function onInteract(PlayerInteractEvent $event)
{
if ($event->getAction() !== PlayerInteractEvent::RIGHT_CLICK_BLOCK) {
return;
}
$player = $event->getPlayer();
$gamer = $this->hub->getGamerForPlayer($player);
$item = $event->getItem();
$block = $event->getBlock();
if ($block instanceof SignPost) {
$sign = $block->getLevel()->getTile($block);
if (!$sign instanceof Sign) {
unset($sign);
}
}
foreach ($this->hub->getJoinMethods() as $method) {
if (!$method->isLevelCorrect($player->getLevel())) {
continue;
}
if ($method instanceof KeyJoinMethod) {
if ($method->key === null or $method->key->equals($item, true, false)) {
if ($method->lock === null or $method->lock->equals($block)) {
$gamer->setModule($this->hub->getModule($method->target));
return;
}
}
} elseif (isset($sign) and $method instanceof SignJoinMethod) {
if ($method->matches($sign)) {
$gamer->setModule($this->hub->getModule($method->target));
return;
}
}
}
}
示例6: FurnaceTouch
public function FurnaceTouch(PlayerInteractEvent $event)
{
$block = $event->getBlock();
$player = $event->getPlayer();
$item = $event->getItem()->getID();
if ($block->getID() == Item::FURNACE or $block->getID() == Item::BURNING_FURNACE) {
$event->setCancelled(true);
if (isset($this->recipes[$item])) {
$coal = 0;
foreach ($player->getInventory()->getContents() as $inven) {
if (!$inven instanceof Item) {
return;
}
if ($inven->getID() == Item::COAL) {
$coal = $inven->getCount();
break;
}
}
if ($coal == Item::AIR and $item != Item::WOOD and !isset($this->coal_cache[$player->getName()])) {
$player->sendMessage(TextFormat::DARK_AQUA . "석탄이 없습니다 ! ( 원목으로 목탄을 만드세요 ! )");
} else {
$player->getInventory()->addItem(Item::get($this->recipes[$item]));
$player->getInventory()->removeItem(Item::get($item, $event->getItem()->getDamage()));
if ($item != Item::WOOD) {
if (!isset($this->coal_cache[$player->getName()])) {
$player->getInventory()->removeItem(Item::get(Item::COAL));
$this->coal_cache[$player->getName()] = 3;
} else {
$this->coal_cache[$player->getName()]--;
if ($this->coal_cache[$player->getName()] == 0) {
unset($this->coal_cache[$player->getName()]);
}
}
}
$player->sendMessage(TextFormat::DARK_AQUA . "성공적으로 구워졌습니다. (인벤토리 확인)");
}
} else {
$player->sendMessage(TextFormat::DARK_AQUA . "조합할 물건으로 터치시 조합 가능합니다 !");
}
if ($event->getItem()->isPlaceable()) {
$this->PlacePrevent[$player->getName()] = true;
}
}
}
示例7: onTouchCrate
public function onTouchCrate(PlayerInteractEvent $e)
{
if ($e->getBlock()->getId() == 54) {
if ($e->getItem()->getId() == $this->getConfig()->get("cratekey-item")) {
if ($e->getPlayer()->hasPermission("mysterycrates.crates.open")) {
$e->setCancelled();
$this->openCrate($e->getPlayer());
}
}
}
}
示例8: onPlayerInteract
public function onPlayerInteract(PlayerInteractEvent $event)
{
$i = $event->getItem();
$b = $event->getBlock();
$p = $event->getPlayer();
if ($b->getID() == 17 && $b->getDamage() == 3) {
if ($i->getID() == 351 && $i->getDamage() == 3) {
$f = $event->getFace();
if ($b->getSide($f)->getID() !== 0) {
return;
}
switch ($f) {
case 2:
$meta = 0;
break;
case 3:
$meta = 2;
break;
case 4:
$meta = 3;
break;
case 5:
$meta = 1;
break;
}
if (!isset($meta)) {
return;
}
$this->beanPlace($b->getSide($f), $meta);
if (!$p->isCreative()) {
$i = $p->getInventory()->getItemInHand();
$i->setCount($i->getCount() - 1);
$inv = $p->getInventory();
$inv->setItem($inv->getHeldItemSlot(), $i);
}
}
} elseif ($b->getID() == 127) {
if (!isset($this->grow[$this->getPos($b)])) {
$this->beanPlace($b, $b->getDamage());
}
if ($i->getID() == 351 && $i->getDamage() == 15) {
$this->beanGrow($b, true);
if (!$p->isCreative()) {
$i = $p->getInventory()->getItemInHand();
$i->setCount($i->getCount() - 1);
$inv = $p->getInventory();
$inv->setItem($inv->getHeldItemSlot(), $i);
}
}
}
}
示例9: onInteract
/**
* @param PlayerInteractEvent $ev
*/
public function onInteract(PlayerInteractEvent $ev)
{
if ($ev->getItem()->getId() == 296) {
$player = $ev->getPlayer();
$effect = Effect::getEffect(5);
$effect->setDuration(20 * 1000);
$effect->setAmplifier(1);
$player->getEffect($effect);
$effect1 = Effect::getEffect(4);
$effect1->setDuration(20 * 1000);
$effect1->setAmplifier(1);
$player->getEffect($effect1);
}
}
示例10: PlayerInteractEvent
public function PlayerInteractEvent(PlayerInteractEvent $ev)
{
$item = $ev->getItem();
$block = $ev->getBlock();
$player = $ev->getPlayer();
if ($ev->getAction() == PlayerInteractEvent::RIGHT_CLICK_BLOCK && $ev->getFace() !== 255) {
if ($player->hasPermission("worldedit.command.setpos2") && $item->getID() == $this->getData("tool-id", Item::IRON_HOE)) {
$player->sendMessage("[WorldEditor]Pos2 지점을 선택했어요 ({$block->x}, {$block->y}, {$block->z})");
self::$pos[$player->getName()][1] = $block->floor();
$ev->setCancelled();
return;
}
} elseif ($ev->getAction() == PlayerInteractEvent::LEFT_CLICK_AIR && $player->hasPermission("worldedit.command.setpos1") && $item->getID() == $this->getData("tool-id", Item::IRON_HOE)) {
$player->sendMessage("[WorldEditor]Pos1 지점을 선택했어요 ({$block->x}, {$block->y}, {$block->z})");
self::$pos[$player->getName()][0] = $block->floor();
return;
}
}
示例11: playerBlockTouch
public function playerBlockTouch(PlayerInteractEvent $event)
{
$sender = $event->getPlayer();
$block = $event->getBlock();
$item = $event->getItem()->getID();
$xyz = $block->x . ":" . $block->y . ":" . $block->z;
if (!($event->getBlock()->getID() == 323 or $event->getBlock()->getID() == 63 or $event->getBlock()->getID() == 68)) {
return;
}
$sign = $event->getPlayer()->getLevel()->getTile($block);
if (!$sign instanceof Sign) {
return;
}
$sign = $sign->getText();
if (!($sign[0] == "[터치시 돈 획득]")) {
return;
}
if (isset($sign[1])) {
if (!isset($this->list[$sender->getName()][$xyz]["time"])) {
$e = explode("\$", $sign[1]);
$money = $e[1];
$this->api->addMoney($sender, $money);
$sender->sendMessage(TextFormat::DARK_AQUA . "[안내] \$" . $money . "를 획득하셨습니다 !");
$this->list[$sender->getName()][$xyz]["time"] = date("d");
return;
} else {
if ($this->list[$sender->getName()][$xyz]["time"] != date("d")) {
$e = explode("\$", $sign[1]);
$money = $e[1];
$this->api->addMoney($sender, $money);
$sender->sendMessage(TextFormat::DARK_AQUA . "[안내] \$" . $money . "를 획득하셨습니다 !");
$this->list[$sender->getName()][$xyz]["time"] = date("d");
return;
} else {
$sender->sendMessage(TextFormat::RED . "[안내] 보상은 하루 한번만 가능합니다 !");
return;
}
}
} else {
$sender->sendMessage(TextFormat::RED . "[안내] 잘못된 표시판 ! 작동되지않습니다 !");
return;
}
}
示例12: onPlayerTouch
public function onPlayerTouch(PlayerInteractEvent $event)
{
$player = $event->getPlayer();
$block = $event->getBlock();
$item = $event->getItem()->getID();
if (!($block->getID() == 323 or $block->getID() == 63 or $block->getID() == 68)) {
return;
}
$sign = $event->getPlayer()->getLevel()->getTile($block);
if (!$sign instanceof Sign) {
return;
}
$sign = $sign->getText();
if (!($sign[0] == "[색상체크]")) {
return;
}
$player->sendMessage($this->getColorMessage($player));
$this->placeQueue[$player->getName()] = true;
}
示例13: groundPound
public function groundPound(PlayerInteractEvent $e)
{
$player = $e->getPlayer();
if ($e->getItem() == 256) {
$player->setMotion($jump = new Vector3(0, 0.5, 0));
$this->onGround = true;
$player->afftected = false;
//To not make the player be affected by the if in the pound() function
}
}
示例14: onPlayerTouch
public function onPlayerTouch(PlayerInteractEvent $event)
{
if ($event->getAction() !== PlayerInteractEvent::RIGHT_CLICK_BLOCK) {
return;
}
$block = $event->getBlock();
$loc = $block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName();
if (isset($this->shop[$loc])) {
$shop = $this->shop[$loc];
$player = $event->getPlayer();
if ($player->getGamemode() % 2 == 1) {
$player->sendMessage($this->getMessage("invalid-gamemode"));
$event->setCancelled();
return;
}
if (!$player->hasPermission("economyshop.shop.buy")) {
$player->sendMessage($this->getMessage("no-permission-buy"));
$event->setCancelled();
return;
}
if (!$player->getInventory()->canAddItem(Item::get($shop["item"], $shop["meta"]))) {
$player->sendMessage($this->getMessage("full-inventory"));
return;
}
$money = EconomyAPI::getInstance()->myMoney($player);
if ($shop["price"] > $money) {
$player->sendMessage($this->getMessage("no-money-buy", [$shop["item"] . ":" . $shop["meta"], $shop["price"], "%3"]));
$event->setCancelled(true);
if ($event->getItem()->isPlaceable()) {
$this->placeQueue[$player->getName()] = true;
}
return;
} else {
if (!isset($shop["itemName"])) {
$item = $this->getItem($shop["item"], $shop["meta"], $shop["amount"]);
if ($item === false) {
$item = $shop["item"] . ":" . $shop["meta"];
} else {
$item = $item[0];
}
$this->shop[$loc]["itemName"] = $item;
$shop["itemName"] = $item;
}
$now = microtime(true);
if ($this->getConfig()->get("enable-double-tap")) {
if (!isset($this->tap[$player->getName()]) or $now - $this->tap[$player->getName()][1] >= 1.5 or $this->tap[$player->getName()][0] !== $loc) {
$this->tap[$player->getName()] = [$loc, $now];
$player->sendMessage($this->getMessage("tap-again", [$shop["itemName"], $shop["price"], $shop["amount"]]));
return;
} else {
unset($this->tap[$player->getName()]);
}
}
$player->getInventory()->addItem(new Item($shop["item"], $shop["meta"], $shop["amount"]));
EconomyAPI::getInstance()->reduceMoney($player, $shop["price"], true, "EconomyShop");
$player->sendMessage($this->getMessage("bought-item", [$shop["amount"], $shop["itemName"], $shop["price"]]));
$event->setCancelled(true);
if ($event->getItem()->isPlaceable()) {
$this->placeQueue[$player->getName()] = true;
}
}
}
}
示例15: onPlayerInteract
public function onPlayerInteract(PlayerInteractEvent $event)
{
if ($event->getAction() !== PlayerInteractEvent::RIGHT_CLICK_BLOCK) {
return;
}
$loc = $this->getLocationByPosition($event->getBlock());
if (!isset($this->shops[$loc])) {
return;
}
$shopData = $this->shops[$loc];
if ($event->getItem()->isPlaceable()) {
array_push($this->placeQueue, $event->getPlayer());
}
$event->setCancelled();
if (!$event->getPlayer()->hasPermission("exchange.use")) {
$event->getPlayer()->sendMessage(TextFormat::RED . self::getTranslation("NO_PERMISSION_USE"));
return;
}
if (!$event->getPlayer()->getInventory()->contains(Item::get($shopData["from"]["id"], $shopData["from"]["damage"], $shopData["from"]["count"]))) {
$event->getPlayer()->sendMessage(TextFormat::RED . self::getTranslation("INSUFFICIENT_ITEM"));
return;
}
if (!$event->getPlayer()->getInventory()->canAddItem(Item::get($shopData["to"]["id"], $shopData["to"]["damage"], $shopData["to"]["count"]))) {
$event->getPlayer()->sendMessage(TextFormat::RED . self::getTranslation("INSUFFICIENT_INVENTORY"));
return;
}
if (!isset($this->doubleTap[$event->getPlayer()->getName()])) {
$this->setDoubleTap($event->getPlayer(), $loc);
return;
}
if ($this->doubleTap[$event->getPlayer()->getName()]["id"] !== $loc) {
$this->setDoubleTap($event->getPlayer(), $loc);
return;
}
if ($this->doubleTap[$event->getPlayer()->getName()]["time"] - microtime(true) >= 1.5) {
$this->setDoubleTap($event->getPlayer(), $loc);
return;
}
unset($this->doubleTap[$event->getPlayer()->getName()]);
$event->getPlayer()->sendMessage(TextFormat::AQUA . self::getTranslation("EXCHANGED"));
if (count($event->getPlayer()->getInventory()->removeItem(Item::get($shopData["from"]["id"], $shopData["from"]["damage"], $shopData["from"]["count"]))) <= 0) {
$event->getPlayer()->getInventory()->addItem(Item::get($shopData["to"]["id"], $shopData["to"]["damage"], $shopData["to"]["count"]));
}
}