本文整理汇总了PHP中pocketmine\block\Block::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::get方法的具体用法?PHP Block::get怎么用?PHP Block::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\block\Block
的用法示例。
在下文中一共展示了Block::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkBlock
public function checkBlock($player, $x, $y, $z)
{
$pos = new Vector3($x, $y - 1, $z);
$blockId = $player->getLevel()->getBlock($pos);
//$this->getLogger()->info($blockId." is on pos".$x."-".$y."-".$z."");
$world = $player->getLevel()->getName();
if ($blockId instanceof Block) {
$this->getLogger($pos);
if ($blockId->getId() === Block::get($this->damageBlock)->getId()) {
// $this->getLogger()->info($blockId." is on pos".$x."-".$y."-".$z."");
$this->doDamage($player);
return true;
} elseif ($blockId->getId() === Block::get($this->healingBlock)->getId()) {
$this->healPlayer($player);
return true;
} elseif ($blockId->getId() === Block::get($this->effectBlock)->getId()) {
$this->giveEffect($player);
return true;
} elseif ($this->isCommandBlock($x, $y, $z, $world)) {
$this->executeCmds($x, $y, $z, $world, $player);
return true;
} else {
return true;
}
} else {
//$this->getLogger()->info($blockId." is not a block on pos".$x."-".$y."-".$z."");
}
}
开发者ID:GoneTone,项目名称:Chinese-Traditional-Translations-For-PocketMine-MP-Plugins,代码行数:28,代码来源:Main.php
示例2: onRun
public function onRun($tick)
{
$blocks = 0;
while ($this->pos->x < $this->xMax) {
while ($this->pos->z < $this->zMax) {
while ($this->pos->y < 128) {
if ($this->pos->y === 0) {
$block = $this->bottomBlock;
} elseif ($this->pos->y < $this->height) {
$block = $this->plotFillBlock;
} elseif ($this->pos->y === $this->height) {
$block = $this->plotFloorBlock;
} else {
$block = Block::get(0);
}
$this->level->setBlock($this->pos, $block, false, false);
$blocks++;
if ($blocks === $this->maxBlocksPerTick) {
$this->getOwner()->getServer()->getScheduler()->scheduleDelayedTask($this, 1);
return;
}
$this->pos->y++;
}
$this->pos->y = 0;
$this->pos->z++;
}
$this->pos->z = $this->plotBeginPos->z;
$this->pos->x++;
}
}
示例3: readMacro
public function readMacro($name)
{
if (!is_file($path = $this->getFile($name))) {
return null;
}
$string = file_get_contents($path);
$nbt = new NBT();
$type = ord(substr($string, 0, 1));
$string = substr($string, 1);
if ($type === 0) {
$nbt->read($string);
} else {
$nbt->readCompressed($string, $type);
}
$tag = $nbt->getData();
$author = $tag["author"];
$description = $tag["description"];
/** @var tag\Enum $tags */
$tags = $tag["ops"];
$ops = [];
/** @var tag\Compound $t */
foreach ($tags as $t) {
$type = $tag["type"];
if ($type === 1) {
$ops[] = new MacroOperation($t["delta"]);
} else {
$vectors = $t["vectors"];
/** @noinspection PhpParamsInspection */
$ops[] = new MacroOperation(new Vector3($vectors[0], $vectors[1], $vectors[2]), Block::get($t["blockID"], $t["blockDamage"]));
}
}
return new Macro(false, $ops, $author, $description);
}
示例4: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $block->getSide(Vector3::SIDE_DOWN);
if ($down->isTransparent() === false) {
$this->getLevel()->setBlock($this, Block::get($this->id, 0));
$up = $block->getSide(Vector3::SIDE_UP);
if ($block->getSide(Vector3::SIDE_EAST) && $block->getSide(Vector3::SIDE_WEST)) {
if ($up->getSide(Vector3::SIDE_EAST)) {
$this->setDirection(Vector3::SIDE_EAST, true);
} elseif ($up->getSide(Vector3::SIDE_WEST)) {
$this->setDirection(Vector3::SIDE_WEST, true);
} else {
$this->setDirection(Vector3::SIDE_EAST);
}
} elseif ($block->getSide(Vector3::SIDE_SOUTH) && $block->getSide(Vector3::SIDE_NORTH)) {
if ($up->getSide(Vector3::SIDE_SOUTH)) {
$this->setDirection(Vector3::SIDE_SOUTH, true);
} elseif ($up->getSide(Vector3::SIDE_NORTH)) {
$this->setDirection(Vector3::SIDE_NORTH, true);
} else {
$this->setDirection(Vector3::SIDE_SOUTH);
}
} else {
$this->setDirection(Vector3::SIDE_NORTH);
}
return true;
}
return false;
}
示例5: readMacro
public function readMacro($name)
{
$result = $this->getMacroRaw($name);
$array = $result->fetch_assoc();
$result->close();
if (!is_array($array)) {
return null;
}
$result = $this->getMacroRaw("macros_deltas", "owner", $name);
$deltas = $result->fetch_all(MYSQLI_ASSOC);
$result->close();
$result = $this->getMacroRaw("macros_ops", "owner", $name);
$ops = array_merge($deltas, $result->fetch_all(MYSQLI_ASSOC));
$opers = [];
foreach ($ops as $op) {
if (isset($op["delta"])) {
$opers[$op["offset"]] = new MacroOperation($op["delta"]);
} else {
$opers[$op["offset"]] = new MacroOperation(new Vector3($op["x"], $op["y"], $op["z"]), Block::get($op["id"], $op["damage"]));
}
}
ksort($opers);
$macro = new Macro(false, array_values($opers), $array["author"], $array["description"]);
return $macro;
}
示例6: __construct
public function __construct($meta = 0, $count = 1)
{
if ($meta == 3) {
$this->block = Block::get(CropPlus::COCOA_BEANS_BLOCK);
}
parent::__construct(Item::DYE, $meta, $count, "Dye");
}
示例7: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
if ($face !== 0) {
$nbt = new CompoundTag("", ["id" => new StringTag("id", Tile::SIGN), "x" => new IntTag("x", $block->x), "y" => new IntTag("y", $block->y), "z" => new IntTag("z", $block->z), "Text1" => new StringTag("Text1", ""), "Text2" => new StringTag("Text2", ""), "Text3" => new StringTag("Text3", ""), "Text4" => new StringTag("Text4", "")]);
if ($player !== null) {
$nbt->Creator = new StringTag("Creator", $player->getRawUniqueId());
}
if ($item->hasCustomBlockData()) {
foreach ($item->getCustomBlockData() as $key => $v) {
$nbt->{$key} = $v;
}
}
if ($face === 1) {
$this->meta = floor(($player->yaw + 180) * 16 / 360 + 0.5) & 0xf;
$this->getLevel()->setBlock($block, Block::get(Item::SIGN_POST, $this->meta), true);
Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
return true;
} else {
$this->meta = $face;
$this->getLevel()->setBlock($block, Block::get(Item::WALL_SIGN, $this->meta), true);
Tile::createTile(Tile::SIGN, $this->getLevel()->getChunk($block->x >> 4, $block->z >> 4), $nbt);
return true;
}
}
return false;
}
示例8: onUpdate
public function onUpdate()
{
$this->entityBaseTick();
if ($this->closed !== false) {
return false;
}
$this->motionY -= $this->gravity;
$this->move($this->motionX, $this->motionY, $this->motionZ);
$friction = 1 - $this->drag;
$this->motionX *= $friction;
$this->motionY *= 1 - $this->drag;
$this->motionZ *= $friction;
$pos = $this->floor();
if ($this->ticksLived === 1) {
$block = $this->level->getBlock($pos);
if ($block->getID() != $this->blockId) {
$this->kill();
return true;
}
$this->level->setBlock($pos, Block::get(0, true));
}
if ($this->onGround) {
$this->kill();
$block = $this->level->getBlock($pos);
if (!$block->isFullBlock) {
$this->getLevel()->dropItem($this, Item::get($this->getBlock(), 0, 1));
} else {
$this->getLevel()->setBlock($pos, Block::get($this->getBlock(), 0), true);
}
}
$this->updateMovement();
return !$this->onGround or $this->motionX == 0 and $this->motionY == 0 and $this->motionZ == 0;
}
示例9: populate
public function populate(ChunkManager $level, $chunkX, $chunkZ, Random $random)
{
$chunk = $level->getChunk($chunkX, $chunkZ);
for ($x = 0; $x < 16; ++$x) {
for ($z = 0; $z < 16; ++$z) {
$biome = Biome::getBiome($chunk->getBiomeId($x, $z));
$cover = $biome->getGroundCover();
if (count($cover) > 0) {
$diffY = 0;
if (!$cover[0]->isSolid()) {
$diffY = 1;
}
$column = $chunk->getBlockIdColumn($x, $z);
for ($y = 127; $y > 0; --$y) {
if ($column[$y] !== "" and !Block::get(ord($column[$y]))->isTransparent()) {
break;
}
}
$startY = min(127, $y + $diffY);
$endY = $startY - count($cover);
for ($y = $startY; $y > $endY and $y >= 0; --$y) {
$b = $cover[$startY - $y];
if ($column[$y] === "" and $b->isSolid()) {
break;
}
if ($b->getDamage() === 0) {
$chunk->setBlockId($x, $y, $z, $b->getId());
} else {
$chunk->setBlock($x, $y, $z, $b->getId(), $b->getDamage());
}
}
}
}
}
}
示例10: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $block->getSide(Vector3::SIDE_DOWN);
if ($down->isTransparent() === false || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
$this->getLevel()->setBlock($this, Block::get($this->id, 0));
$up = $block->getSide(Vector3::SIDE_UP);
if ($block->getSide(Vector3::SIDE_EAST) instanceof RailBlock && $block->getSide(Vector3::SIDE_WEST) instanceof RailBlock) {
if ($up->getSide(Vector3::SIDE_EAST) instanceof RailBlock) {
$this->setDirection(Vector3::SIDE_EAST, true);
} elseif ($up->getSide(Vector3::SIDE_WEST) instanceof RailBlock) {
$this->setDirection(Vector3::SIDE_WEST, true);
} else {
$this->setDirection(Vector3::SIDE_EAST);
}
} elseif ($block->getSide(Vector3::SIDE_SOUTH) instanceof RailBlock && $block->getSide(Vector3::SIDE_NORTH) instanceof RailBlock) {
if ($up->getSide(Vector3::SIDE_SOUTH) instanceof RailBlock) {
$this->setDirection(Vector3::SIDE_SOUTH, true);
} elseif ($up->getSide(Vector3::SIDE_NORTH) instanceof RailBlock) {
$this->setDirection(Vector3::SIDE_NORTH, true);
} else {
$this->setDirection(Vector3::SIDE_SOUTH);
}
} else {
$this->setDirection(Vector3::SIDE_NORTH);
}
return true;
}
return false;
}
示例11: onRun
public function onRun($tick)
{
$blocks = 0;
while ($this->pos->x < $this->xMax) {
while ($this->pos->z < $this->zMax) {
while ($this->pos->y < 128) {
if ($this->pos->y === 0) {
$block = $this->bottomBlock;
} elseif ($this->pos->y < $this->height) {
$block = $this->plotFillBlock;
} elseif ($this->pos->y === $this->height) {
$block = $this->plotFloorBlock;
} else {
$block = Block::get(0);
}
$this->level->setBlock($this->pos, $block, false, false);
$blocks++;
if ($blocks === $this->maxBlocksPerTick) {
$this->getOwner()->getServer()->getScheduler()->scheduleDelayedTask($this, 1);
return;
}
$this->pos->y++;
}
$this->pos->y = 0;
$this->pos->z++;
}
$this->pos->z = $this->plotBeginPos->z;
$this->pos->x++;
}
if ($this->issuer !== null) {
$this->issuer->sendMessage(TextFormat::GREEN . "Successfully cleared this plot");
}
}
示例12: onEntityDamage
public function onEntityDamage(EntityDamageEvent $event)
{
if (!$event->isCancelled() && $event instanceof EntityDamageByEntityEvent) {
$e = $event->getEntity();
$arrow = $event->getDamager();
$damage = round($event->getDamage() / 2);
if ($arrow instanceof AbilityArrow) {
$shoter = $arrow->shootingEntity;
if ($shoter instanceof Player) {
if ($arrow instanceof FireArrow) {
$e->setOnFire(rand(3, 10));
} elseif ($arrow instanceof TeleportArrow) {
$shoter->teleport($e);
} elseif ($arrow instanceof SpiderArrow) {
$e->getLevel()->setBlock($e, Block::get(30));
} elseif ($arrow instanceof HealArrow) {
$damage = -$damage;
} elseif ($arrow instanceof PowerArrow) {
$damage = round($damage * rand(2, 3) / 2);
} else {
return;
}
$arrow->kill();
}
}
$event->setDamage($damage);
}
}
示例13: resetArena
public function resetArena()
{
foreach ($this->players as $p) {
if ($p instanceof Player) {
$p->sendMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . "You have won!");
$this->removePlayer($p);
if ($this->plugin->getConfig()->get("display") == true) {
$this->plugin->getServer()->broadcastMessage(TextFormat::AQUA . "[SimpleSpleef] " . TextFormat::GOLD . $p->getDisplayName() . " has won spleef in Arena " . $this->getArenaName());
}
}
}
$this->enabled = false;
foreach ($this->broken as $block) {
if ($block instanceof Position) {
$level = $block->getLevel();
$x = $block->getX();
$y = $block->getY();
$z = $block->getZ();
$level->setBlock(new Vector3($x, $y, $z), Block::get(Block::SNOW_BLOCK));
}
}
$this->second = $this->plugin->getConfig()->get("wait");
$this->broken = array();
$this->active = false;
$this->enabled = true;
}
示例14: onUpdate
public function onUpdate($type)
{
if ($type === Level::BLOCK_UPDATE_SCHEDULED or $type === Level::BLOCK_UPDATE_RANDOM) {
$this->getLevel()->setBlock($this, Block::get(Item::REDSTONE_ORE, $this->meta), false, false, true);
return Level::BLOCK_UPDATE_WEAK;
}
return false;
}
示例15: onUpdate
public function onUpdate($type)
{
if ($type === Level::BLOCK_UPDATE_NORMAL or $type === Level::BLOCK_UPDATE_TOUCH) {
$this->getLevel()->setBlock($this, Block::get(Item::GLOWING_REDSTONE_ORE, $this->meta), false, false, true);
return Level::BLOCK_UPDATE_WEAK;
}
return false;
}