本文整理汇总了PHP中pocketmine\event\block\BlockBreakEvent::getItem方法的典型用法代码示例。如果您正苦于以下问题:PHP BlockBreakEvent::getItem方法的具体用法?PHP BlockBreakEvent::getItem怎么用?PHP BlockBreakEvent::getItem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\event\block\BlockBreakEvent
的用法示例。
在下文中一共展示了BlockBreakEvent::getItem方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onBreak
public function onBreak(BlockBreakEvent $event)
{
$player = $event->getPlayer();
if ($player->isCreative()) {
return;
}
$time = round(microtime(true) * 1000);
if ($event->getBlock()->getBreakTime($event->getItem()) <= 0.2) {
return;
}
if ($time - $this->tictock[$player->getName()] <= 200) {
if (!isset($this->kick[$player->getName()])) {
$this->kick[$player->getName()] = 1;
} else {
$this->kick[$player->getName()]++;
}
if ($this->kick > 2) {
$player->kick("파괴자모드 감지");
if (isset($this->kick[$player->getName()])) {
unset($this->kick[$player->getName()]);
}
}
$event->setCancelled();
} else {
if (isset($this->kick[$player->getName()])) {
unset($this->kick[$player->getName()]);
}
}
$this->tictock[$player->getName()] = $time;
}
示例2: onBlockBreak
public function onBlockBreak(BlockBreakEvent $ev)
{
if ($ev->isCancelled()) {
return;
}
$pl = $ev->getPlayer();
if (!$this->getState($pl, false)) {
return;
}
if (!$pl->isCreative() || !$this->creative) {
if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
echo "Not using an Axe\n";
//##DEBUG
return;
}
}
if ($this->leaves) {
$damage = $this->destroyTree($ev->getBlock());
} else {
$damage = $this->destroyTrunk($ev->getBlock());
}
if ($damage && $this->items && $this->itemwear) {
$hand = $pl->getInventory()->getItemInHand();
$hand->setDamage($hand->getDamage() + $this->itemwear * $damage);
$pl->getInventory()->setItemInHand($hand);
if ($this->broadcast) {
$this->owner->getServer()->broadcastMessage(mc::_("%1% used TreeCapitator", $pl->getName()));
} else {
$pl->sendMessage(mc::_("Used TreeCapitator"));
}
}
}
示例3: blockBreak
public function blockBreak(BlockBreakEvent $event)
{
//1
$id = $event->getItem()->getId();
if ($id == $this->id) {
$player = $event->getPlayer();
$username = $player->getName();
if (empty($this->data[$user][1])) {
$x = $event->getBlock()->x;
$y = $event->getBlock()->y;
$z = $event->getBlock()->z;
$this->data[$user][1] = array($x, $y, $z);
$ms = "";
if (isset($this->data[$user][2])) {
//片方がセットされていたら
$ms = "[FiredNubesco] Second position has been set to: {$x}, {$y}, {$z}";
$size = $this->countBlocks($player);
if ($num != false) {
$ms .= " (Size: " . $size[0] . "X" . $size[1] . ")";
}
} else {
$ms = "[FiredNubesco] First position has been set to: {$x}, {$y}, {$z}";
}
$player->sendMessage($ms);
$event->setCancelled(true);
}
}
return true;
}
示例4: onBlockBreak
public function onBlockBreak(BlockBreakEvent $event)
{
if ($event->isCancelled()) {
return;
}
if ($this->chopTree($event->getPlayer(), $event->getBlock(), $event->getItem(), self::TYPE_BREAK)) {
$event->setCancelled(true);
}
}
示例5: onBlockBreak
public function onBlockBreak(BlockBreakEvent $event)
{
$key = $event->getBlock()->x . "." . $event->getBlock()->y . "." . $event->getBlock()->z;
foreach ($this->crops as $crop) {
if ($event->getItem()->getId() == $crop["item"] and isset($this->farmData[$key])) {
unset($this->farmData[$key]);
}
}
}
示例6: onBlockBreak
public function onBlockBreak(BlockBreakEvent $event)
{
if ($event->isCancelled()) {
return;
} else {
$event->setCancelled();
}
foreach ($event->getBlock()->getDrops($event->getItem()) as $i) {
$event->getPlayer()->getInventory()->addItem(Item::get(...$i));
}
}
示例7: onBreak
public function onBreak(BlockBreakEvent $event)
{
$block = $event->getBlock();
if ($block instanceof Crops and !$event->getItem()->isHoe()) {
if ($block->getId() === Block::PUMPKIN_STEM or $block->getId() === Block::MELON_STEM) {
$event->setCancelled();
} else {
$this->blocks[microtime(true) + mt_rand(1, 5) . "." . mt_rand(0, 5)] = $block;
$this->runTask();
}
}
}
示例8: onBreak
public function onBreak(BlockBreakEvent $event)
{
if ($event->isCancelled()) {
return;
}
$player = $event->getPlayer();
$block = $event->getBlock();
$drops = $block->getDrops($event->getItem());
$x = $block->x + 0.5;
$y = $block->y + 0.5;
$z = $block->z + 0.5;
$tile = $block->getLevel()->getTile($block);
if ($tile instanceof Chest) {
return;
}
if ($event->getItem() instanceof Item) {
$event->getItem()->useOn($block);
if ($event->getItem()->isTool() and $event->getItem()->getDamage() >= $event->getItem()->getMaxDurability()) {
$event->getPlayer()->getInventory()->setItemInHand(Item::get(Item::AIR, 0, 0));
}
}
if (!$player instanceof Player) {
foreach ($drops as $drop) {
if ($drop[2] > 0) {
$event->getBlock()->getLevel()->dropItem($event->getBlock()->add(0.5, 0.5, 0.5), Item::get(...$drop));
}
}
} else {
if ($player->isSurvival()) {
$this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["drop"] = $drops;
$this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["player"] = $player;
$this->itemQueue["{$x}:{$y}:{$z}"] = $drops;
}
}
}
示例9: onBlockBreak
public function onBlockBreak(BlockBreakEvent $event)
{
if ($event->isCancelled()) {
return;
}
$b = $event->getBlock();
foreach ($b->getDrops($event->getItem()) as $i) {
$this->item[$i[0] . ":" . $i[1] . ":" . $i[2]] = true;
for ($for = 0; $for < $this->getCount(); $for++) {
$b->getLevel()->dropItem($b, Item::get($i[0], $i[1], $i[2]));
}
}
}
示例10: onBlockBreak
public function onBlockBreak(BlockBreakEvent $event)
{
$block = $event->getBlock();
$blockid = $block->getID();
$itemid = $event->getItem()->getID();
foreach ($this->growids as $index => $growid) {
if ($itemid == $growid) {
if (isset($this->farmdata[$block->x . "." . $block->y . "." . $block->z])) {
unset($this->farmdata[$block->x . "." . $block->y . "." . $block->z]);
}
}
}
}
示例11: onBreak
public function onBreak(BlockBreakEvent $event)
{
//ItemDamageBug
$player = $event->getPlayer();
$item = $event->getItem();
if ($item->isTool() and !$event->isCancelled() and self::ENABLE_ITEM_DAMAGE_BUG) {
if ($item->useOn($event->getBlock()) and $item->getDamage() >= $item->getMaxDurability()) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR, 0, 1));
} else {
$player->getInventory()->setItemInHand($item);
}
}
}
示例12: onBreak
public function onBreak(BlockBreakEvent $ev)
{
$p = $ev->getPlayer();
$block = $ev->getBlock();
$item = $ev->getItem()->getId();
$ev->setInstaBreak(true);
foreach ($this->ores as $ore) {
if ($block->getId() === $ore && !$ev->isCancelled()) {
$ev->setDrops(array());
$p->sendMessage("§l§dAUTO-SMELTED!");
$p->getInventory()->addItem(Item::get($this->ingot[$ore]));
$x = $p->getX();
$y = $p->getY();
$z = $p->getZ();
$p->getLevel()->addSound(new FizzSound(new Vector3($x, $y, $z)));
}
}
}
示例13: onBreak
public function onBreak(BlockBreakEvent $event)
{
if (!$event->getPlayer()->hasPermission("TreeChopper")) {
return;
}
if ($event->getBlock()->getId() == Block::LOG) {
$block = $event->getBlock();
$down = $block->getLevel()->getBlockIdAt($block->x, $block->y - 1, $block->z);
if ($down != Block::GRASS and $down != Block::DIRT) {
return;
}
$x = $block->x + 0.5;
$y = $block->y + 0.5;
$z = $block->z + 0.5;
$drops = $block->getDrops($event->getItem());
$this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["drop"] = $drops;
$this->breakQueue["{$block->x}:{$block->y}:{$block->z}"]["player"] = $event->getPlayer();
$this->itemQueue["{$x}:{$y}:{$z}"] = $drops;
}
}
示例14: onBreak
public function onBreak(BlockBreakEvent $ev)
{
//echo __METHOD__.",".__LINE__."\n";//##DEBUG
if ($ev->isCancelled()) {
return;
}
$pl = $ev->getPlayer();
if (!$this->getState($pl, false)) {
return;
}
if ($ev->getBlock()->getId() == Block::AIR) {
return;
}
if (!$pl->isCreative() || !$this->creative) {
if ($this->items && !isset($this->items[$ev->getItem()->getId()])) {
//echo "Not using an PickAxe\n"; //##DEBUG
return;
}
}
$ev->setInstaBreak(true);
}
示例15: snowShot
public function snowShot(BlockBreakEvent $e)
{
$v3 = new Vector3($x, $y, $z);
$player = $e->getPlayer();
if ($e->getItem() == 256 && $this->isInArena($player)) {
$this->spawnEnity = true;
}
}