本文整理汇总了PHP中pocketmine\block\Block::getSide方法的典型用法代码示例。如果您正苦于以下问题:PHP Block::getSide方法的具体用法?PHP Block::getSide怎么用?PHP Block::getSide使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pocketmine\block\Block
的用法示例。
在下文中一共展示了Block::getSide方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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) && $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;
}
示例2: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
if ($block->getSide(0)->getID() === self::FARMLAND) {
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
示例3: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
if ($target->isTransparent() === false and $face > 1 and $block->isSolid() === false) {
$faces = [2 => 1, 3 => 3, 4 => 0, 5 => 2];
$motives = [["Kebab", 1, 1], ["Aztec", 1, 1], ["Alban", 1, 1], ["Aztec2", 1, 1], ["Bomb", 1, 1], ["Plant", 1, 1], ["Wasteland", 1, 1], ["Wanderer", 1, 2], ["Graham", 1, 2], ["Pool", 2, 1], ["Courbet", 2, 1], ["Sunset", 2, 1], ["Sea", 2, 1], ["Creebet", 2, 1], ["Match", 2, 2], ["Bust", 2, 2], ["Stage", 2, 2], ["Void", 2, 2], ["SkullAndRoses", 2, 2], ["Fighters", 4, 2], ["Skeleton", 4, 3], ["DonkeyKong", 4, 3], ["Pointer", 4, 4], ["Pigscene", 4, 4], ["Flaming Skull", 4, 4]];
$right = [4, 5, 3, 2];
$validMotives = [];
foreach ($motives as $motive) {
$valid = true;
for ($x = 0; $x < $motive[1] && $valid; $x++) {
for ($z = 0; $z < $motive[2] && $valid; $z++) {
if ($target->getSide($right[$face - 2], $x)->isTransparent() || $target->getSide(Vector3::SIDE_UP, $z)->isTransparent() || $block->getSide($right[$face - 2], $x)->isSolid() || $block->getSide(Vector3::SIDE_UP, $z)->isSolid()) {
$valid = false;
}
}
}
if ($valid) {
$validMotives[] = $motive;
}
}
$motive = $motives[mt_rand(0, count($validMotives) - 1)];
$data = ["x" => $target->x, "y" => $target->y, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
$nbt = new CompoundTag("", ["Motive" => new StringTag("Motive", $data["Motive"]), "Pos" => new EnumTag("Pos", [new DoubleTag("", $data["x"]), new DoubleTag("", $data["y"]), new DoubleTag("", $data["z"])]), "Motion" => new EnumTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new EnumTag("Rotation", [new FloatTag("", $data["yaw"]), new FloatTag("", 0)])]);
$painting = new PaintingEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
$painting->spawnToAll();
if ($player->isSurvival()) {
$item = $player->getInventory()->getItemInHand();
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
}
//TODO
//$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
//$e->spawnToAll();
/*if(($player->gamemode & 0x01) === 0x00){
$player->removeItem(Item::get($this->getId(), $this->getDamage(), 1));
}*/
return true;
}
return false;
}
示例4: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $target->getSide(Vector3::SIDE_DOWN);
if ($down->isTransparent() === false || $down instanceof Fence || $down instanceof FenceGate) {
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
return false;
}
示例5: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$realPos = $target->getSide($face)->add(0.5, 0.4, 0.5);
$camera = new TripoidCamera($player->getLevel()->getChunk($realPos->getX() >> 4, $realPos->getZ() >> 4), new CompoundTag("", ["Pos" => new ListTag("Pos", [new DoubleTag("", $realPos->getX()), new DoubleTag("", $realPos->getY()), new DoubleTag("", $realPos->getZ())]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", 0), new FloatTag("", 0)])]));
$camera->spawnToAll();
if ($player->isSurvival()) {
--$this->count;
}
return true;
}
示例6: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $block->getSide(0);
if ($down->getId() === self::AIR) {
return false;
}
$faces = [0 => 3, 1 => 0, 2 => 1, 3 => 2];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x3;
$this->getLevel()->setBlock($block, $this, true, true);
return true;
}
示例7: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $block->getSide(0);
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($block, $this, true, true);
$nbt = new Compound("", [new String("id", Tile::FLOWER_POT), new Int("x", $block->x), new Int("y", $block->y), new Int("z", $block->z), new Short("item", 0), new Int("mData", 0)]);
$pot = Tile::createTile("FlowerPot", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
return true;
}
return false;
}
示例8: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = \null)
{
if ($target instanceof Water) {
$up = $target->getSide(Vector3::SIDE_UP);
if ($up->getId() === Block::AIR) {
$this->getLevel()->setBlock($up, $this, \true, \true);
return \true;
}
}
return \false;
}
示例9: addToDeactiveQueue
public static function addToDeactiveQueue(\SplPriorityQueue $queue, Block $location, $updateLevel)
{
if ($updateLevel <= 0) {
return;
}
for ($s = 0; $s <= 5; $s++) {
$sideBlock = $location->getSide($s);
if ($sideBlock->getPowerLevel() === $updateLevel - 1) {
$queue->insert($sideBlock, $sideBlock->getPowerLevel());
}
}
}
示例10: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
$down = $block->getSide(0);
if ($down->isTransparent() && !($down instanceof Slab && ($down->meta & 0x8) === 0x8) || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
return false;
}
if ($player instanceof Player) {
$this->meta = ((int) $player->getDirection() + 5) % 4;
}
$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)
{
$down = $block->getSide(Vector3::SIDE_DOWN);
if ($down->isTransparent() === false) {
$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;
}
示例12: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$realPos = $block->getSide($face);
$boat = Entity::createEntity("Boat", $player->getLevel()->getChunk($realPos->x >> 4, $realPos->z >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $realPos->x), new Double("", $realPos->y), new Double("", $realPos->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
$boat->spawnToAll();
--$this->count;
if ($this->count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return true;
}
$player->getInventory()->setItemInHand($this);
return true;
}
示例13: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$realPos = $block->getSide($face);
$boat = new BoatEntity($player->getLevel()->getChunk($realPos->getX() >> 4, $realPos->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $realPos->getX()), new Double("", $realPos->getY()), new Double("", $realPos->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
$boat->spawnToAll();
$item = $player->getInventory()->getItemInHand();
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
return true;
}
示例14: place
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
{
if ($block->getSide(Vector3::SIDE_DOWN)->isTransparent() === false) {
$this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound("", [new String("id", Tile::BREWING_STAND), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
if ($item->hasCustomName()) {
$nbt->CustomName = new String("CustomName", $item->getCustomName());
}
if ($item->hasCustomBlockData()) {
foreach ($item->getCustomBlockData() as $key => $v) {
$nbt->{$key} = $v;
}
}
Tile::createTile(Tile::BREWING_STAND, $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
return true;
}
return false;
}
示例15: onActivate
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz)
{
$realPos = $block->getSide(Vector3::SIDE_UP);
if (!$block instanceof RailBlock) {
return false;
}
$cart = new MinecartEntity($player->getLevel()->getChunk($realPos->getX() >> 4, $realPos->getZ() >> 4), new Compound("", ["Pos" => new Enum("Pos", [new Double("", $realPos->getX()), new Double("", $realPos->getY()), new Double("", $realPos->getZ())]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", 0), new Float("", 0)])]));
$cart->spawnToAll();
if ($player->isSurvival()) {
$item = $player->getInventory()->getItemInHand();
$count = $item->getCount();
if (--$count <= 0) {
$player->getInventory()->setItemInHand(Item::get(Item::AIR));
return;
}
$item->setCount($count);
$player->getInventory()->setItemInHand($item);
}
return true;
}