diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index 74d58ce26..e0000a086 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -900,7 +900,7 @@ class Player extends Human implements CommandSender, IPlayer{ if($data->getLevel() === $this->getLevel()){ $pk = new SetEntityDataPacket; $pk->eid = $eid; - $pk->metadata = $data->getMetadata(); + $pk->metadata = $data->getDamage(); $this->dataPacket($pk); } break; @@ -1547,7 +1547,7 @@ class Player extends Human implements CommandSender, IPlayer{ $pk->y = $target->y; $pk->z = $target->z; $pk->block = $target->getID(); - $pk->meta = $target->getMetadata(); + $pk->meta = $target->getDamage(); $this->dataPacket($pk); $pk = new UpdateBlockPacket; @@ -1555,7 +1555,7 @@ class Player extends Human implements CommandSender, IPlayer{ $pk->y = $block->y; $pk->z = $block->z; $pk->block = $block->getID(); - $pk->meta = $block->getMetadata(); + $pk->meta = $block->getDamage(); $this->dataPacket($pk); 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){ 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()); }else{ $item = clone $this->getSlot($this->getCurrentEquipment()); @@ -1595,7 +1595,7 @@ class Player extends Human implements CommandSender, IPlayer{ $pk->y = $target->y; $pk->z = $target->z; $pk->block = $target->getID(); - $pk->meta = $target->getMetadata(); + $pk->meta = $target->getDamage(); $this->dataPacket($pk); $pk = new UpdateBlockPacket; @@ -1603,7 +1603,7 @@ class Player extends Human implements CommandSender, IPlayer{ $pk->y = $block->y; $pk->z = $block->z; $pk->block = $block->getID(); - $pk->meta = $block->getMetadata(); + $pk->meta = $block->getDamage(); $this->dataPacket($pk); break; }elseif($packet->face === 0xff){ @@ -1718,7 +1718,7 @@ class Player extends Human implements CommandSender, IPlayer{ $pk->y = $target->y; $pk->z = $target->z; $pk->block = $target->getID(); - $pk->meta = $target->getMetadata(); + $pk->meta = $target->getDamage(); $this->directDataPacket($pk); break; case ProtocolInfo::PLAYER_ARMOR_EQUIPMENT_PACKET: @@ -1751,7 +1751,7 @@ class Player extends Human implements CommandSender, IPlayer{ }else{ $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){ $this->sendArmor(); $this->sendInventory(); @@ -1850,7 +1850,7 @@ class Player extends Human implements CommandSender, IPlayer{ } $target->harm($damage, $this->id); 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)); } } @@ -2034,23 +2034,23 @@ class Player extends Human implements CommandSender, IPlayer{ if($packet->windowid === 0){ $craft = false; $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 - $use = Item::get($slot->getID(), $slot->getMetadata(), $slot->getCount() - $packet->item->getCount()); + 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->getDamage(), $slot->getCount() - $packet->item->getCount()); $this->craftingItems[$packet->slot] = $use; $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 - $craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount() - $slot->getCount()); + }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->getDamage(), $packet->item->getCount() - $slot->getCount()); if(count($this->toCraft) === 0){ $this->toCraft[-1] = 0; } $this->toCraft[$packet->slot] = $craftItem; $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 - $craftItem = Item::get($packet->item->getID(), $packet->item->getMetadata(), $packet->item->getCount()); + }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->getDamage(), $packet->item->getCount()); if(count($this->toCraft) === 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->toCraft[$packet->slot] = $craftItem; $craft = true; @@ -2091,7 +2091,7 @@ class Player extends Human implements CommandSender, IPlayer{ 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); //TODO: container access events? @@ -2146,7 +2146,7 @@ class Player extends Human implements CommandSender, IPlayer{ ){ 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); //TODO: container access events? @@ -2422,10 +2422,10 @@ class Player extends Human implements CommandSender, IPlayer{ foreach($craft as $item){ if($item instanceof Item){ $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; }else{ - $craftItem[1] = $item->getMetadata(); + $craftItem[1] = $item->getDamage(); } $craftItem[2] += $item->getCount(); } @@ -2435,9 +2435,9 @@ class Player extends Human implements CommandSender, IPlayer{ $recipeItems = array(); foreach($recipe as $item){ 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{ - if($item->getMetadata() !== $recipeItems[$item->getID()][1]){ + if($item->getDamage() !== $recipeItems[$item->getID()][1]){ $recipeItems[$item->getID()][1] = false; } $recipeItems[$item->getID()][2] += $item->getCount(); @@ -2470,9 +2470,9 @@ class Player extends Human implements CommandSender, IPlayer{ foreach($craft as $slot => $item){ $s = $this->getSlot($slot); 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{ - $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()){ diff --git a/src/pocketmine/block/Beetroot.php b/src/pocketmine/block/Beetroot.php index 7691b0a64..38e0d714b 100644 --- a/src/pocketmine/block/Beetroot.php +++ b/src/pocketmine/block/Beetroot.php @@ -44,7 +44,7 @@ class Beetroot extends Flowable{ } 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->getLevel()->setBlock($this, $this, true, false, true); $item->count--; diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 6d32f625a..832d30bc2 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -28,7 +28,9 @@ use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\level\Position; use pocketmine\metadata\Metadatable; +use pocketmine\metadata\MetadataValue; use pocketmine\Player; +use pocketmine\plugin\Plugin; abstract class Block extends Position implements Metadatable{ const AIR = 0; @@ -563,7 +565,7 @@ abstract class Block extends Position implements Metadatable{ public static function get($id, $meta = 0, Position $pos = null){ if(isset(self::$list[$id])){ $block = clone self::$list[$id]; - $block->setMetadata($meta); + $block->setDamage($meta); }else{ $block = new Generic($id, $meta); } @@ -611,14 +613,14 @@ abstract class Block extends Position implements Metadatable{ /** * @return int */ - final public function getMetadata(){ + final public function getDamage(){ return $this->meta; } /** * @param int $meta */ - final public function setMetadata($meta){ + final public function setDamage($meta){ $this->meta = $meta & 0x0F; } @@ -743,4 +745,22 @@ abstract class Block extends Position implements Metadatable{ * @return void */ 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); + } } diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 59cce6021..544a3666c 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -121,7 +121,7 @@ class BurningFurnace extends Solid{ for($s = 0; $s < Furnace::SLOTS; ++$s){ $slot = $t->getSlot($s); 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()); } } } diff --git a/src/pocketmine/block/Carrot.php b/src/pocketmine/block/Carrot.php index afaebb303..5717a44f6 100644 --- a/src/pocketmine/block/Carrot.php +++ b/src/pocketmine/block/Carrot.php @@ -44,7 +44,7 @@ class Carrot extends Flowable{ } 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->getLevel()->setBlock($this, $this, true, false, true); $item->count--; diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index 5ec327c9e..0ea0bbe05 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -59,7 +59,7 @@ class Chest extends Transparent{ continue; } $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()){ $chest = $tile; break; @@ -139,7 +139,7 @@ class Chest extends Transparent{ for($s = 0; $s < Chest::SLOTS; ++$s){ $slot = $t->getSlot($s); 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()); } } } diff --git a/src/pocketmine/block/Door.php b/src/pocketmine/block/Door.php index d64320809..81df674fc 100644 --- a/src/pocketmine/block/Door.php +++ b/src/pocketmine/block/Door.php @@ -99,7 +99,7 @@ abstract class Door extends Transparent{ if(($this->meta & 0x08) === 0x08){ //Top $down = $this->getSide(0); 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); $players = $this->getLevel()->getUsingChunk($this->x >> 4, $this->z >> 4); if($player instanceof Player){ diff --git a/src/pocketmine/block/Grass.php b/src/pocketmine/block/Grass.php index 54ef044d0..13674cd6b 100644 --- a/src/pocketmine/block/Grass.php +++ b/src/pocketmine/block/Grass.php @@ -40,7 +40,7 @@ class Grass extends Solid{ } 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--; TallGrass::growGrass($this->getLevel(), $this, new Random(mt_rand()), 8, 2); diff --git a/src/pocketmine/block/MelonStem.php b/src/pocketmine/block/MelonStem.php index 1d3b418ae..e35c0c5e6 100644 --- a/src/pocketmine/block/MelonStem.php +++ b/src/pocketmine/block/MelonStem.php @@ -81,7 +81,7 @@ class MelonStem extends Flowable{ } 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->getLevel()->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ diff --git a/src/pocketmine/block/Potato.php b/src/pocketmine/block/Potato.php index 5a8fc24eb..39b23ebd9 100644 --- a/src/pocketmine/block/Potato.php +++ b/src/pocketmine/block/Potato.php @@ -44,7 +44,7 @@ class Potato extends Flowable{ } 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->getLevel()->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ diff --git a/src/pocketmine/block/PumpkinStem.php b/src/pocketmine/block/PumpkinStem.php index c90f8e699..ee7129a4b 100644 --- a/src/pocketmine/block/PumpkinStem.php +++ b/src/pocketmine/block/PumpkinStem.php @@ -81,7 +81,7 @@ class PumpkinStem extends Flowable{ } 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->getLevel()->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ diff --git a/src/pocketmine/block/Sapling.php b/src/pocketmine/block/Sapling.php index 4870b8cef..6748ccce1 100644 --- a/src/pocketmine/block/Sapling.php +++ b/src/pocketmine/block/Sapling.php @@ -59,7 +59,7 @@ class Sapling extends Flowable{ } 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); if(($player->gamemode & 0x01) === 0){ $item->count--; diff --git a/src/pocketmine/block/Slab.php b/src/pocketmine/block/Slab.php index 336d65967..cb47b812a 100644 --- a/src/pocketmine/block/Slab.php +++ b/src/pocketmine/block/Slab.php @@ -49,11 +49,11 @@ class Slab extends Transparent{ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $this->meta &= 0x07; 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); 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); return true; @@ -61,18 +61,18 @@ class Slab extends Transparent{ $this->meta |= 0x08; } }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); 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); return true; } }elseif(!($player instanceof Player) or !$player->inBlock($block)){ 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); return true; @@ -87,7 +87,7 @@ class Slab extends Transparent{ }else{ 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; } $this->getLevel()->setBlock($block, $this, true, false, true); diff --git a/src/pocketmine/block/Sugarcane.php b/src/pocketmine/block/Sugarcane.php index a65db473b..20a8cf48f 100644 --- a/src/pocketmine/block/Sugarcane.php +++ b/src/pocketmine/block/Sugarcane.php @@ -39,7 +39,7 @@ class Sugarcane extends Flowable{ } 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){ for($y = 1; $y < 3; ++$y){ $b = $this->getLevel()->getBlock(new Vector3($this->x, $this->y + $y, $this->z)); diff --git a/src/pocketmine/block/Torch.php b/src/pocketmine/block/Torch.php index 93a0e375f..72dc8f6e2 100644 --- a/src/pocketmine/block/Torch.php +++ b/src/pocketmine/block/Torch.php @@ -33,7 +33,7 @@ class Torch extends Flowable{ public function onUpdate($type){ if($type === Level::BLOCK_UPDATE_NORMAL){ - $side = $this->getMetadata(); + $side = $this->getDamage(); $faces = array( 1 => 4, 2 => 5, diff --git a/src/pocketmine/block/Wheat.php b/src/pocketmine/block/Wheat.php index d9b34a387..ec20134e8 100644 --- a/src/pocketmine/block/Wheat.php +++ b/src/pocketmine/block/Wheat.php @@ -44,7 +44,7 @@ class Wheat extends Flowable{ } 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->getLevel()->setBlock($this, $this, true, false, true); if(($player->gamemode & 0x01) === 0){ diff --git a/src/pocketmine/block/WoodSlab.php b/src/pocketmine/block/WoodSlab.php index d9b846ace..ed39a624b 100644 --- a/src/pocketmine/block/WoodSlab.php +++ b/src/pocketmine/block/WoodSlab.php @@ -45,11 +45,11 @@ class WoodSlab extends Transparent{ public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){ $this->meta &= 0x07; 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); 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); return true; @@ -57,18 +57,18 @@ class WoodSlab extends Transparent{ $this->meta |= 0x08; } }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); 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); return true; } }elseif(!($player instanceof Player) or !$player->inBlock($block)){ 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); return true; @@ -83,7 +83,7 @@ class WoodSlab extends Transparent{ }else{ 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; } $this->getLevel()->setBlock($block, $this, true, false, true); diff --git a/src/pocketmine/command/defaults/GiveCommand.php b/src/pocketmine/command/defaults/GiveCommand.php index 6cdc8e215..bd9003b14 100644 --- a/src/pocketmine/command/defaults/GiveCommand.php +++ b/src/pocketmine/command/defaults/GiveCommand.php @@ -77,7 +77,7 @@ class GiveCommand extends VanillaCommand{ 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; } diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 6930bb416..2447d80d6 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -84,7 +84,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ if($item->getID() !== 0 and $item->getCount() > 0){ $this->namedtag->Inventory[$slot] = new Compound(false, array( new Byte("Count", $item->getCount()), - new Short("Damage", $item->getMetadata()), + new Short("Damage", $item->getDamage()), new Byte("Slot", $slot), new Byte("TrueSlot", $this->hotbar[$slot]), new Short("id", $item->getID()), @@ -108,7 +108,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ $item = $this->getSlot($slot - 9); $this->namedtag->Inventory[$slot] = new Compound(false, array( new Byte("Count", $item->getCount()), - new Short("Damage", $item->getMetadata()), + new Short("Damage", $item->getDamage()), new Byte("Slot", $slot), new Short("id", $item->getID()), )); @@ -120,7 +120,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ if($item instanceof Item){ $this->namedtag->Inventory[$slot] = new Compound(false, array( new Byte("Count", $item->getCount()), - new Short("Damage", $item->getMetadata()), + new Short("Damage", $item->getDamage()), new Byte("Slot", $slot), new Short("id", $item->getID()), )); @@ -209,7 +209,7 @@ class Human extends Creature implements ProjectileSource, InventorySource{ $pk = new PlayerEquipmentPacket; $pk->eid = $this->id; $pk->item = $this->getSlot($this->slot)->getID(); - $pk->meta = $this->getSlot($this->slot)->getMetadata(); + $pk->meta = $this->getSlot($this->slot)->getDamage(); $pk->slot = 0; $player->dataPacket($pk); } diff --git a/src/pocketmine/item/Block.php b/src/pocketmine/item/Block.php index 936121f44..80e7378b7 100644 --- a/src/pocketmine/item/Block.php +++ b/src/pocketmine/item/Block.php @@ -29,12 +29,12 @@ use pocketmine\block\Block as BlockBlock; class Block extends Item{ public function __construct(BlockBlock $block, $meta = 0, $count = 1){ $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->block->setMetadata($this->meta); + $this->block->setDamage($this->meta); } public function getBlock(){ diff --git a/src/pocketmine/item/Bucket.php b/src/pocketmine/item/Bucket.php index 19d5a5fe7..ab975c854 100644 --- a/src/pocketmine/item/Bucket.php +++ b/src/pocketmine/item/Bucket.php @@ -48,7 +48,7 @@ class Bucket extends Item{ } }elseif($this->meta === Item::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(); $level->setBlock($block, $water, true, false, true); $water->place(clone $this, $block, $target, $face, $fx, $fy, $fz, $player); diff --git a/src/pocketmine/item/FlintSteel.php b/src/pocketmine/item/FlintSteel.php index e69df1013..d57305642 100644 --- a/src/pocketmine/item/FlintSteel.php +++ b/src/pocketmine/item/FlintSteel.php @@ -34,7 +34,7 @@ class FlintSteel extends Tool{ } 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)); } diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index cb5f228f9..363cd59ec 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -436,7 +436,7 @@ class Item{ public static function get($id, $meta = 0, $count = 1){ if(isset(self::$list[$id])){ $item = clone self::$list[$id]; - $item->setMetadata($meta); + $item->setDamage($meta); $item->setCount($count); }else{ $item = new Item($id, $meta, $count); @@ -517,11 +517,11 @@ class Item{ return $this->id; } - final public function getMetadata(){ + final public function getDamage(){ return $this->meta; } - public function setMetadata($meta){ + public function setDamage($meta){ $this->meta = $meta & 0xFFFF; } @@ -617,7 +617,7 @@ class Item{ } 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()); } } diff --git a/src/pocketmine/item/Painting.php b/src/pocketmine/item/Painting.php index d7cd4b961..5eef86e52 100644 --- a/src/pocketmine/item/Painting.php +++ b/src/pocketmine/item/Painting.php @@ -83,7 +83,7 @@ class Painting extends Item{ //$e = $server->api->entity->add($level, ENTITY_OBJECT, OBJECT_PAINTING, $data); //$e->spawnToAll(); 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; diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 42a412080..78f856db7 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -303,7 +303,7 @@ class Level{ $pk->y = $b->y; $pk->z = $b->z; $pk->block = $b->getID(); - $pk->meta = $b->getMetadata(); + $pk->meta = $b->getDamage(); Player::broadcastPacket($this->players, $pk); } } @@ -512,14 +512,14 @@ class Level{ * @return bool */ 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){ $pk = new UpdateBlockPacket; $pk->x = $pos->x; $pk->y = $pos->y; $pk->z = $pos->z; $pk->block = $block->getID(); - $pk->meta = $block->getMetadata(); + $pk->meta = $block->getDamage(); Player::broadcastPacket($this->players, $pk); }elseif($direct === false){ if(!($pos instanceof Position)){ @@ -560,7 +560,7 @@ class Level{ 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(!($pos instanceof Position)){ $pos = new Position($pos->x, $pos->y, $pos->z, $this); @@ -573,7 +573,7 @@ class Level{ $pk->y = $pos->y; $pk->z = $pos->z; $pk->block = $block->getID(); - $pk->meta = $block->getMetadata(); + $pk->meta = $block->getDamage(); Player::broadcastPacket($this->players, $pk); }else{ $index = LevelFormat::getIndex($pos->x >> 4, $pos->z >> 4); @@ -653,7 +653,7 @@ class Level{ $target->onBreak($item); if($item instanceof Item){ $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); } } diff --git a/src/pocketmine/level/generator/Flat.php b/src/pocketmine/level/generator/Flat.php index 6523b6581..4c36e4250 100644 --- a/src/pocketmine/level/generator/Flat.php +++ b/src/pocketmine/level/generator/Flat.php @@ -111,7 +111,7 @@ class Flat extends Generator{ $metas = ""; for($y = $startY; $y < $endY; ++$y){ $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"; } diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index ac820ca04..b41b57eef 100644 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -166,7 +166,7 @@ abstract class DataPacket extends \stdClass{ protected function putSlot(Item $item){ $this->putShort($item->getID()); $this->putByte($item->getCount()); - $this->putShort($item->getMetadata()); + $this->putShort($item->getDamage()); } protected function getString(){ diff --git a/src/pocketmine/tile/Container.php b/src/pocketmine/tile/Container.php index 0756710c6..589fbe5b5 100644 --- a/src/pocketmine/tile/Container.php +++ b/src/pocketmine/tile/Container.php @@ -173,7 +173,7 @@ trait Container{ new Byte("Count", $item->getCount()), new Byte("Slot", $s), new Short("id", $item->getID()), - new Short("Damage", $item->getMetadata()), + new Short("Damage", $item->getDamage()), )); if($item->getID() === Item::AIR or $item->getCount() <= 0){ diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index 660aa9f8e..0d245b901 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -60,7 +60,7 @@ class Furnace extends Tile{ $raw = $this->getSlot(0); $product = $this->getSlot(2); $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){ $this->lastUpdate = microtime(true); $this->namedtag->MaxTime = $this->namedtag->BurnTime = floor($fuel->getFuelTime() * 20); @@ -72,7 +72,7 @@ class Furnace extends Tile{ $this->setSlot(1, $fuel, false); $current = $this->getLevel()->getBlock($this); 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){ @@ -82,7 +82,7 @@ class Furnace extends Tile{ if($smelt !== false and $canSmelt){ $this->namedtag->CookTime += $ticks; 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); $raw->setCount($raw->getCount() - 1); if($raw->getCount() === 0){ @@ -102,7 +102,7 @@ class Furnace extends Tile{ }else{ $current = $this->getLevel()->getBlock($this); 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->BurnTime = 0;