Exemplo n.º 1
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 3, 1 => 2, 2 => 1, 3 => 0];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0] & 0x1;
     $this->getLevel()->setBlock($block, $this, true, true);
     return true;
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
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;
 }
Exemplo n.º 4
0
 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;
 }
Exemplo n.º 5
0
 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;
 }
Exemplo n.º 6
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $down = $this->getSide(0);
     if ($down->isTransparent() === false) {
         $faces = [0 => 3, 1 => 4, 2 => 2, 3 => 5];
         $d = $player instanceof Player ? $player->getDirection() : 0;
         $next = $this->getSide($faces[($d + 3) % 4]);
         $downNext = $this->getSide(0);
         if ($next->canBeReplaced() === true and $downNext->isTransparent() === false) {
             $meta = ($d + 3) % 4 & 0x3;
             $this->getLevel()->setBlock($block, Block::get($this->id, $meta), true, true);
             $this->getLevel()->setBlock($next, Block::get($this->id, $meta | 0x8), true, true);
             return true;
         }
     }
     return false;
 }
Exemplo n.º 7
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3];
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new Compound("", [new Enum("Items", []), new String("id", Tile::FURNACE), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new String("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     return true;
 }
Exemplo n.º 8
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 4, 1 => 2, 2 => 5, 3 => 3];
     $chest = null;
     $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
     for ($side = 2; $side <= 5; ++$side) {
         if (($this->meta === 4 or $this->meta === 5) and ($side === 4 or $side === 5)) {
             continue;
         } elseif (($this->meta === 3 or $this->meta === 2) and ($side === 2 or $side === 3)) {
             continue;
         }
         $c = $this->getSide($side);
         if ($c instanceof Chest and $c->getDamage() === $this->meta) {
             $tile = $this->getLevel()->getTile($c);
             if ($tile instanceof TileChest and !$tile->isPaired()) {
                 $chest = $tile;
                 break;
             }
         }
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     $nbt = new Compound("", [new Enum("Items", []), new String("id", Tile::CHEST), new Int("x", $this->x), new Int("y", $this->y), new Int("z", $this->z)]);
     $nbt->Items->setTagType(NBT::TAG_Compound);
     if ($item->hasCustomName()) {
         $nbt->CustomName = new String("CustomName", $item->getCustomName());
     }
     if ($item->hasCustomBlockData()) {
         foreach ($item->getCustomBlockData() as $key => $v) {
             $nbt->{$key} = $v;
         }
     }
     $tile = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
     if ($chest instanceof TileChest and $tile instanceof TileChest) {
         $chest->pairWith($tile);
         $tile->pairWith($chest);
     }
     return true;
 }
Exemplo n.º 9
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     $faces = [0 => 0, 1 => 2, 2 => 1, 3 => 3];
     $this->meta = $faces[$player->getDirection()] & 0x3;
     if ($fy > 0.5 and $face !== 1 or $face === 0) {
         $this->meta |= 0x4;
         //Upside-down stairs
     }
     $this->getLevel()->setBlock($block, $this, true, true);
     return true;
 }
Exemplo n.º 10
0
 public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null)
 {
     if ($face === 1) {
         $blockUp = $this->getSide(1);
         $blockDown = $this->getSide(0);
         if ($blockUp->canBeReplaced() === false or $blockDown->isTransparent() === true && !($blockDown instanceof Slab && ($blockDown->meta & 0x8) === 0x8) || $blockDown instanceof WoodSlab && ($blockDown->meta & 0x8) === 0x8 || $blockDown instanceof Stair && ($blockDown->meta & 0x4) === 0x4) {
             return false;
         }
         $direction = $player instanceof Player ? $player->getDirection() : 0;
         $face = [0 => 3, 1 => 4, 2 => 2, 3 => 5];
         $next = $this->getSide($face[($direction + 2) % 4]);
         $next2 = $this->getSide($face[$direction]);
         $metaUp = 0x8;
         if ($next->getId() === $this->getId() or $next2->isTransparent() === false and $next->isTransparent() === true) {
             // Door hinge
             $metaUp |= 0x1;
         }
         $this->setDamage($player->getDirection() & 0x3);
         $this->getLevel()->setBlock($block, $this, true, true);
         // Bottom
         $this->getLevel()->setBlock($blockUp, $b = Block::get($this->getId(), $metaUp), true);
         // Top
         $this->onRedstoneUpdate(null, null);
         return true;
     }
     return false;
 }