本文整理汇总了PHP中pocketmine\block\Block::getDamage方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::getDamage方法的具体用法?PHP Block::getDamage怎么用?PHP Block::getDamage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\block\Block
的用法示例。
在下文中一共展示了Block::getDamage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}
}
示例2: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($this->meta === Item::AIR) {
if ($target instanceof Liquid) {
$level->setBlock($target, new Air(), true);
if (($player->gamemode & 0x1) === 0) {
$this->meta = $target instanceof Water ? Item::WATER : Item::LAVA;
}
return true;
}
} elseif ($this->meta === Item::WATER) {
//Support Make Non-Support Water to Support Water
if ($block->getID() === self::AIR || $block instanceof Water && ($block->getDamage() & 0x7) != 0x0) {
$water = new Water();
$level->setBlock($block, $water, true);
$water->place(clone $this, $block, $target, $face, $fx, $fy, $fz, $player);
if (($player->gamemode & 0x1) === 0) {
$this->meta = 0;
}
return true;
}
} elseif ($this->meta === Item::LAVA) {
if ($block->getID() === self::AIR) {
$level->setBlock($block, new Lava(), true);
if (($player->gamemode & 0x1) === 0) {
$this->meta = 0;
}
return true;
}
}
return false;
}
示例3: 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));
}
示例4: 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;
}
示例5: 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);
}
}
示例6: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
if ($target->getId() === Block::WOOD and $target->getDamage() === Wood::JUNGLE) {
if ($face !== 0 and $face !== 1) {
$faces = [2 => 0, 3 => 2, 4 => 3, 5 => 1];
$this->meta = $faces[$face];
$this->getLevel()->setBlock($block, $this, true);
return true;
}
}
return false;
}
示例7: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$bucketContents = Block::get($this->meta);
if ($bucketContents instanceof Air) {
// Bucket Empty so pick up block
if ($target instanceof Liquid and $target->getDamage() === 0) {
$result = clone $this;
if ($target instanceof StillWater) {
$toStore = Block::WATER;
} elseif ($target instanceof StillLava) {
$toStore = Block::LAVA;
} else {
return false;
}
$result->setDamage($toStore);
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
if (!$ev->isCancelled()) {
$player->getLevel()->setBlock($target, new Air(), true, true);
if ($player->isSurvival()) {
$player->getInventory()->setItemInHand($ev->getItem(), $player);
}
return true;
} else {
$player->getInventory()->sendContents($player);
}
}
} elseif ($bucketContents instanceof Liquid) {
// Bucket Full, so empty
$result = clone $this;
$result->setDamage(0);
if ($bucketContents instanceof Water) {
$toCreate = Block::STILL_WATER;
} elseif ($bucketContents instanceof Lava) {
$toCreate = Block::STILL_LAVA;
} else {
return false;
}
$bucketContents = Block::get($toCreate);
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
if (!$ev->isCancelled()) {
$player->getLevel()->setBlock($block, $bucketContents, true, true);
if ($player->isSurvival()) {
$player->getInventory()->setItemInHand($ev->getItem(), $player);
}
return true;
} else {
$player->getInventory()->sendContents($player);
}
}
return false;
}
示例8: 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;
}
示例9: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$targetBlock = Block::get($this->meta);
if ($targetBlock instanceof Air) {
if ($target instanceof Liquid and $target->getDamage() === 0) {
$result = clone $this;
$id = $target->getId();
if ($id == self::STILL_WATER) {
$id = self::WATER;
}
if ($id == self::STILL_LAVA) {
$id = self::LAVA;
}
$result->setDamage($id);
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result));
if (!$ev->isCancelled()) {
$player->getLevel()->setBlock($target, new Air(), true, true);
if ($player->isSurvival()) {
$player->getInventory()->setItemInHand($ev->getItem());
}
return true;
} else {
$player->getInventory()->sendContents($player);
}
}
} elseif ($targetBlock instanceof Liquid) {
$result = clone $this;
$result->setDamage(0);
$player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketEmptyEvent($player, $block, $face, $this, $result));
if (!$ev->isCancelled()) {
//Only disallow water placement in the Nether, allow other liquids to be placed
//In vanilla, water buckets are emptied when used in the Nether, but no water placed.
if (!($player->getLevel()->getDimension() === Level::DIMENSION_NETHER and $targetBlock->getID() === self::WATER)) {
$player->getLevel()->setBlock($block, $targetBlock, true, true);
}
if ($player->isSurvival()) {
$player->getInventory()->setItemInHand($ev->getItem());
}
return true;
} else {
$player->getInventory()->sendContents($player);
}
}
return false;
}
示例10: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$this->meta &= 0x7;
if ($face === 0) {
if ($target->getID() === self::WOOD_SLAB and ($target->getDamage() & 0x8) === 0x8 and ($target->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
return true;
} elseif ($block->getID() === self::WOOD_SLAB and ($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
return true;
} else {
$this->meta |= 0x8;
}
} elseif ($face === 1) {
if ($target->getID() === self::WOOD_SLAB and ($target->getDamage() & 0x8) === 0 and ($target->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
return true;
} elseif ($block->getID() === self::WOOD_SLAB and ($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
return true;
}
} elseif (!$player instanceof Player) {
//TODO: collision
if ($block->getID() === self::WOOD_SLAB) {
if (($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true);
return true;
}
return false;
} else {
if ($fy > 0.5) {
$this->meta |= 0x8;
}
}
} else {
return false;
}
if ($block->getID() === self::WOOD_SLAB and ($target->getDamage() & 0x7) !== ($this->meta & 0x7)) {
return false;
}
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
示例11: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = \null)
{
$this->meta &= 0x7;
if ($face === 0) {
if ($target->getId() === self::SLAB and ($target->getDamage() & 0x8) === 0x8 and ($target->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_SLAB, $this->meta), \true);
return \true;
} elseif ($block->getId() === self::SLAB and ($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), \true);
return \true;
} else {
$this->meta |= 0x8;
}
} elseif ($face === 1) {
if ($target->getId() === self::SLAB and ($target->getDamage() & 0x8) === 0 and ($target->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_SLAB, $this->meta), \true);
return \true;
} elseif ($block->getId() === self::SLAB and ($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), \true);
return \true;
}
//TODO: check for collision
} else {
if ($block->getId() === self::SLAB) {
if (($block->getDamage() & 0x7) === ($this->meta & 0x7)) {
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), \true);
return \true;
}
return \false;
} else {
if ($fy > 0.5) {
$this->meta |= 0x8;
}
}
}
if ($block->getId() === self::SLAB and ($target->getDamage() & 0x7) !== ($this->meta & 0x7)) {
return \false;
}
$this->getLevel()->setBlock($block, $this, \true, \true);
return \true;
}
示例12: matches
public function matches(Block $block)
{
return $block->getId() === $this->block->getId() and ($this->damageSensitive or $block->getDamage() === $this->block->getDamage());
}
示例13: 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}블럭변경을 끝냈어요");
}
}
示例14: isRocketPad
/**
* @param Block $block
* @return bool
*/
public function isRocketPad(Block $block)
{
if (is_array($this->getConfig()->getNested("pad.blockId"))) {
return in_array($block->getId() . ":" . $block->getDamage(), $this->getConfig()->getNested("pad.blockId"));
}
}
示例15: getSapling
/**
* @param Block $leaves
* @return Sapling
*/
public function getSapling(Block $leaves)
{
if ($leaves instanceof Leaves) {
$damage = $leaves->getDamage();
if ($leaves instanceof Leaves2) {
switch ($damage) {
default:
case Leaves2::ACACIA:
return new Sapling(Sapling::ACACIA);
case Leaves2::DARK_OAK:
return new Sapling(Sapling::DARK_OAK);
}
} else {
return new Sapling($damage);
}
} else {
return new Sapling();
}
}