isTransparent() public method

public isTransparent ( ) : boolean
return boolean
Example #1
0
 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 => 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 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;
 }
 /**
  * @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));
 }
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $this->getSide(0);
     if ($target->isTransparent() === false and $face !== 0) {
         $faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
         $this->meta = $faces[$face];
         $side = $faces[$face];
         $faces = [1 => 4, 2 => 5, 3 => 2, 4 => 3, 5 => 0, 6 => 0, 0 => 0];
         if ($this->getSide($faces[$side])->isCharged($this->getHash())) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
         return true;
     } elseif ($down->isTransparent() === false or $down->getId() === self::FENCE or $down->getId() === self::COBBLE_WALL or $down->getId() === self::GLASS || $down instanceof Slab && ($down->meta & 0x8) === 0x8 || $down instanceof WoodSlab && ($down->meta & 0x8) === 0x8 || $down instanceof Stair && ($down->meta & 0x4) === 0x4) {
         $this->meta = 0;
         if ($target->isCharged($this->getHash())) {
             $this->id = 75;
             $this->getLevel()->setBlock($block, $this);
             return;
         }
         $this->getLevel()->setBlock($block, $this);
         $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, Block::REDSTONESOURCEPOWER);
         return true;
     }
     return false;
 }
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false || $target->getId() === self::FENCE) {
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #5
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (!$target->isTransparent() || ($face === 0 && ($this->getSide(0) instanceof Slab && ($this->getSide(0)->meta & 0x8) === 0x8) || $this->getSide(0) instanceof WoodSlab && ($this->getSide(0)->meta & 0x8) === 0x8 || $this->getSide(0) instanceof Stair && ($this->getSide(0)->meta & 0x4) === 0x4)) {
         $this->meta = $face;
         $this->getLevel()->setBlock($block, $this, true, false);
         return true;
     }
     return false;
 }
Example #6
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($face !== 0 && $face !== 1 && !$target->isTransparent()) {
         $ret = $this->setFacingDirection($face);
         $this->getLevel()->setBlock($block, $this, true);
         return $ret;
     }
     return false;
 }
Example #7
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5];
         $this->setDamage($faces[$face]);
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [2 => 3, 3 => 0, 0 => 1, 1 => 2];
         $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (!$target->isTransparent()) {
         $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #10
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = \null)
 {
     if ($target->isTransparent() === \false) {
         $faces = [2 => 2, 3 => 3, 4 => 4, 5 => 5];
         if (isset($faces[$face])) {
             $this->meta = $faces[$face];
             $this->getLevel()->setBlock($block, $this, \true, \true);
             return \true;
         }
     }
     return \false;
 }
Example #11
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false and $face > 1 and $block->isSolid() === false) {
         $faces = [2 => 3, 3 => 2, 4 => 1, 5 => 0];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         $nbt = new CompoundTag("", [new StringTag("id", Tile::ITEM_FRAME), new IntTag("x", $block->x), new IntTag("y", $block->y), new IntTag("z", $block->z), new ByteTag("ItemRotation", 0), new FloatTag("ItemDropChance", 1.0)]);
         Tile::createTile(Tile::ITEM_FRAME, $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)
 {
     if (($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1) {
         $faces = [2 => 0, 3 => 1, 4 => 2, 5 => 3];
         $this->meta = $faces[$face] & 0x3;
         if ($fy > 0.5) {
             $this->meta |= 0x8;
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #13
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false and $face !== 0) {
         $faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     } elseif ($below->isTransparent() === false) {
         $this->meta = 0;
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #14
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1) {
         $faces = [self::SIDE_SOUTH => self::MASK_SIDE_SOUTH, self::SIDE_NORTH => self::MASK_SIDE_NORTH, self::SIDE_EAST => self::MASK_SIDE_EAST, self::SIDE_WEST => self::MASK_SIDE_WEST];
         echo $face, PHP_EOL, $faces[$face], PHP_EOL;
         $this->meta = $faces[$face] & self::MASK_SIDE;
         if ($fy > 0.5) {
             $this->meta |= self::MASK_UPPER;
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $below = $this->getSide(0);
     if ($target->isTransparent() === false and $face !== 0) {
         $faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     } elseif ($this->getSide($faces[$side])->isTransparent() === true and !($side === 0 and ($below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL or $below->getId() === self::GLASS || $below instanceof Slab && ($below->meta & 0x8) === 0x8 || $below instanceof WoodSlab && ($below->meta & 0x8) === 0x8 || $below instanceof Stair && ($below->meta & 0x4) === 0x4))) {
         $this->meta = 0;
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #16
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = \null)
 {
     $below = $this->getSide(0);
     if ($target->isTransparent() === \false and $face !== 0) {
         $faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, \true, \true);
         return \true;
     } elseif ($below->isTransparent() === \false or $below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL) {
         $this->meta = 0;
         $this->getLevel()->setBlock($block, $this, \true, \true);
         return \true;
     }
     return \false;
 }
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $below = $this->getSide(0);
     $this->BroadcastRedstoneUpdate(Level::REDSTONE_UPDATE_PLACE, $this->getPower(), $this);
     if ($target->isTransparent() === false and $face !== 0) {
         $faces = [1 => 5, 2 => 4, 3 => 3, 4 => 2, 5 => 1];
         $this->meta = $faces[$face];
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     } elseif ($below->isTransparent() === false or $below->getId() === self::FENCE or $below->getId() === self::COBBLE_WALL) {
         $this->meta = 0;
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #18
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1) {
         //Search the correct combination of 2,3,4,5
         //Trapdoor works if it placed in the bottom of block, if placed in top doesn't work
         $faces = [2 => 0, 3 => 1, 4 => 2, 5 => 3];
         $this->meta = $faces[$face] & 0x3;
         if ($fy > 0.5) {
             $this->meta |= 0x8;
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         $this->getLevel()->addSound(new DoorSound($this));
         return true;
     }
     return false;
 }
Example #19
0
 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]];
         $motive = $motives[mt_rand(0, count($motives) - 1)];
         $data = ["x" => $target->x, "y" => $target->y, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
         //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;
 }
Example #20
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [0 => 0, 1 => 1, 2 => 2, 3 => 3];
         $damage = $this->getDamage();
         $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x4;
         if ($damage >= 0 && $damage <= 3) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
         } elseif ($damage >= 4 && $damage <= 7) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x4;
         } elseif ($damage >= 8 && $damage <= 11) {
             $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] | 0x8;
         }
         $this->getLevel()->setBlock($block, $this, true);
         return true;
     }
     return false;
 }
Example #21
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($target->isTransparent() === false) {
         $faces = [3 => 3, 2 => 4, 4 => 2, 5 => 1];
         if ($face === 0) {
             $to = $player instanceof Player ? $player->getDirection() : 0;
             $this->meta = $to ^ 0x1 === 0x1 ? 0 : 7;
         } elseif ($face === 1) {
             $to = $player instanceof Player ? $player->getDirection() : 0;
             $this->meta = $to ^ 0x1 === 0x1 ? 6 : 5;
         } else {
             $this->meta = $faces[$face];
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #22
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1) {
         $faces = [];
         switch ($faces) {
             case 0x0:
                 return Vector3::SIDE_SOUTH;
             case 0x1:
                 return Vector3::SIDE_NORTH;
             case 0x2:
                 return Vector3::SIDE_EAST;
             case 0x3:
                 return Vector3::SIDE_WEST;
         }
         $this->meta = $faces[$face] & 0x3;
         if ($fy > 0.5) {
             $this->meta |= 0x8;
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #23
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (($target->isTransparent() === false or $target->getId() === self::SLAB) and $face !== 0 and $face !== 1) {
         switch ($face) {
             case 2:
                 $this->meta |= 0b11;
                 break;
             case 3:
                 $this->meta |= 0b10;
                 break;
             case 4:
                 $this->meta |= 0b1;
                 break;
             case 5:
                 break;
         }
         if ($fy > 0.5) {
             $this->meta |= 0b100;
         }
         $this->getLevel()->setBlock($block, $this, true, true);
         return true;
     }
     return false;
 }
Example #24
0
 public function canConnect(Block $block)
 {
     //TODO: activate comments when the NetherBrickFenceGate class has been created.
     return $block instanceof NetherBrickFence ? true : $block->isSolid() and !$block->isTransparent();
 }
 public function canConnect(Block $block)
 {
     return ($block->getId() !== self::COBBLE_WALL and $block->getId() !== self::FENCE_GATE) ? $block->isSolid() and !$block->isTransparent() : true;
 }
Example #26
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if (!$target->isTransparent() and $target->isSolid()) {
         $faces = [0 => 0, 1 => 0, 2 => 1, 3 => 4, 4 => 8, 5 => 2];
         if (isset($faces[$face])) {
             $this->meta = $faces[$face];
             $this->getLevel()->setBlock($block, $this, true, true);
             return true;
         }
     }
     return false;
 }
Example #27
0
 public function canConnect(Block $block)
 {
     return ($block instanceof Fence or $block instanceof FenceGate) ? true : $block->isSolid() and !$block->isTransparent();
 }
Example #28
0
 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 => 1, 3 => 3, 4 => 0, 5 => 2];
         $motives = PaintingEntity::MOTIVES;
         $face2side = [4, 5, 3, 2];
         $foundApplicableMotive = false;
         $searchedMotives = [];
         while (!$foundApplicableMotive) {
             if (count($searchedMotives) == count($motives)) {
                 break;
             }
             $rand = -1;
             while (!isset($motives[$rand])) {
                 $rand = mt_rand(0, count($motives) - 1);
             }
             $motive = $motives[$rand];
             $foundApplicableMotive = true;
             $searchedMotives[$rand] = true;
             for ($x = 0; $x < $motive[1] && $foundApplicableMotive; $x++) {
                 for ($z = 0; $z < $motive[2] && $foundApplicableMotive; $z++) {
                     if ($target->getSide($face2side[$face - 2], $x)->isTransparent() || $target->getSide(Vector3::SIDE_UP, $z)->isTransparent() || $block->getSide($face2side[$face - 2], $x)->isSolid() || $block->getSide(Vector3::SIDE_UP, $z)->isSolid()) {
                         $foundApplicableMotive = false;
                     }
                 }
             }
         }
         if (!$foundApplicableMotive) {
             return false;
         }
         //WIP overlapping calculation AND BTW: EVEN MCPE DOESN'T DO THIS!
         /*
         for($x = 0; $x < $motive[1] && $valid; $x++){
         	for($z = 0; $z < $motive[2] && $valid; $z++){
         		$entPos = $target->getSide($right[$face - 2], $x);
         		//getEntitiesAtThatPos (high intensive calculation)
         		if($entity instanceof PaintingEntity){
         			return false;
         		}
         	}
         }
         */
         $data = ["x" => $target->x, "y" => $target->y - 0.1, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
         if ($motive[2] <= 1) {
             $data["y"] = $data["y"] + 1;
         }
         if ($motive[2] >= 2) {
             $data["y"] = $data["y"] + 0.4;
         }
         if ($motive[2] >= 3) {
             $data["y"] = $data["y"] + 0.1;
         }
         switch ($face2side[$face - 2]) {
             case Vector3::SIDE_NORTH:
                 $data["z"] = $data["z"] + 0.1;
                 break;
             case Vector3::SIDE_SOUTH:
                 $data["z"] = $data["z"] - 0.1;
                 break;
             case Vector3::SIDE_WEST:
                 $data["x"] = $data["x"] + 0.1;
                 break;
             case Vector3::SIDE_EAST:
                 $data["x"] = $data["x"] - 0.1;
                 break;
         }
         $nbt = new CompoundTag("", ["Motive" => new StringTag("Motive", $data["Motive"]), "Pos" => new ListTag("Pos", [new DoubleTag("", $data["x"]), new DoubleTag("", $data["y"]), new DoubleTag("", $data["z"])]), "Motion" => new ListTag("Motion", [new DoubleTag("", 0), new DoubleTag("", 0), new DoubleTag("", 0)]), "Rotation" => new ListTag("Rotation", [new FloatTag("", $data["yaw"]), new FloatTag("", 0)])]);
         $painting = new PaintingEntity($player->getLevel()->getChunk($block->getX() >> 4, $block->getZ() >> 4), $nbt);
         $painting->spawnToAll();
         unset($player->getLevel()->updateEntities[$painting->getId()]);
         if ($player->isSurvival()) {
             $item = $player->getInventory()->getItemInHand();
             $count = $item->getCount();
             if (--$count <= 0) {
                 $player->getInventory()->setItemInHand(Item::get(Item::AIR));
             }
             $item->setCount($count);
             $player->getInventory()->setItemInHand($item);
         }
         return true;
     }
     return false;
 }
Example #29
-1
 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) {
         $chunk = $level->getChunk($block->getX() >> 4, $block->getZ() >> 4);
         $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]];
         if ($this->hasCustomName()) {
             $nbt->CustomName = new String("CustomName", $this->getCustomName());
         }
         $motive = $motives[mt_rand(0, count($motives) - 1)];
         $data = ["x" => $target->x, "y" => $target->y, "z" => $target->z, "yaw" => $faces[$face] * 90, "Motive" => $motive[0]];
         $nbt = new Compound("", ["Pos" => new Enum("Pos", [new Double("", $target->x), new Double("", $target->y), new Double("", $target->z)]), "Motion" => new Enum("Motion", [new Double("", 0), new Double("", 0), new Double("", 0)]), "Rotation" => new Enum("Rotation", [new Float("", $faces[$face] * 90), new Float("", 0)])]);
         $entity = Entity::createEntity($this->meta, $chunk, $nbt, $data);
         if ($entity instanceof Entity) {
             if ($player->isSurvival()) {
                 --$this->count;
             }
             $entity->spawnToAll();
             return true;
         }
         return true;
     }
     return false;
 }