mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-22 00:33:59 +00:00
Updated method names: getMetadata() & setMetadata() to getDamage() & setDamage() on Block and Item classes
This commit is contained in:
parent
c1546aac9c
commit
0be679c9d5
@ -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()){
|
||||
|
@ -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--;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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--;
|
||||
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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){
|
||||
|
@ -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){
|
||||
|
@ -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){
|
||||
|
@ -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--;
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
|
@ -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,
|
||||
|
@ -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){
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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(){
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -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";
|
||||
}
|
||||
|
@ -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(){
|
||||
|
@ -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){
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user