Corrected block metadata

This commit is contained in:
Shoghi Cervantes Pueyo 2013-02-02 15:53:22 +01:00
parent bbd113692e
commit 34db027ffd
10 changed files with 25 additions and 24 deletions

View File

@ -43,7 +43,7 @@ class LevelAPI{
switch($event){ switch($event){
case "player.block.place": case "player.block.place":
case "player.block.update": case "player.block.update":
$b = BlockAPI::get($data["block"]); $b = BlockAPI::get($data["block"], $data["meta"]);
console("[DEBUG] Player ".$data["entity"]->player->username." placed ".$b->getName()." (".$data["block"].":".$data["meta"].") at (".$data["x"].", ".$data["y"].", ".$data["z"].")", true, true, 2); console("[DEBUG] Player ".$data["entity"]->player->username." placed ".$b->getName()." (".$data["block"].":".$data["meta"].") at (".$data["x"].", ".$data["y"].", ".$data["z"].")", true, true, 2);
$this->setBlock($data["x"], $data["y"], $data["z"], $data["block"], $data["meta"]); $this->setBlock($data["x"], $data["y"], $data["z"], $data["block"], $data["meta"]);
break; break;
@ -52,7 +52,7 @@ class LevelAPI{
if($block[0] === 0){ if($block[0] === 0){
break; break;
} }
$b = BlockAPI::get($block[0]); $b = BlockAPI::get($block[0], $block[1]);
console("[DEBUG] Player ".$data["entity"]->player->username." broke ".$b->getName()." (".$block[0].":".$block[1].") at (".$data["x"].", ".$data["y"].", ".$data["z"].")", true, true, 2); console("[DEBUG] Player ".$data["entity"]->player->username." broke ".$b->getName()." (".$block[0].":".$block[1].") at (".$data["x"].", ".$data["y"].", ".$data["z"].")", true, true, 2);
$this->setBlock($data["x"], $data["y"], $data["z"], 0, 0, true, true); $this->setBlock($data["x"], $data["y"], $data["z"], 0, 0, true, true);
break; break;

View File

@ -549,7 +549,8 @@ class Player{
if($this->server->handle("player.equipment.change", $data) !== false){ if($this->server->handle("player.equipment.change", $data) !== false){
$this->equipment[0] = $data["block"]; $this->equipment[0] = $data["block"];
$this->equipment[1] = $data["meta"]; $this->equipment[1] = $data["meta"];
console("[DEBUG] EID ".$this->eid." has now ".$data["block"].":".$data["meta"]." in their hands!", true, true, 2); $b = BlockAPI::get($data["block"], $data["meta"]);
console("[DEBUG] Player ".$this->username." has now ".$b->getName()." (".$data["block"].":".$data["meta"].") in their hands!", true, true, 2);
} }
break; break;
case MC_REQUEST_CHUNK: case MC_REQUEST_CHUNK:

View File

@ -58,7 +58,7 @@ abstract class Block{
} }
final public function getMetadata(){ final public function getMetadata(){
return $meta & 0x0F; return $this->meta & 0x0F;
} }
final public function position(Vector3 $v){ final public function position(Vector3 $v){

View File

@ -31,8 +31,8 @@ class SaplingBlock extends TransparentBlock{
const BIRCH = 2; const BIRCH = 2;
const BURN_TIME = 5; const BURN_TIME = 5;
public function __construct($type = Sapling::OAK){ public function __construct($meta = Sapling::OAK){
parent::__construct(SAPLING, $type, "Sapling"); parent::__construct(SAPLING, $meta, "Sapling");
$this->isActivable = true; $this->isActivable = true;
$this->isFlowable = true; $this->isFlowable = true;
$names = array( $names = array(
@ -40,7 +40,7 @@ class SaplingBlock extends TransparentBlock{
1 => "Spruce Sapling", 1 => "Spruce Sapling",
2 => "Birch Sapling", 2 => "Birch Sapling",
); );
$this->name = $names[$this->type & 0x03]; $this->name = $names[$this->meta & 0x03];
} }
public function onActivate(LevelAPI $level, Item $item, Player $player){ public function onActivate(LevelAPI $level, Item $item, Player $player){

View File

@ -26,8 +26,8 @@ the Free Software Foundation, either version 3 of the License, or
*/ */
class TallGrassBlock extends FlowableBlock{ class TallGrassBlock extends FlowableBlock{
public function __construct($type = 1){ public function __construct($meta = 1){
parent::__construct(TALL_GRASS, $type, "Tall Grass"); parent::__construct(TALL_GRASS, $meta, "Tall Grass");
$this->isFlowable = true; $this->isFlowable = true;
$this->isReplaceable = true; $this->isReplaceable = true;
$names = array( $names = array(
@ -35,7 +35,7 @@ class TallGrassBlock extends FlowableBlock{
1 => "Tall Grass", 1 => "Tall Grass",
2 => "Fern", 2 => "Fern",
); );
$this->name = $names[$this->type & 0x03]; $this->name = $names[$this->meta & 0x03];
} }
} }

View File

@ -26,14 +26,14 @@ the Free Software Foundation, either version 3 of the License, or
*/ */
class LeavesBlock extends TransparentBlock{ class LeavesBlock extends TransparentBlock{
public function __construct($type = 0){ public function __construct($meta = 0){
parent::__construct(LEAVES, $type, "Leaves"); parent::__construct(LEAVES, $meta, "Leaves");
$names = array( $names = array(
0 => "Oak Leaves", 0 => "Oak Leaves",
1 => "Spruce Leaves", 1 => "Spruce Leaves",
2 => "Birch Leaves", 2 => "Birch Leaves",
); );
$this->name = $names[$this->type & 0x03]; $this->name = $names[$this->meta & 0x03];
} }
} }

View File

@ -26,8 +26,8 @@ the Free Software Foundation, either version 3 of the License, or
*/ */
class PlanksBlock extends SolidBlock{ class PlanksBlock extends SolidBlock{
public function __construct($type = 0){ public function __construct($meta = 0){
parent::__construct(PLANKS, $type, "Wooden Planks"); parent::__construct(PLANKS, $meta, "Wooden Planks");
} }
} }

View File

@ -26,14 +26,14 @@ the Free Software Foundation, either version 3 of the License, or
*/ */
class SandstoneBlock extends SolidBlock{ class SandstoneBlock extends SolidBlock{
public function __construct($type = 0){ public function __construct($meta = 0){
parent::__construct(SANDSTONE, $type, "Sandstone"); parent::__construct(SANDSTONE, $meta, "Sandstone");
$names = array( $names = array(
0 => "Sandstone", 0 => "Sandstone",
1 => "Chiseled Sandstone", 1 => "Chiseled Sandstone",
2 => "Smooth Sandstone", 2 => "Smooth Sandstone",
); );
$this->name = $names[$this->type & 0x03]; $this->name = $names[$this->meta & 0x03];
} }
} }

View File

@ -29,14 +29,14 @@ class WoodBlock extends SolidBlock{
const OAK = 0; const OAK = 0;
const SPRUCE = 1; const SPRUCE = 1;
const BIRCH = 2; const BIRCH = 2;
public function __construct($type = 0){ public function __construct($meta = 0){
parent::__construct(WOOD, $type, "Wood"); parent::__construct(WOOD, $meta, "Wood");
$names = array( $names = array(
0 => "Oak Wood", 0 => "Oak Wood",
1 => "Spruce Wood", 1 => "Spruce Wood",
2 => "Birch Wood", 2 => "Birch Wood",
); );
$this->name = $names[$this->type & 0x03]; $this->name = $names[$this->meta & 0x03];
} }
} }

View File

@ -26,8 +26,8 @@ the Free Software Foundation, either version 3 of the License, or
*/ */
class WoolBlock extends SolidBlock{ class WoolBlock extends SolidBlock{
public function __construct($type = 0){ public function __construct($meta = 0){
parent::__construct(WOOL, $type, "Wool"); parent::__construct(WOOL, $meta, "Wool");
$names = array( $names = array(
0 => "White Wool", 0 => "White Wool",
1 => "Orange Wool", 1 => "Orange Wool",
@ -46,7 +46,7 @@ class WoolBlock extends SolidBlock{
14 => "Red Wool", 14 => "Red Wool",
15 => "Black Wool", 15 => "Black Wool",
); );
$this->name = $names[$this->type]; $this->name = $names[$this->meta];
} }
} }