From 34db027ffd95c94b7e96fa5b385b22054f8b4533 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Sat, 2 Feb 2013 15:53:22 +0100 Subject: [PATCH] Corrected block metadata --- src/API/LevelAPI.php | 4 ++-- src/classes/Player.php | 3 ++- src/classes/material/Block.php | 2 +- src/classes/material/block/plant/Sapling.php | 6 +++--- src/classes/material/block/plant/TallGrass.php | 6 +++--- src/classes/material/block/solid/Leaves.php | 6 +++--- src/classes/material/block/solid/Planks.php | 4 ++-- src/classes/material/block/solid/Sandstone.php | 6 +++--- src/classes/material/block/solid/Wood.php | 6 +++--- src/classes/material/block/solid/Wool.php | 6 +++--- 10 files changed, 25 insertions(+), 24 deletions(-) diff --git a/src/API/LevelAPI.php b/src/API/LevelAPI.php index 3e6a8c25..be8acf7b 100644 --- a/src/API/LevelAPI.php +++ b/src/API/LevelAPI.php @@ -43,7 +43,7 @@ class LevelAPI{ switch($event){ case "player.block.place": 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); $this->setBlock($data["x"], $data["y"], $data["z"], $data["block"], $data["meta"]); break; @@ -52,7 +52,7 @@ class LevelAPI{ if($block[0] === 0){ 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); $this->setBlock($data["x"], $data["y"], $data["z"], 0, 0, true, true); break; diff --git a/src/classes/Player.php b/src/classes/Player.php index 881d68fe..d356274c 100644 --- a/src/classes/Player.php +++ b/src/classes/Player.php @@ -549,7 +549,8 @@ class Player{ if($this->server->handle("player.equipment.change", $data) !== false){ $this->equipment[0] = $data["block"]; $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; case MC_REQUEST_CHUNK: diff --git a/src/classes/material/Block.php b/src/classes/material/Block.php index f81cdfe3..8cd91f93 100644 --- a/src/classes/material/Block.php +++ b/src/classes/material/Block.php @@ -58,7 +58,7 @@ abstract class Block{ } final public function getMetadata(){ - return $meta & 0x0F; + return $this->meta & 0x0F; } final public function position(Vector3 $v){ diff --git a/src/classes/material/block/plant/Sapling.php b/src/classes/material/block/plant/Sapling.php index a0b56c11..c98a6e33 100644 --- a/src/classes/material/block/plant/Sapling.php +++ b/src/classes/material/block/plant/Sapling.php @@ -31,8 +31,8 @@ class SaplingBlock extends TransparentBlock{ const BIRCH = 2; const BURN_TIME = 5; - public function __construct($type = Sapling::OAK){ - parent::__construct(SAPLING, $type, "Sapling"); + public function __construct($meta = Sapling::OAK){ + parent::__construct(SAPLING, $meta, "Sapling"); $this->isActivable = true; $this->isFlowable = true; $names = array( @@ -40,7 +40,7 @@ class SaplingBlock extends TransparentBlock{ 1 => "Spruce 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){ diff --git a/src/classes/material/block/plant/TallGrass.php b/src/classes/material/block/plant/TallGrass.php index be507038..3abc14ae 100644 --- a/src/classes/material/block/plant/TallGrass.php +++ b/src/classes/material/block/plant/TallGrass.php @@ -26,8 +26,8 @@ the Free Software Foundation, either version 3 of the License, or */ class TallGrassBlock extends FlowableBlock{ - public function __construct($type = 1){ - parent::__construct(TALL_GRASS, $type, "Tall Grass"); + public function __construct($meta = 1){ + parent::__construct(TALL_GRASS, $meta, "Tall Grass"); $this->isFlowable = true; $this->isReplaceable = true; $names = array( @@ -35,7 +35,7 @@ class TallGrassBlock extends FlowableBlock{ 1 => "Tall Grass", 2 => "Fern", ); - $this->name = $names[$this->type & 0x03]; + $this->name = $names[$this->meta & 0x03]; } } \ No newline at end of file diff --git a/src/classes/material/block/solid/Leaves.php b/src/classes/material/block/solid/Leaves.php index 2d981fe3..9af56ea0 100644 --- a/src/classes/material/block/solid/Leaves.php +++ b/src/classes/material/block/solid/Leaves.php @@ -26,14 +26,14 @@ the Free Software Foundation, either version 3 of the License, or */ class LeavesBlock extends TransparentBlock{ - public function __construct($type = 0){ - parent::__construct(LEAVES, $type, "Leaves"); + public function __construct($meta = 0){ + parent::__construct(LEAVES, $meta, "Leaves"); $names = array( 0 => "Oak Leaves", 1 => "Spruce Leaves", 2 => "Birch Leaves", ); - $this->name = $names[$this->type & 0x03]; + $this->name = $names[$this->meta & 0x03]; } } \ No newline at end of file diff --git a/src/classes/material/block/solid/Planks.php b/src/classes/material/block/solid/Planks.php index d41c3d3f..3f52017d 100644 --- a/src/classes/material/block/solid/Planks.php +++ b/src/classes/material/block/solid/Planks.php @@ -26,8 +26,8 @@ the Free Software Foundation, either version 3 of the License, or */ class PlanksBlock extends SolidBlock{ - public function __construct($type = 0){ - parent::__construct(PLANKS, $type, "Wooden Planks"); + public function __construct($meta = 0){ + parent::__construct(PLANKS, $meta, "Wooden Planks"); } } \ No newline at end of file diff --git a/src/classes/material/block/solid/Sandstone.php b/src/classes/material/block/solid/Sandstone.php index ddaa2555..76fcfafb 100644 --- a/src/classes/material/block/solid/Sandstone.php +++ b/src/classes/material/block/solid/Sandstone.php @@ -26,14 +26,14 @@ the Free Software Foundation, either version 3 of the License, or */ class SandstoneBlock extends SolidBlock{ - public function __construct($type = 0){ - parent::__construct(SANDSTONE, $type, "Sandstone"); + public function __construct($meta = 0){ + parent::__construct(SANDSTONE, $meta, "Sandstone"); $names = array( 0 => "Sandstone", 1 => "Chiseled Sandstone", 2 => "Smooth Sandstone", ); - $this->name = $names[$this->type & 0x03]; + $this->name = $names[$this->meta & 0x03]; } } \ No newline at end of file diff --git a/src/classes/material/block/solid/Wood.php b/src/classes/material/block/solid/Wood.php index 42a0cfad..45a49908 100644 --- a/src/classes/material/block/solid/Wood.php +++ b/src/classes/material/block/solid/Wood.php @@ -29,14 +29,14 @@ class WoodBlock extends SolidBlock{ const OAK = 0; const SPRUCE = 1; const BIRCH = 2; - public function __construct($type = 0){ - parent::__construct(WOOD, $type, "Wood"); + public function __construct($meta = 0){ + parent::__construct(WOOD, $meta, "Wood"); $names = array( 0 => "Oak Wood", 1 => "Spruce Wood", 2 => "Birch Wood", ); - $this->name = $names[$this->type & 0x03]; + $this->name = $names[$this->meta & 0x03]; } } \ No newline at end of file diff --git a/src/classes/material/block/solid/Wool.php b/src/classes/material/block/solid/Wool.php index 809dad2f..592e5389 100644 --- a/src/classes/material/block/solid/Wool.php +++ b/src/classes/material/block/solid/Wool.php @@ -26,8 +26,8 @@ the Free Software Foundation, either version 3 of the License, or */ class WoolBlock extends SolidBlock{ - public function __construct($type = 0){ - parent::__construct(WOOL, $type, "Wool"); + public function __construct($meta = 0){ + parent::__construct(WOOL, $meta, "Wool"); $names = array( 0 => "White Wool", 1 => "Orange Wool", @@ -46,7 +46,7 @@ class WoolBlock extends SolidBlock{ 14 => "Red Wool", 15 => "Black Wool", ); - $this->name = $names[$this->type]; + $this->name = $names[$this->meta]; } } \ No newline at end of file