本文整理汇总了PHP中pocketmine\block\Block::getLevel方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::getLevel方法的具体用法?PHP Block::getLevel怎么用?PHP Block::getLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\block\Block
的用法示例。
在下文中一共展示了Block::getLevel方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: isFreezable
/**
* @param Block $block
* @return bool
*/
public function isFreezable(Block $block)
{
if (isset($this->configs[$ilevel = strtolower($block->getLevel()->getName())])) {
return $this->configs[$ilevel]->exists($block->getId() . ":" . $block->getDamage(), true);
}
return false;
}
示例2: sendBlockInfo
/**
* @param CommandSender $sender
* @param Block $block
*/
public function sendBlockInfo(CommandSender $sender, Block $block)
{
$sender->sendMessage("Name: " . $block->getName());
$sender->sendMessage("XYZ: " . $block->getFloorX() . ":" . $block->getFloorY() . ":" . $block->getFloorZ());
$sender->sendMessage("Level: " . $block->getLevel()->getName());
$sender->sendMessage("Block-id: " . $block->getId() . ":" . $block->getDamage());
$sender->sendMessage("Hardness: " . $block->getHardness());
$sender->sendMessage("Resistance: " . $block->getResistance());
$sender->sendMessage("Tool-type: " . $block->getToolType());
$sender->sendMessage("Friction: " . $block->getFrictionFactor());
$sender->sendMessage("Light-level: " . $block->getLightLevel());
//$sender->sendMessage("Is-placeable: ".($block->canBePlaced() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
$sender->sendMessage("Is-replaceable: " . ($block->canBeReplaced() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
$sender->sendMessage("Is-transparent: " . ($block->isTransparent() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
$sender->sendMessage("Is-solid: " . ($block->isSolid() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
//$sender->sendMessage("Is-flowable: ".($block->canBeFlowedInto() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
//$sender->sendMessage("Is-activateable: ".($block->canBeActivated() ? TextFormat::GREEN."yes" : TextFormat::RED."no"));
$sender->sendMessage("Is-passable: " . ($block->canPassThrough() ? TextFormat::GREEN . "yes" : TextFormat::RED . "no"));
$dropCount = 0;
$dropNames = "";
foreach ($block->getDrops() as $drop) {
$dropNames .= $drop->getName() . ", ";
$dropCount++;
}
$sender->sendMessage("Drops (" . $dropCount . "): " . substr($dropNames, 0, -2));
}
示例3: isBlockSpecified
/**
* @param Block $block
* @return bool
*/
private function isBlockSpecified(Block $block)
{
$key = array_change_key_case($this->getConfig()->getNested("level." . $block->getLevel()->getName()), CASE_LOWER);
if (is_array($key)) {
return in_array($block->getId() . ":" . $block->getDamage(), $key);
}
}
示例4: isBlockSpecified
/**
* @param Block $block
* @return bool
*/
public function isBlockSpecified(Block $block)
{
$key = array_change_key_case($this->getConfig()->get("level"), CASE_LOWER);
$levelKey = $key[strtolower($block->getLevel()->getName())];
if (is_array($levelKey)) {
return in_array($block->getId() . ":" . $block->getDamage(), $levelKey);
}
}
示例5: __construct
public function __construct(Player $player, Block $block, Item $item, $instaBreak = false)
{
$this->block = $block;
$this->item = $item;
$this->player = $player;
$this->instaBreak = (bool) $instaBreak;
$drops = $player->isSurvival() ? $block->getLevel()->getGameRule("doTileDrops") ? $block->getDrops($item) : [] : [];
foreach ($drops as $i) {
$this->blockDrops[] = Item::get($i[0], $i[1], $i[2]);
}
}
示例6: addEntry
/**
* @param Block $sourceBlock a Block with the absolute X, Y and Z from the original level
*/
public function addEntry(Block $sourceBlock)
{
if (!$this->isWritable) {
throw new \InvalidStateException("This clip is not writable");
}
if (!$sourceBlock->isValid()) {
throw new \InvalidArgumentException("Source block must contain a level and absolute coords");
}
if ($sourceBlock->getLevel()->getName() !== $this->levelName) {
throw new \InvalidStateException("Block is not from the level clip is being written in");
}
$delta = $sourceBlock->subtract($this->anchor);
$insert = Block::get($sourceBlock->getId(), $sourceBlock->getDamage(), Position::fromObject($delta->subtract($this->anchor)));
$this->entries[] = $insert;
}
示例7: getDispenserId
public function getDispenserId(Block $block)
{
return $block->getX() . ":" . $block->getY() . ":" . $block->getZ() . ":" . $block->getLevel()->getFolderName();
}
示例8: getTreetop
/**
* @param Block $stump
* @return int
*/
public function getTreetop(Block $stump)
{
$level = $stump->getLevel();
$floor = $level->getBlock($stump->getSide(0));
if (!in_array($floor->getId(), self::FLOORS)) {
return -1;
}
$found = null;
$maxHeight = $this->getConfig()->get("maxWorldHeight") - $stump->getY();
for ($height = 0; $height < $maxHeight; $height++) {
$block = $level->getBlock($stump->add(0, $height, 0));
if (in_array($block->getId(), self::WOODS)) {
if ($found === null) {
$found = [$block->getId(), $block->getDamage()];
} elseif ($found[0] !== $block->getId() or $found[1] !== $block->getDamage()) {
return -1;
}
} elseif ($found !== null and in_array($block->getId(), self::LEAVES)) {
return $height;
} else {
return -1;
}
}
return -1;
}
示例9: rotateBlockByOne
private static function rotateBlockByOne(Block $block)
{
return Block::get($block->getID(), $block->getDamage(), new Position($block->getZ(), $block->getY(), -$block->getX(), $block->getLevel()));
}
示例10: addChest
/**
* Adds a resettable chest
* @param Block $chest
*/
public function addChest(Block $chest)
{
$chests = $this->config->chests;
$chests[count($this->chests)] = ['id' => $chest->getId(), 'x' => $chest->getX(), 'y' => $chest->getY(), 'z' => $chest->getZ(), 'level' => $chest->getLevel()->getId()];
$this->config->set("chests", $chests);
$this->config->save();
array_push($this->chests, $chest);
}
示例11: destroyTrunk
private function destroyTrunk(Block $bl)
{
$damage = 0;
if ($bl->getId() != Block::WOOD) {
return $damage;
}
$down = $bl->getSide(Vector3::SIDE_DOWN);
if ($down->getId() == Block::WOOD) {
return $damage;
}
$l = $bl->getLevel();
for ($y = $bl->getY() + 1; $y < 128; ++$y) {
$x = $bl->getX();
$z = $bl->getZ();
$bl = $l->getBlock(new Vector3($x, $y, $z));
if ($bl->getId() != Block::WOOD) {
break;
}
++$damage;
$l->dropItem($bl, new ItemBlock($bl));
$l->setBlockIdAt($x, $y, $z, 0);
$l->setBlockDataAt($x, $y, $z, 0);
}
return $damage;
}
示例12: replaceBlock
public function replaceBlock($startX, $startY, $startZ, $endX, $endY, $endZ, Block $block, Block $target, Player $player = null)
{
$count = 0;
$x = $startX;
$y = $startY;
$z = $startZ;
if (is_array($y)) {
$startY = $y[1];
$y = $y[0];
}
if (is_array($z)) {
$startZ = $z[1];
$z = $z[0];
}
while (true) {
if ($count < $this->getData("limit-block", 130)) {
$chunk = $block->getLevel()->getChunk($x >> 4, $z >> 4, true);
if ($chunk !== null) {
$id = $chunk->getBlockId($x & 0xf, $y & 0x7f, $z & 0xf);
$meta = $chunk->getBlockData($x & 0xf, $y & 0x7f, $z & 0xf);
if ($id === $block->getId() && $meta === $block->getDamage()) {
++$count;
$this->saveUndo($block, $pos = new Vector3($x, $y, $z));
$this->set($target, $pos);
}
}
if ($z < $endZ) {
$z++;
} else {
$z = $startZ;
if ($y < $endY) {
$y++;
} else {
$y = $startY;
if ($x < $endX) {
$x++;
} else {
break;
}
}
}
} else {
self::core()->getScheduler()->scheduleDelayedTask(new WorldEditorTask([$this, "replaceBlock"], [$x, [$y, $startY], [$z, $startZ], $endX, $endY, $endZ, $block, $target, $player], $this), 1);
return;
}
}
if ($player !== null) {
$player->sendMessage("[WorldEditor]모든 블럭을 변경했어요");
}
if ($this->getData("debug", false)) {
$name = $player === null ? "" : "{$player->getName()}님이 ";
self::core()->getLogger()->info("[WorldEditor]{$name}블럭변경을 끝냈어요");
}
}
示例13: removeRocketPad
/**
* @param Block $block
*/
public function removeRocketPad(Block $block)
{
$this->pads->remove($block->getFloorX() . ":" . $block->getFloorY() . ":" . $block->getFloorZ() . ":" . strtolower($block->getLevel()->getName()));
$this->pads->save();
}