public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz) { if ($target->isTransparent() === false and $face !== 0 and $face !== 1 and $block->isSolid() === false) { $faces = [2 => 0, 3 => 2, 4 => 1, 5 => 3]; $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]]; $motive = $motives[mt_rand(0, count($motives) - 1)]; $data = ["x" => $target->x, "y" => $target->y + 0.4, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]]; $nbt = new Compound("", ["Motive" => new String("Motive", $data["Motive"]), "Pos" => new Enum("Pos", [new Double("", $data["x"]), new Double("", $data["y"]), new Double("", $data["z"])]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", $data["yaw"]), new Float("", 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); }*/ return true; } return false; }
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; $result->setDamage($target->getId()); $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 ($targetBlock instanceof Liquid) { $result = clone $this; $result->setDamage(0); $player->getServer()->getPluginManager()->callEvent($ev = new PlayerBucketFillEvent($player, $block, $face, $this, $result)); if (!$ev->isCancelled()) { $player->getLevel()->setBlock($block, $targetBlock, true, true); if ($player->isSurvival()) { $player->getInventory()->setItemInHand($ev->getItem(), $player); } return true; } else { $player->getInventory()->sendContents($player); } } return false; }
public function onActivate(Level $level, Player $player, $block, $target, $face, $fx, $fy, $fz) { foreach ($player->getLevel()->getEntities() as $entity) { if ($entity instanceof FishingHook) { if ($entity->shootingEntity === $player) { $entity->reelLine(); } } } }
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; }
/** * * @param Player $player */ public function spawnTo(Player $player) { if ($this->spawned and $player->spawned and $this->isAlive() and $player->isAlive() and $player->getLevel() === $this->level and $player->canSee($this) and !$this->isSpectator()) { parent::spawnTo($player); } }