Stair Block placement

This commit is contained in:
Shoghi Cervantes Pueyo 2013-02-03 20:59:34 +01:00
parent b45676d2b5
commit 8df59078ad
8 changed files with 64 additions and 7 deletions

View File

@ -193,4 +193,5 @@ require_once("block/GenericBlock.php");
require_once("block/SolidBlock.php");
require_once("block/TransparentBlock.php");
require_once("block/FallableBlock.php");
require_once("block/LiquidBlock.php");
require_once("block/LiquidBlock.php");
require_once("block/StairBlock.php");

View File

@ -0,0 +1,56 @@
<?php
/*
-
/ \
/ \
/ PocketMine \
/ MP \
|\ @shoghicp /|
|. \ / .|
| .. \ / .. |
| .. | .. |
| .. | .. |
\ | /
\ | /
\ | /
\ | /
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
*/
class StairBlock extends TransparentBlock{
public function __construct($id, $meta = 0, $name = "Unknown"){
parent::__construct($id, $meta, $name);
}
public function place(BlockAPI $level, Item $item, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if($block->inWorld === true){
$faces = array(
0 => 0,
1 => 2,
2 => 1,
3 => 3,
);
$this->meta = $faces[$player->entity->getDirection()] & 0x03;
if($fy > 0.5){
$this->meta |= 0x04; //Upside-down stairs
}
$level->setBlock($block, $this->id, $this->meta);
return true;
}
return false;
}
public function getDrops(Item $item, Player $player){
return array(
array($this->id, 0, 1),
);
}
}

View File

@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
class BrickStairsBlock extends TransparentBlock{
class BrickStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(BRICK_STAIRS, $meta, "Brick Stairs");
}

View File

@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
class CobblestoneStairsBlock extends TransparentBlock{
class CobblestoneStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(COBBLESTONE_STAIRS, $meta, "Cobblestone Stairs");
}

View File

@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
class NetherBrickStairsBlock extends TransparentBlock{
class NetherBrickStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(NETHER_BRICK_STAIRS, $meta, "Nether Brick Stairs");
}

View File

@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
class SandstoneStairsBlock extends TransparentBlock{
class SandstoneStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(SANDSTONE_STAIRS, $meta, "Sandstone Stairs");
}

View File

@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
class StoneBrickStairsBlock extends TransparentBlock{
class StoneBrickStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(STONE_BRICK_STAIRS, $meta, "Stone Brick Stairs");
}

View File

@ -25,7 +25,7 @@ the Free Software Foundation, either version 3 of the License, or
*/
class WoodStairsBlock extends TransparentBlock{
class WoodStairsBlock extends StairBlock{
public function __construct($meta = 0){
parent::__construct(WOOD_STAIRS, $meta, "Wood Stairs");
}