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; }
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; }
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; }
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 Int("item", 0), new Int("data", 0)]); $pot = Tile::createTile("FlowerPot", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); return true; } return false; }
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; }
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(); 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; }
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; }
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() || $down instanceof Fence || $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); return true; } return false; }
private function findLog(Block $pos, array $visited, $distance, &$check, $fromSide = null) { ++$check; $index = $pos->x . "." . $pos->y . "." . $pos->z; if (isset($visited[$index])) { return false; } if ($pos->getId() === self::WOOD2) { return true; } elseif ($pos->getId() === self::LEAVES2 and $distance < 3) { $visited[$index] = true; $down = $pos->getSide(0)->getId(); if ($down === Item::WOOD2) { return true; } if ($fromSide === null) { for ($side = 2; $side <= 5; ++$side) { if ($this->findLog($pos->getSide($side), $visited, $distance + 1, $check, $side) === true) { return true; } } } else { //No more loops switch ($fromSide) { case 2: if ($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true) { return true; } break; case 3: if ($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true) { return true; } break; case 4: if ($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(4), $visited, $distance + 1, $check, $fromSide) === true) { return true; } break; case 5: if ($this->findLog($pos->getSide(2), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(3), $visited, $distance + 1, $check, $fromSide) === true) { return true; } elseif ($this->findLog($pos->getSide(5), $visited, $distance + 1, $check, $fromSide) === true) { return true; } break; } } } return false; }
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null) { $down = $block->getSide(Vector3::SIDE_DOWN); $class = ""; if ($down->isTransparent() === false) { $up = $block->getSide(Vector3::SIDE_UP); if ($block->getSide(Vector3::SIDE_EAST) instanceof RailBlock && $block->getSide(Vector3::SIDE_SOUTH) instanceof RailBlock) { return $this->setDirection(self::SIDE_SOUTH_EAST); } elseif ($block->getSide(Vector3::SIDE_EAST) instanceof RailBlock && $block->getSide(Vector3::SIDE_NORTH) instanceof RailBlock) { return $this->setDirection(self::SIDE_NORTH_EAST); } elseif ($block->getSide(Vector3::SIDE_SOUTH) instanceof RailBlock && $block->getSide(Vector3::SIDE_WEST) instanceof RailBlock) { return $this->setDirection(self::SIDE_SOUTH_WEST); } elseif ($block->getSide(Vector3::SIDE_NORTH) instanceof RailBlock && $block->getSide(Vector3::SIDE_WEST) instanceof RailBlock) { return $this->setDirection(self::SIDE_NORTH_WEST); } elseif ($block->getSide(Vector3::SIDE_EAST) instanceof RailBlock && $block->getSide(Vector3::SIDE_WEST) instanceof RailBlock) { if ($up->getSide(Vector3::SIDE_EAST) instanceof RailBlock) { return $this->setDirection(Vector3::SIDE_EAST, true); } elseif ($up->getSide(Vector3::SIDE_WEST) instanceof RailBlock) { return $this->setDirection(Vector3::SIDE_WEST, true); } else { return $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) { return $this->setDirection(Vector3::SIDE_SOUTH, true); } elseif ($up->getSide(Vector3::SIDE_NORTH) instanceof RailBlock) { return $this->setDirection(Vector3::SIDE_NORTH, true); } else { return $this->setDirection(Vector3::SIDE_SOUTH); } } else { return $this->setDirection(Vector3::SIDE_NORTH); } } return false; }