Updated method names: getMetadata() & setMetadata() to getDamage() & setDamage() on Block and Item classes

This commit is contained in:
Shoghi Cervantes 2014-05-22 18:37:28 +02:00
parent c1546aac9c
commit 0be679c9d5
29 changed files with 101 additions and 81 deletions

View File

@ -900,7 +900,7 @@ class Player extends Human implements CommandSender, IPlayer{
if($data->getLevel() === $this->getLevel()){ if($data->getLevel() === $this->getLevel()){
$pk = new SetEntityDataPacket; $pk = new SetEntityDataPacket;
$pk->eid = $eid; $pk->eid = $eid;
$pk->metadata = $data->getMetadata(); $pk->metadata = $data->getDamage();
$this->dataPacket($pk); $this->dataPacket($pk);
} }
break; break;
@ -1547,7 +1547,7 @@ class Player extends Human implements CommandSender, IPlayer{
$pk->y = $target->y; $pk->y = $target->y;
$pk->z = $target->z; $pk->z = $target->z;
$pk->block = $target->getID(); $pk->block = $target->getID();
$pk->meta = $target->getMetadata(); $pk->meta = $target->getDamage();
$this->dataPacket($pk); $this->dataPacket($pk);
$pk = new UpdateBlockPacket; $pk = new UpdateBlockPacket;
@ -1555,7 +1555,7 @@ class Player extends Human implements CommandSender, IPlayer{
$pk->y = $block->y; $pk->y = $block->y;
$pk->z = $block->z; $pk->z = $block->z;
$pk->block = $block->getID(); $pk->block = $block->getID();
$pk->meta = $block->getMetadata(); $pk->meta = $block->getDamage();
$this->dataPacket($pk); $this->dataPacket($pk);
break; break;
} }
@ -1576,7 +1576,7 @@ class Player extends Human implements CommandSender, IPlayer{
if($this->getLevel()->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this) === true){ if($this->getLevel()->useItemOn($blockVector, $item, $packet->face, $packet->fx, $packet->fy, $packet->fz, $this) === true){
break; break;
} }
}elseif($this->getSlot($this->getCurrentEquipment())->getID() !== $packet->item or ($this->getSlot($this->getCurrentEquipment())->isTool() === false and $this->getSlot($this->getCurrentEquipment())->getMetadata() !== $packet->meta)){ }elseif($this->getSlot($this->getCurrentEquipment())->getID() !== $packet->item or ($this->getSlot($this->getCurrentEquipment())->isTool() === false and $this->getSlot($this->getCurrentEquipment())->getDamage() !== $packet->meta)){
$this->sendInventorySlot($this->getCurrentEquipment()); $this->sendInventorySlot($this->getCurrentEquipment());
}else{ }else{
$item = clone $this->getSlot($this->getCurrentEquipment()); $item = clone $this->getSlot($this->getCurrentEquipment());
@ -1595,7 +1595,7 @@ class Player extends Human implements CommandSender, IPlayer{
$pk->y = $target->y; $pk->y = $target->y;
$pk->z = $target->z; $pk->z = $target->z;
$pk->block = $target->getID(); $pk->block = $target->getID();
$pk->meta = $target->getMetadata(); $pk->meta = $target->getDamage();
$this->dataPacket($pk); $this->dataPacket($pk);
$pk = new UpdateBlockPacket; $pk = new UpdateBlockPacket;
@ -1603,7 +1603,7 @@ class Player extends Human implements CommandSender, IPlayer{
$pk->y = $block->y; $pk->y = $block->y;
$pk->z = $block->z; $pk->z = $block->z;
$pk->block = $block->getID(); $pk->block = $block->getID();
$pk->meta = $block->getMetadata(); $pk->meta = $block->getDamage();
$this->dataPacket($pk); $this->dataPacket($pk);
break; break;
}elseif($packet->face === 0xff){ }elseif($packet->face === 0xff){
@ -1718,7 +1718,7 @@ class Player extends Human implements CommandSender, IPlayer{
$pk->y = $target->y; $pk->y = $target->y;
$pk->z = $target->z; $pk->z = $target->z;
$pk->block = $target->getID(); $pk->block = $target->getID();
$pk->meta = $target->getMetadata(); $pk->meta = $target->getDamage();
$this->directDataPacket($pk); $this->directDataPacket($pk);
break; break;
case ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET: case ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET:
@ -1751,7 +1751,7 @@ class Player extends Human implements CommandSender, IPlayer{
}else{ }else{
$this->setSlot($sl, Item::get(Item::AIR, 0, 0)); $this->setSlot($sl, Item::get(Item::AIR, 0, 0));
} }
}elseif($s->getID() !== Item::AIR and $slot->getID() !== Item::AIR and ($slot->getID() !== $s->getID() or $slot->getMetadata() !== $s->getMetadata()) and ($sl = $this->hasItem($s, false)) !== false){ }elseif($s->getID() !== Item::AIR and $slot->getID() !== Item::AIR and ($slot->getID() !== $s->getID() or $slot->getDamage() !== $s->getDamage()) and ($sl = $this->hasItem($s, false)) !== false){
if($this->setArmorSlot($i, $this->getSlot($sl)) === false){ if($this->setArmorSlot($i, $this->getSlot($sl)) === false){
$this->sendArmor(); $this->sendArmor();
$this->sendInventory(); $this->sendInventory();
@ -1850,7 +1850,7 @@ class Player extends Human implements CommandSender, IPlayer{
} }
$target->harm($damage, $this->id); $target->harm($damage, $this->id);
if($slot->isTool() === true and ($this->gamemode & 0x01) === 0){ if($slot->isTool() === true and ($this->gamemode & 0x01) === 0){
if($slot->useOn($target) and $slot->getMetadata() >= $slot->getMaxDurability()){ if($slot->useOn($target) and $slot->getDamage() >= $slot->getMaxDurability()){
$this->setSlot($this->getCurrentEquipment(), new Item(AIR, 0, 0)); $this->setSlot($this->getCurrentEquipment(), new Item(AIR, 0, 0));
} }
} }
@ -2034,23 +2034,23 @@ class Player extends Human implements CommandSender, IPlayer{
if($packet->windowid === 0){ if($packet->windowid === 0){
$craft = false; $craft = false;
$slot = $this->getSlot($packet->slot); $slot = $this->getSlot($packet->slot);
if($slot->getCount() >= $packet->item->getCount() and (($slot->getID() === $packet->item->getID() and $slot->getMetadata() === $packet->item->getMetadata()) or ($packet->item->getID() === Item::AIR and $packet->item->getCount() === 0)) and !isset($this->craftingItems[$packet->slot])){ //Crafting recipe if($slot->getCount() >= $packet->item->getCount() and (($slot->getID() === $packet->item->getID() and $slot->getDamage() === $packet->item->getDamage()) or ($packet->item->getID() === Item::AIR and $packet->item->getCount() === 0)) and !isset($this->craftingItems[$packet->slot])){ //Crafting recipe
$use = Item::get($slot->getID(), $slot->getMetadata(), $slot->getCount() - $packet->item->getCount()); $use = Item::get($slot->getID(), $slot->getDamage(), $slot->getCount() - $packet->item->getCount());
$this->craftingItems[$packet->slot] = $use; $this->craftingItems[$packet->slot] = $use;
$craft = true; $craft = true;
}elseif($slot->getCount() <= $packet->item->getCount() and ($slot->getID() === Item::AIR or ($slot->getID() === $packet->item->getID() and $slot->getMetadata() === $packet->item->getMetadata()))){ //Crafting final }elseif($slot->getCount() <= $packet->item->getCount() and ($slot->getID() === Item::AIR or ($slot->getID() === $packet->item->getID() and $slot->getDamage() === $packet->item->getDamage()))){ //Crafting final
$craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount() - $slot->getCount()); $craftItem = Item::get($packet->item->getID(), $packet->item->getDamage(), $packet->item->getCount() - $slot->getCount());
if(count($this->toCraft) === 0){ if(count($this->toCraft) === 0){
$this->toCraft[-1] = 0; $this->toCraft[-1] = 0;
} }
$this->toCraft[$packet->slot] = $craftItem; $this->toCraft[$packet->slot] = $craftItem;
$craft = true; $craft = true;
}elseif(((count($this->toCraft) === 1 and isset($this->toCraft[-1])) or count($this->toCraft) === 0) and $slot->getCount() > 0 and $slot->getID() > Item::AIR and ($slot->getID() !== $packet->item->getID() or $slot->getMetadata() !== $packet->item->getMetadata())){ //Crafting final }elseif(((count($this->toCraft) === 1 and isset($this->toCraft[-1])) or count($this->toCraft) === 0) and $slot->getCount() > 0 and $slot->getID() > Item::AIR and ($slot->getID() !== $packet->item->getID() or $slot->getDamage() !== $packet->item->getDamage())){ //Crafting final
$craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount()); $craftItem = Item::get($packet->item->getID(), $packet->item->getDamage(), $packet->item->getCount());
if(count($this->toCraft) === 0){ if(count($this->toCraft) === 0){
$this->toCraft[-1] = 0; $this->toCraft[-1] = 0;
} }
$use = Item::get($slot->getID(), $slot->getMetadata(), $slot->getCount()); $use = Item::get($slot->getID(), $slot->getDamage(), $slot->getCount());
$this->craftingItems[$packet->slot] = $use; $this->craftingItems[$packet->slot] = $use;
$this->toCraft[$packet->slot] = $craftItem; $this->toCraft[$packet->slot] = $craftItem;
$craft = true; $craft = true;
@ -2091,7 +2091,7 @@ class Player extends Human implements CommandSender, IPlayer{
break; break;
} }
$item = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount()); $item = Item::get($packet->item->getID(), $packet->item->getDamage(), $packet->item->getCount());
$slot = $tile->getSlot($slotn); $slot = $tile->getSlot($slotn);
//TODO: container access events? //TODO: container access events?
@ -2146,7 +2146,7 @@ class Player extends Human implements CommandSender, IPlayer{
){ ){
break; break;
} }
$item = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount()); $item = Item::get($packet->item->getID(), $packet->item->getDamage(), $packet->item->getCount());
$slot = $tile->getSlot($packet->slot); $slot = $tile->getSlot($packet->slot);
//TODO: container access events? //TODO: container access events?
@ -2422,10 +2422,10 @@ class Player extends Human implements CommandSender, IPlayer{
foreach($craft as $item){ foreach($craft as $item){
if($item instanceof Item){ if($item instanceof Item){
$craftItem[0] = $item->getID(); $craftItem[0] = $item->getID();
if($item->getMetadata() !== $craftItem[1] and $craftItem[1] !== true){ if($item->getDamage() !== $craftItem[1] and $craftItem[1] !== true){
$craftItem[1] = false; $craftItem[1] = false;
}else{ }else{
$craftItem[1] = $item->getMetadata(); $craftItem[1] = $item->getDamage();
} }
$craftItem[2] += $item->getCount(); $craftItem[2] += $item->getCount();
} }
@ -2435,9 +2435,9 @@ class Player extends Human implements CommandSender, IPlayer{
$recipeItems = array(); $recipeItems = array();
foreach($recipe as $item){ foreach($recipe as $item){
if(!isset($recipeItems[$item->getID()])){ if(!isset($recipeItems[$item->getID()])){
$recipeItems[$item->getID()] = array($item->getID(), $item->getMetadata(), $item->getCount()); $recipeItems[$item->getID()] = array($item->getID(), $item->getDamage(), $item->getCount());
}else{ }else{
if($item->getMetadata() !== $recipeItems[$item->getID()][1]){ if($item->getDamage() !== $recipeItems[$item->getID()][1]){
$recipeItems[$item->getID()][1] = false; $recipeItems[$item->getID()][1] = false;
} }
$recipeItems[$item->getID()][2] += $item->getCount(); $recipeItems[$item->getID()][2] += $item->getCount();
@ -2470,9 +2470,9 @@ class Player extends Human implements CommandSender, IPlayer{
foreach($craft as $slot => $item){ foreach($craft as $slot => $item){
$s = $this->getSlot($slot); $s = $this->getSlot($slot);
if($s->getCount() <= 0 or $s->getID() === Item::AIR){ if($s->getCount() <= 0 or $s->getID() === Item::AIR){
$this->setSlot($slot, Item::get($item->getID(), $item->getMetadata(), $item->getCount())); $this->setSlot($slot, Item::get($item->getID(), $item->getDamage(), $item->getCount()));
}else{ }else{
$this->setSlot($slot, Item::get($item->getID(), $item->getMetadata(), $s->getCount() + $item->getCount())); $this->setSlot($slot, Item::get($item->getID(), $item->getDamage(), $s->getCount() + $item->getCount()));
} }
switch($item->getID()){ switch($item->getID()){

View File

@ -44,7 +44,7 @@ class Beetroot extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true, false, true); $this->getLevel()->setBlock($this, $this, true, false, true);
$item->count--; $item->count--;

View File

@ -28,7 +28,9 @@ use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\level\Position; use pocketmine\level\Position;
use pocketmine\metadata\Metadatable; use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\plugin\Plugin;
abstract class Block extends Position implements Metadatable{ abstract class Block extends Position implements Metadatable{
const AIR = 0; const AIR = 0;
@ -563,7 +565,7 @@ abstract class Block extends Position implements Metadatable{
public static function get($id, $meta = 0, Position $pos = null){ public static function get($id, $meta = 0, Position $pos = null){
if(isset(self::$list[$id])){ if(isset(self::$list[$id])){
$block = clone self::$list[$id]; $block = clone self::$list[$id];
$block->setMetadata($meta); $block->setDamage($meta);
}else{ }else{
$block = new Generic($id, $meta); $block = new Generic($id, $meta);
} }
@ -611,14 +613,14 @@ abstract class Block extends Position implements Metadatable{
/** /**
* @return int * @return int
*/ */
final public function getMetadata(){ final public function getDamage(){
return $this->meta; return $this->meta;
} }
/** /**
* @param int $meta * @param int $meta
*/ */
final public function setMetadata($meta){ final public function setDamage($meta){
$this->meta = $meta & 0x0F; $this->meta = $meta & 0x0F;
} }
@ -743,4 +745,22 @@ abstract class Block extends Position implements Metadatable{
* @return void * @return void
*/ */
abstract function onUpdate($type); abstract function onUpdate($type);
//TODO: Level block metadata
public function setMetadata($metadataKey, MetadataValue $metadataValue){
//$this->server->getPlayerMetadata()->setMetadata($this, $metadataKey, $metadataValue);
}
public function getMetadata($metadataKey){
return null;//return $this->server->getPlayerMetadata()->getMetadata($this, $metadataKey);
}
public function hasMetadata($metadataKey){
return false;//return $this->server->getPlayerMetadata()->hasMetadata($this, $metadataKey);
}
public function removeMetadata($metadataKey, Plugin $plugin){
//$this->server->getPlayerMetadata()->removeMetadata($this, $metadataKey, $plugin);
}
} }

View File

@ -121,7 +121,7 @@ class BurningFurnace extends Solid{
for($s = 0; $s < Furnace::SLOTS; ++$s){ for($s = 0; $s < Furnace::SLOTS; ++$s){
$slot = $t->getSlot($s); $slot = $t->getSlot($s);
if($slot->getID() > Item::AIR and $slot->getCount() > 0){ if($slot->getID() > Item::AIR and $slot->getCount() > 0){
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->getCount()); $drops[] = array($slot->getID(), $slot->getDamage(), $slot->getCount());
} }
} }
} }

View File

@ -44,7 +44,7 @@ class Carrot extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true, false, true); $this->getLevel()->setBlock($this, $this, true, false, true);
$item->count--; $item->count--;

View File

@ -59,7 +59,7 @@ class Chest extends Transparent{
continue; continue;
} }
$c = $this->getSide($side); $c = $this->getSide($side);
if(($c instanceof TileChest) and $c->getMetadata() === $this->meta){ if(($c instanceof TileChest) and $c->getDamage() === $this->meta){
if((($tile = $this->getLevel()->getTile($c)) instanceof TileChest) and !$tile->isPaired()){ if((($tile = $this->getLevel()->getTile($c)) instanceof TileChest) and !$tile->isPaired()){
$chest = $tile; $chest = $tile;
break; break;
@ -139,7 +139,7 @@ class Chest extends Transparent{
for($s = 0; $s < Chest::SLOTS; ++$s){ for($s = 0; $s < Chest::SLOTS; ++$s){
$slot = $t->getSlot($s); $slot = $t->getSlot($s);
if($slot->getID() > Item::AIR and $slot->getCount() > 0){ if($slot->getID() > Item::AIR and $slot->getCount() > 0){
$drops[] = array($slot->getID(), $slot->getMetadata(), $slot->getCount()); $drops[] = array($slot->getID(), $slot->getDamage(), $slot->getCount());
} }
} }
} }

View File

@ -99,7 +99,7 @@ abstract class Door extends Transparent{
if(($this->meta & 0x08) === 0x08){ //Top if(($this->meta & 0x08) === 0x08){ //Top
$down = $this->getSide(0); $down = $this->getSide(0);
if($down->getID() === $this->id){ if($down->getID() === $this->id){
$meta = $down->getMetadata() ^ 0x04; $meta = $down->getDamage() ^ 0x04;
$this->getLevel()->setBlock($down, Block::get($this->id, $meta), true, false, true); $this->getLevel()->setBlock($down, Block::get($this->id, $meta), true, false, true);
$players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4); $players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4);
if($player instanceof Player){ if($player instanceof Player){

View File

@ -40,7 +40,7 @@ class Grass extends Solid{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){
$item->count--; $item->count--;
TallGrass::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2); TallGrass::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2);

View File

@ -81,7 +81,7 @@ class MelonStem extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true, false, true); $this->getLevel()->setBlock($this, $this, true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){

View File

@ -44,7 +44,7 @@ class Potato extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true, false, true); $this->getLevel()->setBlock($this, $this, true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){

View File

@ -81,7 +81,7 @@ class PumpkinStem extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true, false, true); $this->getLevel()->setBlock($this, $this, true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){

View File

@ -59,7 +59,7 @@ class Sapling extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
Tree::growTree($this->getLevel(), $this, new Random(mt_rand()), $this->meta & 0x03); Tree::growTree($this->getLevel(), $this, new Random(mt_rand()), $this->meta & 0x03);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){
$item->count--; $item->count--;

View File

@ -49,11 +49,11 @@ class Slab extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$this->meta &= 0x07; $this->meta &= 0x07;
if($face === 0){ if($face === 0){
if($target->getID() === self::SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === self::SLAB and ($target->getDamage() & 0x08) === 0x08 and ($target->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
}elseif($block->getID() === self::SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ }elseif($block->getID() === self::SLAB and ($block->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
@ -61,18 +61,18 @@ class Slab extends Transparent{
$this->meta |= 0x08; $this->meta |= 0x08;
} }
}elseif($face === 1){ }elseif($face === 1){
if($target->getID() === self::SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === self::SLAB and ($target->getDamage() & 0x08) === 0 and ($target->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
}elseif($block->getID() === self::SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ }elseif($block->getID() === self::SLAB and ($block->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
} }
}elseif(!($player instanceof Player) or !$player->inBlock($block)){ }elseif(!($player instanceof Player) or !$player->inBlock($block)){
if($block->getID() === self::SLAB){ if($block->getID() === self::SLAB){
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ if(($block->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_SLAB, $this->meta), true, false, true);
return true; return true;
@ -87,7 +87,7 @@ class Slab extends Transparent{
}else{ }else{
return false; return false;
} }
if($block->getID() === self::SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){ if($block->getID() === self::SLAB and ($target->getDamage() & 0x07) !== ($this->meta & 0x07)){
return false; return false;
} }
$this->getLevel()->setBlock($block, $this, true, false, true); $this->getLevel()->setBlock($block, $this, true, false, true);

View File

@ -39,7 +39,7 @@ class Sugarcane extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
if($this->getSide(0)->getID() !== self::SUGARCANE_BLOCK){ if($this->getSide(0)->getID() !== self::SUGARCANE_BLOCK){
for($y = 1; $y < 3; ++$y){ for($y = 1; $y < 3; ++$y){
$b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z));

View File

@ -33,7 +33,7 @@ class Torch extends Flowable{
public function onUpdate($type){ public function onUpdate($type){
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
$side = $this->getMetadata(); $side = $this->getDamage();
$faces = array( $faces = array(
1 => 4, 1 => 4,
2 => 5, 2 => 5,

View File

@ -44,7 +44,7 @@ class Wheat extends Flowable{
} }
public function onActivate(Item $item, Player $player = null){ public function onActivate(Item $item, Player $player = null){
if($item->getID() === Item::DYE and $item->getMetadata() === 0x0F){ //Bonemeal if($item->getID() === Item::DYE and $item->getDamage() === 0x0F){ //Bonemeal
$this->meta = 0x07; $this->meta = 0x07;
$this->getLevel()->setBlock($this, $this, true, false, true); $this->getLevel()->setBlock($this, $this, true, false, true);
if(($player->gamemode & 0x01) === 0){ if(($player->gamemode & 0x01) === 0){

View File

@ -45,11 +45,11 @@ class WoodSlab extends Transparent{
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
$this->meta &= 0x07; $this->meta &= 0x07;
if($face === 0){ if($face === 0){
if($target->getID() === self::WOOD_SLAB and ($target->getMetadata() & 0x08) === 0x08 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === self::WOOD_SLAB and ($target->getDamage() & 0x08) === 0x08 and ($target->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
}elseif($block->getID() === self::WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ }elseif($block->getID() === self::WOOD_SLAB and ($block->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
@ -57,18 +57,18 @@ class WoodSlab extends Transparent{
$this->meta |= 0x08; $this->meta |= 0x08;
} }
}elseif($face === 1){ }elseif($face === 1){
if($target->getID() === self::WOOD_SLAB and ($target->getMetadata() & 0x08) === 0 and ($target->getMetadata() & 0x07) === ($this->meta & 0x07)){ if($target->getID() === self::WOOD_SLAB and ($target->getDamage() & 0x08) === 0 and ($target->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($target, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
}elseif($block->getID() === self::WOOD_SLAB and ($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ }elseif($block->getID() === self::WOOD_SLAB and ($block->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
} }
}elseif(!($player instanceof Player) or !$player->inBlock($block)){ }elseif(!($player instanceof Player) or !$player->inBlock($block)){
if($block->getID() === self::WOOD_SLAB){ if($block->getID() === self::WOOD_SLAB){
if(($block->getMetadata() & 0x07) === ($this->meta & 0x07)){ if(($block->getDamage() & 0x07) === ($this->meta & 0x07)){
$this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true); $this->getLevel()->setBlock($block, Block::get(Item::DOUBLE_WOOD_SLAB, $this->meta), true, false, true);
return true; return true;
@ -83,7 +83,7 @@ class WoodSlab extends Transparent{
}else{ }else{
return false; return false;
} }
if($block->getID() === self::WOOD_SLAB and ($target->getMetadata() & 0x07) !== ($this->meta & 0x07)){ if($block->getID() === self::WOOD_SLAB and ($target->getDamage() & 0x07) !== ($this->meta & 0x07)){
return false; return false;
} }
$this->getLevel()->setBlock($block, $this, true, false, true); $this->getLevel()->setBlock($block, $this, true, false, true);

View File

@ -77,7 +77,7 @@ class GiveCommand extends VanillaCommand{
return true; return true;
} }
Command::broadcastCommandMessage($sender, "Gave " . $player->getName() . " " . $item->getCount() . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getMetadata() . ")"); Command::broadcastCommandMessage($sender, "Gave " . $player->getName() . " " . $item->getCount() . " of " . $item->getName() . " (" . $item->getID() . ":" . $item->getDamage() . ")");
return true; return true;
} }

View File

@ -84,7 +84,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
if($item->getID() !== 0 and $item->getCount() > 0){ if($item->getID() !== 0 and $item->getCount() > 0){
$this->namedtag->Inventory[$slot] = new Compound(false, array( $this->namedtag->Inventory[$slot] = new Compound(false, array(
new Byte("Count", $item->getCount()), new Byte("Count", $item->getCount()),
new Short("Damage", $item->getMetadata()), new Short("Damage", $item->getDamage()),
new Byte("Slot", $slot), new Byte("Slot", $slot),
new Byte("TrueSlot", $this->hotbar[$slot]), new Byte("TrueSlot", $this->hotbar[$slot]),
new Short("id", $item->getID()), new Short("id", $item->getID()),
@ -108,7 +108,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
$item = $this->getSlot($slot - 9); $item = $this->getSlot($slot - 9);
$this->namedtag->Inventory[$slot] = new Compound(false, array( $this->namedtag->Inventory[$slot] = new Compound(false, array(
new Byte("Count", $item->getCount()), new Byte("Count", $item->getCount()),
new Short("Damage", $item->getMetadata()), new Short("Damage", $item->getDamage()),
new Byte("Slot", $slot), new Byte("Slot", $slot),
new Short("id", $item->getID()), new Short("id", $item->getID()),
)); ));
@ -120,7 +120,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
if($item instanceof Item){ if($item instanceof Item){
$this->namedtag->Inventory[$slot] = new Compound(false, array( $this->namedtag->Inventory[$slot] = new Compound(false, array(
new Byte("Count", $item->getCount()), new Byte("Count", $item->getCount()),
new Short("Damage", $item->getMetadata()), new Short("Damage", $item->getDamage()),
new Byte("Slot", $slot), new Byte("Slot", $slot),
new Short("id", $item->getID()), new Short("id", $item->getID()),
)); ));
@ -209,7 +209,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{
$pk = new PlayerEquipmentPacket; $pk = new PlayerEquipmentPacket;
$pk->eid = $this->id; $pk->eid = $this->id;
$pk->item = $this->getSlot($this->slot)->getID(); $pk->item = $this->getSlot($this->slot)->getID();
$pk->meta = $this->getSlot($this->slot)->getMetadata(); $pk->meta = $this->getSlot($this->slot)->getDamage();
$pk->slot = 0; $pk->slot = 0;
$player->dataPacket($pk); $player->dataPacket($pk);
} }

View File

@ -29,12 +29,12 @@ use pocketmine\block\Block as BlockBlock;
class Block extends Item{ class Block extends Item{
public function __construct(BlockBlock $block, $meta = 0, $count = 1){ public function __construct(BlockBlock $block, $meta = 0, $count = 1){
$this->block = clone $block; $this->block = clone $block;
parent::__construct($block->getID(), $block->getMetadata(), $count, $block->getName()); parent::__construct($block->getID(), $block->getDamage(), $count, $block->getName());
} }
public function setMetadata($meta){ public function setDamage($meta){
$this->meta = $meta & 0x0F; $this->meta = $meta & 0x0F;
$this->block->setMetadata($this->meta); $this->block->setDamage($this->meta);
} }
public function getBlock(){ public function getBlock(){

View File

@ -48,7 +48,7 @@ class Bucket extends Item{
} }
}elseif($this->meta === Item::WATER){ }elseif($this->meta === Item::WATER){
//Support Make Non-Support Water to Support Water //Support Make Non-Support Water to Support Water
if($block->getID() === self::AIR || ($block instanceof Water && ($block->getMetadata() & 0x07) != 0x00)){ if($block->getID() === self::AIR || ($block instanceof Water && ($block->getDamage() & 0x07) != 0x00)){
$water = new Water(); $water = new Water();
$level->setBlock($block, $water, true, false, true); $level->setBlock($block, $water, true, false, true);
$water->place(clone $this, $block, $target, $face, $fx, $fy, $fz, $player); $water->place(clone $this, $block, $target, $face, $fx, $fy, $fz, $player);

View File

@ -34,7 +34,7 @@ class FlintSteel extends Tool{
} }
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){ public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
if(($player->gamemode & 0x01) === 0 and $this->useOn($block) and $this->getMetadata() >= $this->getMaxDurability()){ if(($player->gamemode & 0x01) === 0 and $this->useOn($block) and $this->getDamage() >= $this->getMaxDurability()){
$player->setSlot($player->getCurrentEquipment(), new Item(Item::AIR, 0, 0)); $player->setSlot($player->getCurrentEquipment(), new Item(Item::AIR, 0, 0));
} }

View File

@ -436,7 +436,7 @@ class Item{
public static function get($id, $meta = 0, $count = 1){ public static function get($id, $meta = 0, $count = 1){
if(isset(self::$list[$id])){ if(isset(self::$list[$id])){
$item = clone self::$list[$id]; $item = clone self::$list[$id];
$item->setMetadata($meta); $item->setDamage($meta);
$item->setCount($count); $item->setCount($count);
}else{ }else{
$item = new Item($id, $meta, $count); $item = new Item($id, $meta, $count);
@ -517,11 +517,11 @@ class Item{
return $this->id; return $this->id;
} }
final public function getMetadata(){ final public function getDamage(){
return $this->meta; return $this->meta;
} }
public function setMetadata($meta){ public function setDamage($meta){
$this->meta = $meta & 0xFFFF; $this->meta = $meta & 0xFFFF;
} }
@ -617,7 +617,7 @@ class Item{
} }
public final function equals(Item $item, $checkDamage = false){ public final function equals(Item $item, $checkDamage = false){
return $this->id === $item->getID() and ($checkDamage === false or $this->getMetadata() === $item->getMetadata()); return $this->id === $item->getID() and ($checkDamage === false or $this->getDamage() === $item->getDamage());
} }
} }

View File

@ -83,7 +83,7 @@ class Painting extends Item{
//$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data); //$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data);
//$e->spawnToAll(); //$e->spawnToAll();
if(($player->gamemode & 0x01) === 0x00){ if(($player->gamemode & 0x01) === 0x00){
$player->removeItem(Item::get($this->getID(), $this->getMetadata(), 1)); $player->removeItem(Item::get($this->getID(), $this->getDamage(), 1));
} }
return true; return true;

View File

@ -303,7 +303,7 @@ class Level{
$pk->y = $b->y; $pk->y = $b->y;
$pk->z = $b->z; $pk->z = $b->z;
$pk->block = $b->getID(); $pk->block = $b->getID();
$pk->meta = $b->getMetadata(); $pk->meta = $b->getDamage();
Player::broadcastPacket($this->players, $pk); Player::broadcastPacket($this->players, $pk);
} }
} }
@ -512,14 +512,14 @@ class Level{
* @return bool * @return bool
*/ */
public function setBlockRaw(Vector3 $pos, Block $block, $direct = true, $send = true){ public function setBlockRaw(Vector3 $pos, Block $block, $direct = true, $send = true){
if(($ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata())) === true and $send !== false){ if(($ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getDamage())) === true and $send !== false){
if($direct === true){ if($direct === true){
$pk = new UpdateBlockPacket; $pk = new UpdateBlockPacket;
$pk->x = $pos->x; $pk->x = $pos->x;
$pk->y = $pos->y; $pk->y = $pos->y;
$pk->z = $pos->z; $pk->z = $pos->z;
$pk->block = $block->getID(); $pk->block = $block->getID();
$pk->meta = $block->getMetadata(); $pk->meta = $block->getDamage();
Player::broadcastPacket($this->players, $pk); Player::broadcastPacket($this->players, $pk);
}elseif($direct === false){ }elseif($direct === false){
if(!($pos instanceof Position)){ if(!($pos instanceof Position)){
@ -560,7 +560,7 @@ class Level{
return false; return false;
} }
$ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getMetadata()); $ret = $this->level->setBlock($pos->x, $pos->y, $pos->z, $block->getID(), $block->getDamage());
if($ret === true){ if($ret === true){
if(!($pos instanceof Position)){ if(!($pos instanceof Position)){
$pos = new Position($pos->x, $pos->y, $pos->z, $this); $pos = new Position($pos->x, $pos->y, $pos->z, $this);
@ -573,7 +573,7 @@ class Level{
$pk->y = $pos->y; $pk->y = $pos->y;
$pk->z = $pos->z; $pk->z = $pos->z;
$pk->block = $block->getID(); $pk->block = $block->getID();
$pk->meta = $block->getMetadata(); $pk->meta = $block->getDamage();
Player::broadcastPacket($this->players, $pk); Player::broadcastPacket($this->players, $pk);
}else{ }else{
$index = LevelFormat::getIndex($pos->x >> 4, $pos->z >> 4); $index = LevelFormat::getIndex($pos->x >> 4, $pos->z >> 4);
@ -653,7 +653,7 @@ class Level{
$target->onBreak($item); $target->onBreak($item);
if($item instanceof Item){ if($item instanceof Item){
$item->useOn($target); $item->useOn($target);
if($item->isTool() and $item->getMetadata() >= $item->getMaxDurability()){ if($item->isTool() and $item->getDamage() >= $item->getMaxDurability()){
$item = Item::get(Item::AIR, 0, 0); $item = Item::get(Item::AIR, 0, 0);
} }
} }

View File

@ -111,7 +111,7 @@ class Flat extends Generator{
$metas = ""; $metas = "";
for($y = $startY; $y < $endY; ++$y){ for($y = $startY; $y < $endY; ++$y){
$blocks .= chr($this->structure[$y]->getID()); $blocks .= chr($this->structure[$y]->getID());
$metas .= substr(dechex($this->structure[$y]->getMetadata()), -1); $metas .= substr(dechex($this->structure[$y]->getDamage()), -1);
} }
$this->chunks[$Y] .= $blocks . hex2bin($metas) . "\x00\x00\x00\x00\x00\x00\x00\x00"; $this->chunks[$Y] .= $blocks . hex2bin($metas) . "\x00\x00\x00\x00\x00\x00\x00\x00";
} }

View File

@ -166,7 +166,7 @@ abstract class DataPacket extends \stdClass{
protected function putSlot(Item $item){ protected function putSlot(Item $item){
$this->putShort($item->getID()); $this->putShort($item->getID());
$this->putByte($item->getCount()); $this->putByte($item->getCount());
$this->putShort($item->getMetadata()); $this->putShort($item->getDamage());
} }
protected function getString(){ protected function getString(){

View File

@ -173,7 +173,7 @@ trait Container{
new Byte("Count", $item->getCount()), new Byte("Count", $item->getCount()),
new Byte("Slot", $s), new Byte("Slot", $s),
new Short("id", $item->getID()), new Short("id", $item->getID()),
new Short("Damage", $item->getMetadata()), new Short("Damage", $item->getDamage()),
)); ));
if($item->getID() === Item::AIR or $item->getCount() <= 0){ if($item->getID() === Item::AIR or $item->getCount() <= 0){

View File

@ -60,7 +60,7 @@ class Furnace extends Tile{
$raw = $this->getSlot(0); $raw = $this->getSlot(0);
$product = $this->getSlot(2); $product = $this->getSlot(2);
$smelt = $raw->getSmeltItem(); $smelt = $raw->getSmeltItem();
$canSmelt = ($smelt !== false and $raw->getCount() > 0 and (($product->getID() === $smelt->getID() and $product->getMetadata() === $smelt->getMetadata() and $product->getCount() < $product->getMaxStackSize()) or $product->getID() === Item::AIR)); $canSmelt = ($smelt !== false and $raw->getCount() > 0 and (($product->getID() === $smelt->getID() and $product->getDamage() === $smelt->getDamage() and $product->getCount() < $product->getMaxStackSize()) or $product->getID() === Item::AIR));
if($this->namedtag->BurnTime <= 0 and $canSmelt and $fuel->getFuelTime() !== false and $fuel->getCount() > 0){ if($this->namedtag->BurnTime <= 0 and $canSmelt and $fuel->getFuelTime() !== false and $fuel->getCount() > 0){
$this->lastUpdate = microtime(true); $this->lastUpdate = microtime(true);
$this->namedtag->MaxTime = $this->namedtag->BurnTime = floor($fuel->getFuelTime() * 20); $this->namedtag->MaxTime = $this->namedtag->BurnTime = floor($fuel->getFuelTime() * 20);
@ -72,7 +72,7 @@ class Furnace extends Tile{
$this->setSlot(1, $fuel, false); $this->setSlot(1, $fuel, false);
$current = $this->getLevel()->getBlock($this); $current = $this->getLevel()->getBlock($this);
if($current->getID() === Item::FURNACE){ if($current->getID() === Item::FURNACE){
$this->getLevel()->setBlock($this, Block::get(Item::BURNING_FURNACE, $current->getMetadata()), true, false, true); $this->getLevel()->setBlock($this, Block::get(Item::BURNING_FURNACE, $current->getDamage()), true, false, true);
} }
} }
if($this->namedtag->BurnTime > 0){ if($this->namedtag->BurnTime > 0){
@ -82,7 +82,7 @@ class Furnace extends Tile{
if($smelt !== false and $canSmelt){ if($smelt !== false and $canSmelt){
$this->namedtag->CookTime += $ticks; $this->namedtag->CookTime += $ticks;
if($this->namedtag->CookTime >= 200){ //10 seconds if($this->namedtag->CookTime >= 200){ //10 seconds
$product = Item::get($smelt->getID(), $smelt->getMetadata(), $product->getCount() + 1); $product = Item::get($smelt->getID(), $smelt->getDamage(), $product->getCount() + 1);
$this->setSlot(2, $product, false); $this->setSlot(2, $product, false);
$raw->setCount($raw->getCount() - 1); $raw->setCount($raw->getCount() - 1);
if($raw->getCount() === 0){ if($raw->getCount() === 0){
@ -102,7 +102,7 @@ class Furnace extends Tile{
}else{ }else{
$current = $this->getLevel()->getBlock($this); $current = $this->getLevel()->getBlock($this);
if($current->getID() === Item::BURNING_FURNACE){ if($current->getID() === Item::BURNING_FURNACE){
$this->getLevel()->setBlock($this, Block::get(Item::FURNACE, $current->getMetadata()), true, false, true); $this->getLevel()->setBlock($this, Block::get(Item::FURNACE, $current->getDamage()), true, false, true);
} }
$this->namedtag->CookTime = 0; $this->namedtag->CookTime = 0;
$this->namedtag->BurnTime = 0; $this->namedtag->BurnTime = 0;