Renamed NBT tags to have Tag in the name

This commit is contained in:
Shoghi Cervantes 2015-08-12 21:30:15 +02:00
parent 34dc6ea0d6
commit 7f8b39a63c
58 changed files with 791 additions and 791 deletions

View File

@ -23,7 +23,7 @@ namespace pocketmine;
use pocketmine\metadata\MetadataValue; use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\plugin\Plugin; use pocketmine\plugin\Plugin;
class OfflinePlayer implements IPlayer{ class OfflinePlayer implements IPlayer{
@ -103,15 +103,15 @@ class OfflinePlayer implements IPlayer{
} }
public function getFirstPlayed(){ public function getFirstPlayed(){
return $this->namedtag instanceof Compound ? $this->namedtag["firstPlayed"] : null; return $this->namedtag instanceof CompoundTag ? $this->namedtag["firstPlayed"] : null;
} }
public function getLastPlayed(){ public function getLastPlayed(){
return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null; return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
} }
public function hasPlayedBefore(){ public function hasPlayedBefore(){
return $this->namedtag instanceof Compound; return $this->namedtag instanceof CompoundTag;
} }
public function setMetadata($metadataKey, MetadataValue $metadataValue){ public function setMetadata($metadataKey, MetadataValue $metadataValue){

View File

@ -91,15 +91,15 @@ use pocketmine\math\Vector2;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\metadata\MetadataValue; use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\Long; use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AdventureSettingsPacket; use pocketmine\network\protocol\AdventureSettingsPacket;
use pocketmine\network\protocol\AnimatePacket; use pocketmine\network\protocol\AnimatePacket;
@ -296,15 +296,15 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
} }
public function getFirstPlayed(){ public function getFirstPlayed(){
return $this->namedtag instanceof Compound ? $this->namedtag["firstPlayed"] : null; return $this->namedtag instanceof CompoundTag ? $this->namedtag["firstPlayed"] : null;
} }
public function getLastPlayed(){ public function getLastPlayed(){
return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null; return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null;
} }
public function hasPlayedBefore(){ public function hasPlayedBefore(){
return $this->namedtag instanceof Compound; return $this->namedtag instanceof CompoundTag;
} }
public function setAllowFlight($value){ public function setAllowFlight($value){
@ -503,7 +503,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->interface = $interface; $this->interface = $interface;
$this->windows = new \SplObjectStorage(); $this->windows = new \SplObjectStorage();
$this->perm = new PermissibleBase($this); $this->perm = new PermissibleBase($this);
$this->namedtag = new Compound(); $this->namedtag = new CompoundTag();
$this->server = Server::getInstance(); $this->server = Server::getInstance();
$this->lastBreak = PHP_INT_MAX; $this->lastBreak = PHP_INT_MAX;
$this->ip = $ip; $this->ip = $ip;
@ -1097,7 +1097,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->spawnToAll(); $this->spawnToAll();
} }
$this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode); $this->namedtag->playerGameType = new IntTag("playerGameType", $this->gamemode);
$spawnPosition = $this->getSpawn(); $spawnPosition = $this->getSpawn();
@ -1636,14 +1636,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$nbt = $this->server->getOfflinePlayerData($this->username); $nbt = $this->server->getOfflinePlayerData($this->username);
if(!isset($nbt->NameTag)){ if(!isset($nbt->NameTag)){
$nbt->NameTag = new String("NameTag", $this->username); $nbt->NameTag = new StringTag("NameTag", $this->username);
}else{ }else{
$nbt["NameTag"] = $this->username; $nbt["NameTag"] = $this->username;
} }
$this->gamemode = $nbt["playerGameType"] & 0x03; $this->gamemode = $nbt["playerGameType"] & 0x03;
if($this->server->getForceGamemode()){ if($this->server->getForceGamemode()){
$this->gamemode = $this->server->getGamemode(); $this->gamemode = $this->server->getGamemode();
$nbt->playerGameType = new Int("playerGameType", $this->gamemode); $nbt->playerGameType = new IntTag("playerGameType", $this->gamemode);
} }
$this->allowFlight = $this->isCreative(); $this->allowFlight = $this->isCreative();
@ -1659,7 +1659,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->setLevel($level); $this->setLevel($level);
} }
if(!($nbt instanceof Compound)){ if(!($nbt instanceof CompoundTag)){
$this->close($this->getLeaveMessage(), "Invalid data"); $this->close($this->getLeaveMessage(), "Invalid data");
return; return;
@ -1672,7 +1672,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false; $this->achievements[$achievement->getName()] = $achievement->getValue() > 0 ? true : false;
} }
$nbt->lastPlayed = new Long("lastPlayed", floor(microtime(true) * 1000)); $nbt->lastPlayed = new LongTag("lastPlayed", floor(microtime(true) * 1000));
if($this->server->getAutoSave()){ if($this->server->getAutoSave()){
$this->server->saveOfflinePlayerData($this->username, $nbt, true); $this->server->saveOfflinePlayerData($this->username, $nbt, true);
} }
@ -2039,20 +2039,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
} }
if($item->getId() === Item::SNOWBALL){ if($item->getId() === Item::SNOWBALL){
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
"Pos" => new Enum("Pos", [ "Pos" => new ListTag("Pos", [
new Double("", $this->x), new DoubleTag("", $this->x),
new Double("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->y + $this->getEyeHeight()),
new Double("", $this->z) new DoubleTag("", $this->z)
]), ]),
"Motion" => new Enum("Motion", [ "Motion" => new ListTag("Motion", [
new Double("", $aimPos->x), new DoubleTag("", $aimPos->x),
new Double("", $aimPos->y), new DoubleTag("", $aimPos->y),
new Double("", $aimPos->z) new DoubleTag("", $aimPos->z)
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new ListTag("Rotation", [
new Float("", $this->yaw), new FloatTag("", $this->yaw),
new Float("", $this->pitch) new FloatTag("", $this->pitch)
]), ]),
]); ]);
@ -2115,22 +2115,22 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
} }
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
"Pos" => new Enum("Pos", [ "Pos" => new ListTag("Pos", [
new Double("", $this->x), new DoubleTag("", $this->x),
new Double("", $this->y + $this->getEyeHeight()), new DoubleTag("", $this->y + $this->getEyeHeight()),
new Double("", $this->z) new DoubleTag("", $this->z)
]), ]),
"Motion" => new Enum("Motion", [ "Motion" => new ListTag("Motion", [
new Double("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)),
new Double("", -sin($this->pitch / 180 * M_PI)), new DoubleTag("", -sin($this->pitch / 180 * M_PI)),
new Double("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)) new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new ListTag("Rotation", [
new Float("", $this->yaw), new FloatTag("", $this->yaw),
new Float("", $this->pitch) new FloatTag("", $this->pitch)
]), ]),
"Fire" => new Short("Fire", $this->isOnFire() ? 45 * 60 : 0) "Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0)
]); ]);
$diff = ($this->server->getTick() - $this->startAction); $diff = ($this->server->getTick() - $this->startAction);
@ -3102,7 +3102,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
parent::saveNBT(); parent::saveNBT();
if($this->level instanceof Level){ if($this->level instanceof Level){
$this->namedtag->Level = new String("Level", $this->level->getName()); $this->namedtag->Level = new StringTag("Level", $this->level->getName());
if($this->spawnPosition instanceof Position and $this->spawnPosition->getLevel() instanceof Level){ if($this->spawnPosition instanceof Position and $this->spawnPosition->getLevel() instanceof Level){
$this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getName(); $this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getName();
$this->namedtag["SpawnX"] = (int) $this->spawnPosition->x; $this->namedtag["SpawnX"] = (int) $this->spawnPosition->x;
@ -3111,13 +3111,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
} }
foreach($this->achievements as $achievement => $status){ foreach($this->achievements as $achievement => $status){
$this->namedtag->Achievements[$achievement] = new Byte($achievement, $status === true ? 1 : 0); $this->namedtag->Achievements[$achievement] = new ByteTag($achievement, $status === true ? 1 : 0);
} }
$this->namedtag["playerGameType"] = $this->gamemode; $this->namedtag["playerGameType"] = $this->gamemode;
$this->namedtag["lastPlayed"] = new Long("lastPlayed", floor(microtime(true) * 1000)); $this->namedtag["lastPlayed"] = new LongTag("lastPlayed", floor(microtime(true) * 1000));
if($this->username != "" and $this->namedtag instanceof Compound){ if($this->username != "" and $this->namedtag instanceof CompoundTag){
$this->server->saveOfflinePlayerData($this->username, $this->namedtag, $async); $this->server->saveOfflinePlayerData($this->username, $this->namedtag, $async);
} }
} }

View File

@ -73,15 +73,15 @@ use pocketmine\metadata\EntityMetadataStore;
use pocketmine\metadata\LevelMetadataStore; use pocketmine\metadata\LevelMetadataStore;
use pocketmine\metadata\PlayerMetadataStore; use pocketmine\metadata\PlayerMetadataStore;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\Long; use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\CompressBatchedTask; use pocketmine\network\CompressBatchedTask;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\BatchPacket; use pocketmine\network\protocol\BatchPacket;
@ -743,7 +743,7 @@ class Server{
/** /**
* @param string $name * @param string $name
* *
* @return Compound * @return CompoundTag
*/ */
public function getOfflinePlayerData($name){ public function getOfflinePlayerData($name){
$name = strtolower($name); $name = strtolower($name);
@ -762,38 +762,38 @@ class Server{
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name])); $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name]));
} }
$spawn = $this->getDefaultLevel()->getSafeSpawn(); $spawn = $this->getDefaultLevel()->getSafeSpawn();
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
new Long("firstPlayed", floor(microtime(true) * 1000)), new LongTag("firstPlayed", floor(microtime(true) * 1000)),
new Long("lastPlayed", floor(microtime(true) * 1000)), new LongTag("lastPlayed", floor(microtime(true) * 1000)),
new Enum("Pos", [ new ListTag("Pos", [
new Double(0, $spawn->x), new DoubleTag(0, $spawn->x),
new Double(1, $spawn->y), new DoubleTag(1, $spawn->y),
new Double(2, $spawn->z) new DoubleTag(2, $spawn->z)
]), ]),
new String("Level", $this->getDefaultLevel()->getName()), new StringTag("Level", $this->getDefaultLevel()->getName()),
//new String("SpawnLevel", $this->getDefaultLevel()->getName()), //new StringTag("SpawnLevel", $this->getDefaultLevel()->getName()),
//new Int("SpawnX", (int) $spawn->x), //new IntTag("SpawnX", (int) $spawn->x),
//new Int("SpawnY", (int) $spawn->y), //new IntTag("SpawnY", (int) $spawn->y),
//new Int("SpawnZ", (int) $spawn->z), //new IntTag("SpawnZ", (int) $spawn->z),
//new Byte("SpawnForced", 1), //TODO //new ByteTag("SpawnForced", 1), //TODO
new Enum("Inventory", []), new ListTag("Inventory", []),
new Compound("Achievements", []), new CompoundTag("Achievements", []),
new Int("playerGameType", $this->getGamemode()), new IntTag("playerGameType", $this->getGamemode()),
new Enum("Motion", [ new ListTag("Motion", [
new Double(0, 0.0), new DoubleTag(0, 0.0),
new Double(1, 0.0), new DoubleTag(1, 0.0),
new Double(2, 0.0) new DoubleTag(2, 0.0)
]), ]),
new Enum("Rotation", [ new ListTag("Rotation", [
new Float(0, 0.0), new FloatTag(0, 0.0),
new Float(1, 0.0) new FloatTag(1, 0.0)
]), ]),
new Float("FallDistance", 0.0), new FloatTag("FallDistance", 0.0),
new Short("Fire", 0), new ShortTag("Fire", 0),
new Short("Air", 300), new ShortTag("Air", 300),
new Byte("OnGround", 1), new ByteTag("OnGround", 1),
new Byte("Invulnerable", 0), new ByteTag("Invulnerable", 0),
new String("NameTag", $name), new StringTag("NameTag", $name),
]); ]);
$nbt->Pos->setTagType(NBT::TAG_Double); $nbt->Pos->setTagType(NBT::TAG_Double);
$nbt->Inventory->setTagType(NBT::TAG_Compound); $nbt->Inventory->setTagType(NBT::TAG_Compound);
@ -814,39 +814,39 @@ class Server{
$this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerOld", [$name])); $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerOld", [$name]));
foreach($data->get("inventory") as $slot => $item){ foreach($data->get("inventory") as $slot => $item){
if(count($item) === 3){ if(count($item) === 3){
$nbt->Inventory[$slot + 9] = new Compound("", [ $nbt->Inventory[$slot + 9] = new CompoundTag("", [
new Short("id", $item[0]), new ShortTag("id", $item[0]),
new Short("Damage", $item[1]), new ShortTag("Damage", $item[1]),
new Byte("Count", $item[2]), new ByteTag("Count", $item[2]),
new Byte("Slot", $slot + 9), new ByteTag("Slot", $slot + 9),
new Byte("TrueSlot", $slot + 9) new ByteTag("TrueSlot", $slot + 9)
]); ]);
} }
} }
foreach($data->get("hotbar") as $slot => $itemSlot){ foreach($data->get("hotbar") as $slot => $itemSlot){
if(isset($nbt->Inventory[$itemSlot + 9])){ if(isset($nbt->Inventory[$itemSlot + 9])){
$item = $nbt->Inventory[$itemSlot + 9]; $item = $nbt->Inventory[$itemSlot + 9];
$nbt->Inventory[$slot] = new Compound("", [ $nbt->Inventory[$slot] = new CompoundTag("", [
new Short("id", $item["id"]), new ShortTag("id", $item["id"]),
new Short("Damage", $item["Damage"]), new ShortTag("Damage", $item["Damage"]),
new Byte("Count", $item["Count"]), new ByteTag("Count", $item["Count"]),
new Byte("Slot", $slot), new ByteTag("Slot", $slot),
new Byte("TrueSlot", $item["TrueSlot"]) new ByteTag("TrueSlot", $item["TrueSlot"])
]); ]);
} }
} }
foreach($data->get("armor") as $slot => $item){ foreach($data->get("armor") as $slot => $item){
if(count($item) === 2){ if(count($item) === 2){
$nbt->Inventory[$slot + 100] = new Compound("", [ $nbt->Inventory[$slot + 100] = new CompoundTag("", [
new Short("id", $item[0]), new ShortTag("id", $item[0]),
new Short("Damage", $item[1]), new ShortTag("Damage", $item[1]),
new Byte("Count", 1), new ByteTag("Count", 1),
new Byte("Slot", $slot + 100) new ByteTag("Slot", $slot + 100)
]); ]);
} }
} }
foreach($data->get("achievements") as $achievement => $status){ foreach($data->get("achievements") as $achievement => $status){
$nbt->Achievements[$achievement] = new Byte($achievement, $status == true ? 1 : 0); $nbt->Achievements[$achievement] = new ByteTag($achievement, $status == true ? 1 : 0);
} }
unlink($path . "$name.yml"); unlink($path . "$name.yml");
} }
@ -858,10 +858,10 @@ class Server{
/** /**
* @param string $name * @param string $name
* @param Compound $nbtTag * @param CompoundTag $nbtTag
* @param bool $async * @param bool $async
*/ */
public function saveOfflinePlayerData($name, Compound $nbtTag, $async = false){ public function saveOfflinePlayerData($name, CompoundTag $nbtTag, $async = false){
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
try{ try{
$nbt->setData($nbtTag); $nbt->setData($nbtTag);

View File

@ -24,10 +24,10 @@ namespace pocketmine\block;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\Tool; use pocketmine\item\Tool;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\tile\Furnace; use pocketmine\tile\Furnace;
use pocketmine\tile\Tile; use pocketmine\tile\Tile;
@ -69,17 +69,17 @@ class BurningFurnace extends Solid{
]; ];
$this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0];
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
new Enum("Items", []), new ListTag("Items", []),
new String("id", Tile::FURNACE), new StringTag("id", Tile::FURNACE),
new Int("x", $this->x), new IntTag("x", $this->x),
new Int("y", $this->y), new IntTag("y", $this->y),
new Int("z", $this->z) new IntTag("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
if($item->hasCustomName()){ if($item->hasCustomName()){
$nbt->CustomName = new String("CustomName", $item->getCustomName()); $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
} }
if($item->hasCustomBlockData()){ if($item->hasCustomBlockData()){
@ -106,18 +106,18 @@ class BurningFurnace extends Solid{
if($t instanceof Furnace){ if($t instanceof Furnace){
$furnace = $t; $furnace = $t;
}else{ }else{
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
new Enum("Items", []), new ListTag("Items", []),
new String("id", Tile::FURNACE), new StringTag("id", Tile::FURNACE),
new Int("x", $this->x), new IntTag("x", $this->x),
new Int("y", $this->y), new IntTag("y", $this->y),
new Int("z", $this->z) new IntTag("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
$furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); $furnace = Tile::createTile("Furnace", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
} }
if(isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof String){ if(isset($furnace->namedtag->Lock) and $furnace->namedtag->Lock instanceof StringTag){
if($furnace->namedtag->Lock->getValue() !== $item->getCustomName()){ if($furnace->namedtag->Lock->getValue() !== $item->getCustomName()){
return true; return true;
} }

View File

@ -25,10 +25,10 @@ use pocketmine\item\Item;
use pocketmine\item\Tool; use pocketmine\item\Tool;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\tile\Chest as TileChest; use pocketmine\tile\Chest as TileChest;
use pocketmine\tile\Tile; use pocketmine\tile\Tile;
@ -96,17 +96,17 @@ class Chest extends Transparent{
} }
$this->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
new Enum("Items", []), new ListTag("Items", []),
new String("id", Tile::CHEST), new StringTag("id", Tile::CHEST),
new Int("x", $this->x), new IntTag("x", $this->x),
new Int("y", $this->y), new IntTag("y", $this->y),
new Int("z", $this->z) new IntTag("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
if($item->hasCustomName()){ if($item->hasCustomName()){
$nbt->CustomName = new String("CustomName", $item->getCustomName()); $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
} }
if($item->hasCustomBlockData()){ if($item->hasCustomBlockData()){
@ -147,18 +147,18 @@ class Chest extends Transparent{
if($t instanceof TileChest){ if($t instanceof TileChest){
$chest = $t; $chest = $t;
}else{ }else{
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
new Enum("Items", []), new ListTag("Items", []),
new String("id", Tile::CHEST), new StringTag("id", Tile::CHEST),
new Int("x", $this->x), new IntTag("x", $this->x),
new Int("y", $this->y), new IntTag("y", $this->y),
new Int("z", $this->z) new IntTag("z", $this->z)
]); ]);
$nbt->Items->setTagType(NBT::TAG_Compound); $nbt->Items->setTagType(NBT::TAG_Compound);
$chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt); $chest = Tile::createTile("Chest", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), $nbt);
} }
if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof String){ if(isset($chest->namedtag->Lock) and $chest->namedtag->Lock instanceof StringTag){
if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){ if($chest->namedtag->Lock->getValue() !== $item->getCustomName()){
return true; return true;
} }

View File

@ -51,7 +51,7 @@ class DoubleSlab extends Solid{
6 => "Quartz", 6 => "Quartz",
7 => "", 7 => "",
]; ];
return "Double " . $names[$this->meta & 0x07] . " Slab"; return "DoubleTag " . $names[$this->meta & 0x07] . " Slab";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -50,7 +50,7 @@ class DoubleWoodSlab extends Solid{
6 => "", 6 => "",
7 => "" 7 => ""
]; ];
return "Double " . $names[$this->meta & 0x07] . " Wooden Slab"; return "DoubleTag " . $names[$this->meta & 0x07] . " Wooden Slab";
} }
public function getDrops(Item $item){ public function getDrops(Item $item){

View File

@ -25,9 +25,9 @@ use pocketmine\inventory\EnchantInventory;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\item\Tool; use pocketmine\item\Tool;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\tile\Tile; use pocketmine\tile\Tile;
@ -41,15 +41,15 @@ class EnchantingTable 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->getLevel()->setBlock($block, $this, true, true); $this->getLevel()->setBlock($block, $this, true, true);
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
new String("id", Tile::ENCHANT_TABLE), new StringTag("id", Tile::ENCHANT_TABLE),
new Int("x", $this->x), new IntTag("x", $this->x),
new Int("y", $this->y), new IntTag("y", $this->y),
new Int("z", $this->z) new IntTag("z", $this->z)
]); ]);
if($item->hasCustomName()){ if($item->hasCustomName()){
$nbt->CustomName = new String("CustomName", $item->getCustomName()); $nbt->CustomName = new StringTag("CustomName", $item->getCustomName());
} }
if($item->hasCustomBlockData()){ if($item->hasCustomBlockData()){

View File

@ -37,7 +37,7 @@ class EndPortalFrame extends Solid{
} }
public function getName(){ public function getName(){
return "End Portal Frame"; return "EndTag Portal Frame";
} }
public function getHardness(){ public function getHardness(){

View File

@ -33,7 +33,7 @@ class EndStone extends Solid{
} }
public function getName(){ public function getName(){
return "End Stone"; return "EndTag Stone";
} }
public function getToolType(){ public function getToolType(){

View File

@ -25,12 +25,12 @@ use pocketmine\entity\Entity;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\Player; use pocketmine\Player;
abstract class Fallable extends Solid{ abstract class Fallable extends Solid{
@ -45,23 +45,23 @@ abstract class Fallable extends Solid{
if($type === Level::BLOCK_UPDATE_NORMAL){ if($type === Level::BLOCK_UPDATE_NORMAL){
$down = $this->getSide(Vector3::SIDE_DOWN); $down = $this->getSide(Vector3::SIDE_DOWN);
if($down->getId() === self::AIR or ($down instanceof Liquid)){ if($down->getId() === self::AIR or ($down instanceof Liquid)){
$fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [ $fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [
"Pos" => new Enum("Pos", [ "Pos" => new ListTag("Pos", [
new Double("", $this->x + 0.5), new DoubleTag("", $this->x + 0.5),
new Double("", $this->y), new DoubleTag("", $this->y),
new Double("", $this->z + 0.5) new DoubleTag("", $this->z + 0.5)
]), ]),
"Motion" => new Enum("Motion", [ "Motion" => new ListTag("Motion", [
new Double("", 0), new DoubleTag("", 0),
new Double("", 0), new DoubleTag("", 0),
new Double("", 0) new DoubleTag("", 0)
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new ListTag("Rotation", [
new Float("", 0), new FloatTag("", 0),
new Float("", 0) new FloatTag("", 0)
]), ]),
"TileID" => new Int("TileID", $this->getId()), "TileID" => new IntTag("TileID", $this->getId()),
"Data" => new Byte("Data", $this->getDamage()), "Data" => new ByteTag("Data", $this->getDamage()),
])); ]));
$fall->spawnToAll(); $fall->spawnToAll();

View File

@ -23,11 +23,11 @@ namespace pocketmine\block;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\utils\Random; use pocketmine\utils\Random;
@ -57,22 +57,22 @@ class TNT extends Solid{
$this->getLevel()->setBlock($this, new Air(), true); $this->getLevel()->setBlock($this, new Air(), true);
$mot = (new Random())->nextSignedFloat() * M_PI * 2; $mot = (new Random())->nextSignedFloat() * M_PI * 2;
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [ $tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [
"Pos" => new Enum("Pos", [ "Pos" => new ListTag("Pos", [
new Double("", $this->x + 0.5), new DoubleTag("", $this->x + 0.5),
new Double("", $this->y), new DoubleTag("", $this->y),
new Double("", $this->z + 0.5) new DoubleTag("", $this->z + 0.5)
]), ]),
"Motion" => new Enum("Motion", [ "Motion" => new ListTag("Motion", [
new Double("", -sin($mot) * 0.02), new DoubleTag("", -sin($mot) * 0.02),
new Double("", 0.2), new DoubleTag("", 0.2),
new Double("", -cos($mot) * 0.02) new DoubleTag("", -cos($mot) * 0.02)
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new ListTag("Rotation", [
new Float("", 0), new FloatTag("", 0),
new Float("", 0) new FloatTag("", 0)
]), ]),
"Fuse" => new Byte("Fuse", 80) "Fuse" => new ByteTag("Fuse", 80)
])); ]));
$tnt->spawnToAll(); $tnt->spawnToAll();

View File

@ -26,7 +26,7 @@ use pocketmine\command\CommandSender;
use pocketmine\event\TranslationContainer; use pocketmine\event\TranslationContainer;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\utils\TextFormat; use pocketmine\utils\TextFormat;
@ -70,7 +70,7 @@ class GiveCommand extends VanillaCommand{
$exception = $ex; $exception = $ex;
} }
if(!($tags instanceof Compound) or $exception !== null){ if(!($tags instanceof CompoundTag) or $exception !== null){
$sender->sendMessage(new TranslationContainer("commands.give.tagError", [$exception !== null ? $exception->getMessage() : "Invalid tag conversion"])); $sender->sendMessage(new TranslationContainer("commands.give.tagError", [$exception !== null ? $exception->getMessage() : "Invalid tag conversion"]));
return true; return true;
} }

View File

@ -23,7 +23,7 @@ namespace pocketmine\entity;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\level\particle\CriticalParticle; use pocketmine\level\particle\CriticalParticle;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\Player; use pocketmine\Player;
@ -42,7 +42,7 @@ class Arrow extends Projectile{
protected $isCritical; protected $isCritical;
public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null, $critical = false){ public function __construct(FullChunk $chunk, CompoundTag $nbt, Entity $shootingEntity = null, $critical = false){
$this->isCritical = (bool) $critical; $this->isCritical = (bool) $critical;
parent::__construct($chunk, $nbt, $shootingEntity); parent::__construct($chunk, $nbt, $shootingEntity);
} }

View File

@ -45,14 +45,14 @@ use pocketmine\math\Vector2;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\metadata\Metadatable; use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue; use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\MobEffectPacket; use pocketmine\network\protocol\MobEffectPacket;
use pocketmine\network\protocol\RemoveEntityPacket; use pocketmine\network\protocol\RemoveEntityPacket;
@ -205,7 +205,7 @@ abstract class Entity extends Location implements Metadatable{
protected $isPlayer = false; protected $isPlayer = false;
public function __construct(FullChunk $chunk, Compound $nbt){ public function __construct(FullChunk $chunk, CompoundTag $nbt){
if($chunk === null or $chunk->getProvider() === null){ if($chunk === null or $chunk->getProvider() === null){
throw new ChunkException("Invalid garbage Chunk given to Entity"); throw new ChunkException("Invalid garbage Chunk given to Entity");
} }
@ -241,27 +241,27 @@ abstract class Entity extends Location implements Metadatable{
$this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2])); $this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2]));
if(!isset($this->namedtag->FallDistance)){ if(!isset($this->namedtag->FallDistance)){
$this->namedtag->FallDistance = new Float("FallDistance", 0); $this->namedtag->FallDistance = new FloatTag("FallDistance", 0);
} }
$this->fallDistance = $this->namedtag["FallDistance"]; $this->fallDistance = $this->namedtag["FallDistance"];
if(!isset($this->namedtag->Fire)){ if(!isset($this->namedtag->Fire)){
$this->namedtag->Fire = new Short("Fire", 0); $this->namedtag->Fire = new ShortTag("Fire", 0);
} }
$this->fireTicks = $this->namedtag["Fire"]; $this->fireTicks = $this->namedtag["Fire"];
if(!isset($this->namedtag->Air)){ if(!isset($this->namedtag->Air)){
$this->namedtag->Air = new Short("Air", 300); $this->namedtag->Air = new ShortTag("Air", 300);
} }
$this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"]); $this->setDataProperty(self::DATA_AIR, self::DATA_TYPE_SHORT, $this->namedtag["Air"]);
if(!isset($this->namedtag->OnGround)){ if(!isset($this->namedtag->OnGround)){
$this->namedtag->OnGround = new Byte("OnGround", 0); $this->namedtag->OnGround = new ByteTag("OnGround", 0);
} }
$this->onGround = $this->namedtag["OnGround"] > 0 ? true : false; $this->onGround = $this->namedtag["OnGround"] > 0 ? true : false;
if(!isset($this->namedtag->Invulnerable)){ if(!isset($this->namedtag->Invulnerable)){
$this->namedtag->Invulnerable = new Byte("Invulnerable", 0); $this->namedtag->Invulnerable = new ByteTag("Invulnerable", 0);
} }
$this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false; $this->invulnerable = $this->namedtag["Invulnerable"] > 0 ? true : false;
@ -407,12 +407,12 @@ abstract class Entity extends Location implements Metadatable{
/** /**
* @param int|string $type * @param int|string $type
* @param FullChunk $chunk * @param FullChunk $chunk
* @param Compound $nbt * @param CompoundTag $nbt
* @param $args * @param $args
* *
* @return Entity * @return Entity
*/ */
public static function createEntity($type, FullChunk $chunk, Compound $nbt, ...$args){ public static function createEntity($type, FullChunk $chunk, CompoundTag $nbt, ...$args){
if(isset(self::$knownEntities[$type])){ if(isset(self::$knownEntities[$type])){
$class = self::$knownEntities[$type]; $class = self::$knownEntities[$type];
return new $class($chunk, $nbt, ...$args); return new $class($chunk, $nbt, ...$args);
@ -449,52 +449,52 @@ abstract class Entity extends Location implements Metadatable{
public function saveNBT(){ public function saveNBT(){
if(!($this instanceof Player)){ if(!($this instanceof Player)){
$this->namedtag->id = new String("id", $this->getSaveId()); $this->namedtag->id = new StringTag("id", $this->getSaveId());
if($this->getNameTag() !== ""){ if($this->getNameTag() !== ""){
$this->namedtag->CustomName = new String("CustomName", $this->getNameTag()); $this->namedtag->CustomName = new StringTag("CustomName", $this->getNameTag());
$this->namedtag->CustomNameVisible = new String("CustomNameVisible", $this->isNameTagVisible()); $this->namedtag->CustomNameVisible = new StringTag("CustomNameVisible", $this->isNameTagVisible());
}else{ }else{
unset($this->namedtag->CustomName); unset($this->namedtag->CustomName);
unset($this->namedtag->CustomNameVisible); unset($this->namedtag->CustomNameVisible);
} }
} }
$this->namedtag->Pos = new Enum("Pos", [ $this->namedtag->Pos = new ListTag("Pos", [
new Double(0, $this->x), new DoubleTag(0, $this->x),
new Double(1, $this->y), new DoubleTag(1, $this->y),
new Double(2, $this->z) new DoubleTag(2, $this->z)
]); ]);
$this->namedtag->Motion = new Enum("Motion", [ $this->namedtag->Motion = new ListTag("Motion", [
new Double(0, $this->motionX), new DoubleTag(0, $this->motionX),
new Double(1, $this->motionY), new DoubleTag(1, $this->motionY),
new Double(2, $this->motionZ) new DoubleTag(2, $this->motionZ)
]); ]);
$this->namedtag->Rotation = new Enum("Rotation", [ $this->namedtag->Rotation = new ListTag("Rotation", [
new Float(0, $this->yaw), new FloatTag(0, $this->yaw),
new Float(1, $this->pitch) new FloatTag(1, $this->pitch)
]); ]);
$this->namedtag->FallDistance = new Float("FallDistance", $this->fallDistance); $this->namedtag->FallDistance = new FloatTag("FallDistance", $this->fallDistance);
$this->namedtag->Fire = new Short("Fire", $this->fireTicks); $this->namedtag->Fire = new ShortTag("Fire", $this->fireTicks);
$this->namedtag->Air = new Short("Air", $this->getDataProperty(self::DATA_AIR)); $this->namedtag->Air = new ShortTag("Air", $this->getDataProperty(self::DATA_AIR));
$this->namedtag->OnGround = new Byte("OnGround", $this->onGround == true ? 1 : 0); $this->namedtag->OnGround = new ByteTag("OnGround", $this->onGround == true ? 1 : 0);
$this->namedtag->Invulnerable = new Byte("Invulnerable", $this->invulnerable == true ? 1 : 0); $this->namedtag->Invulnerable = new ByteTag("Invulnerable", $this->invulnerable == true ? 1 : 0);
if(count($this->effects) > 0){ if(count($this->effects) > 0){
$effects = []; $effects = [];
foreach($this->effects as $effect){ foreach($this->effects as $effect){
$effects[$effect->getId()] = new Compound($effect->getId(), [ $effects[$effect->getId()] = new CompoundTag($effect->getId(), [
"Id" => new Byte("Id", $effect->getId()), "Id" => new ByteTag("Id", $effect->getId()),
"Amplifier" => new Byte("Amplifier", $effect->getAmplifier()), "Amplifier" => new ByteTag("Amplifier", $effect->getAmplifier()),
"Duration" => new Int("Duration", $effect->getDuration()), "Duration" => new IntTag("Duration", $effect->getDuration()),
"Ambient" => new Byte("Ambient", 0), "Ambient" => new ByteTag("Ambient", 0),
"ShowParticles" => new Byte("ShowParticles", $effect->isVisible() ? 1 : 0) "ShowParticles" => new ByteTag("ShowParticles", $effect->isVisible() ? 1 : 0)
]); ]);
} }
$this->namedtag->ActiveEffects = new Enum("ActiveEffects", $effects); $this->namedtag->ActiveEffects = new ListTag("ActiveEffects", $effects);
}else{ }else{
unset($this->namedtag->ActiveEffects); unset($this->namedtag->ActiveEffects);
} }

View File

@ -30,8 +30,8 @@ use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\item\Item as ItemItem; use pocketmine\item\Item as ItemItem;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\Player; use pocketmine\Player;
@ -58,7 +58,7 @@ class FallingSand extends Entity{
$this->blockId = $this->namedtag["TileID"]; $this->blockId = $this->namedtag["TileID"];
}elseif(isset($this->namedtag->Tile)){ }elseif(isset($this->namedtag->Tile)){
$this->blockId = $this->namedtag["Tile"]; $this->blockId = $this->namedtag["Tile"];
$this->namedtag["TileID"] = new Int("TileID", $this->blockId); $this->namedtag["TileID"] = new IntTag("TileID", $this->blockId);
} }
if(isset($this->namedtag->Data)){ if(isset($this->namedtag->Data)){
@ -153,8 +153,8 @@ class FallingSand extends Entity{
} }
public function saveNBT(){ public function saveNBT(){
$this->namedtag->TileID = new Int("TileID", $this->blockId); $this->namedtag->TileID = new IntTag("TileID", $this->blockId);
$this->namedtag->Data = new Byte("Data", $this->damage); $this->namedtag->Data = new ByteTag("Data", $this->damage);
} }
public function spawnTo(Player $player){ public function spawnTo(Player $player){

View File

@ -26,11 +26,11 @@ use pocketmine\inventory\PlayerInventory;
use pocketmine\item\Item as ItemItem; use pocketmine\item\Item as ItemItem;
use pocketmine\utils\UUID; use pocketmine\utils\UUID;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AddPlayerPacket; use pocketmine\network\protocol\AddPlayerPacket;
use pocketmine\network\protocol\RemovePlayerPacket; use pocketmine\network\protocol\RemovePlayerPacket;
@ -111,14 +111,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
$this->setNameTag($this->namedtag["NameTag"]); $this->setNameTag($this->namedtag["NameTag"]);
} }
if(isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof Compound){ if(isset($this->namedtag->Skin) and $this->namedtag->Skin instanceof CompoundTag){
$this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Slim"] > 0); $this->setSkin($this->namedtag->Skin["Data"], $this->namedtag->Skin["Slim"] > 0);
} }
$this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag()); $this->uuid = UUID::fromData($this->getId(), $this->getSkinData(), $this->getNameTag());
} }
if(isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof Enum){ if(isset($this->namedtag->Inventory) and $this->namedtag->Inventory instanceof ListTag){
foreach($this->namedtag->Inventory as $item){ foreach($this->namedtag->Inventory as $item){
if($item["Slot"] >= 0 and $item["Slot"] < 9){ //Hotbar if($item["Slot"] >= 0 and $item["Slot"] < 9){ //Hotbar
$this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1); $this->inventory->setHotbarSlotIndex($item["Slot"], isset($item["TrueSlot"]) ? $item["TrueSlot"] : -1);
@ -150,7 +150,7 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
public function saveNBT(){ public function saveNBT(){
parent::saveNBT(); parent::saveNBT();
$this->namedtag->Inventory = new Enum("Inventory", []); $this->namedtag->Inventory = new ListTag("Inventory", []);
$this->namedtag->Inventory->setTagType(NBT::TAG_Compound); $this->namedtag->Inventory->setTagType(NBT::TAG_Compound);
if($this->inventory !== null){ if($this->inventory !== null){
for($slot = 0; $slot < 9; ++$slot){ for($slot = 0; $slot < 9; ++$slot){
@ -159,19 +159,19 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
$item = $this->inventory->getItem($hotbarSlot); $item = $this->inventory->getItem($hotbarSlot);
if($item->getId() !== 0 and $item->getCount() > 0){ if($item->getId() !== 0 and $item->getCount() > 0){
$tag = NBT::putItemHelper($item, $slot); $tag = NBT::putItemHelper($item, $slot);
$tag->TrueSlot = new Byte("TrueSlot", $hotbarSlot); $tag->TrueSlot = new ByteTag("TrueSlot", $hotbarSlot);
$this->namedtag->Inventory[$slot] = $tag; $this->namedtag->Inventory[$slot] = $tag;
continue; continue;
} }
} }
$this->namedtag->Inventory[$slot] = new Compound("", [ $this->namedtag->Inventory[$slot] = new CompoundTag("", [
new Byte("Count", 0), new ByteTag("Count", 0),
new Short("Damage", 0), new ShortTag("Damage", 0),
new Byte("Slot", $slot), new ByteTag("Slot", $slot),
new Byte("TrueSlot", -1), new ByteTag("TrueSlot", -1),
new Short("id", 0), new ShortTag("id", 0),
]); ]);
} }
@ -193,9 +193,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
} }
if(strlen($this->getSkinData()) > 0){ if(strlen($this->getSkinData()) > 0){
$this->namedtag->Skin = new Compound("Skin", [ $this->namedtag->Skin = new CompoundTag("Skin", [
"Data" => new String("Data", $this->getSkinData()), "Data" => new StringTag("Data", $this->getSkinData()),
"Slim" => new Byte("Slim", $this->isSkinSlim() ? 1 : 0) "Slim" => new ByteTag("Slim", $this->isSkinSlim() ? 1 : 0)
]); ]);
} }
} }

View File

@ -30,8 +30,8 @@ use pocketmine\item\Item as ItemItem;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AddItemEntityPacket; use pocketmine\network\protocol\AddItemEntityPacket;
use pocketmine\Player; use pocketmine\Player;
@ -160,14 +160,14 @@ class Item extends Entity{
public function saveNBT(){ public function saveNBT(){
parent::saveNBT(); parent::saveNBT();
$this->namedtag->Item = NBT::putItemHelper($this->item); $this->namedtag->Item = NBT::putItemHelper($this->item);
$this->namedtag->Health = new Short("Health", $this->getHealth()); $this->namedtag->Health = new ShortTag("Health", $this->getHealth());
$this->namedtag->Age = new Short("Age", $this->age); $this->namedtag->Age = new ShortTag("Age", $this->age);
$this->namedtag->PickupDelay = new Short("PickupDelay", $this->pickupDelay); $this->namedtag->PickupDelay = new ShortTag("PickupDelay", $this->pickupDelay);
if($this->owner !== null){ if($this->owner !== null){
$this->namedtag->Owner = new String("Owner", $this->owner); $this->namedtag->Owner = new StringTag("Owner", $this->owner);
} }
if($this->thrower !== null){ if($this->thrower !== null){
$this->namedtag->Thrower = new String("Thrower", $this->thrower); $this->namedtag->Thrower = new StringTag("Thrower", $this->thrower);
} }
} }

View File

@ -31,7 +31,7 @@ use pocketmine\event\entity\EntityRegainHealthEvent;
use pocketmine\event\Timings; use pocketmine\event\Timings;
use pocketmine\item\Item as ItemItem; use pocketmine\item\Item as ItemItem;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\EntityEventPacket; use pocketmine\network\protocol\EntityEventPacket;
@ -51,12 +51,12 @@ abstract class Living extends Entity implements Damageable{
parent::initEntity(); parent::initEntity();
if(isset($this->namedtag->HealF)){ if(isset($this->namedtag->HealF)){
$this->namedtag->Health = new Short("Health", (int) $this->namedtag["HealF"]); $this->namedtag->Health = new ShortTag("Health", (int) $this->namedtag["HealF"]);
unset($this->namedtag->HealF); unset($this->namedtag->HealF);
} }
if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof ShortTag)){
$this->namedtag->Health = new Short("Health", $this->getMaxHealth()); $this->namedtag->Health = new ShortTag("Health", $this->getMaxHealth());
} }
$this->setHealth($this->namedtag["Health"]); $this->setHealth($this->namedtag["Health"]);
@ -75,7 +75,7 @@ abstract class Living extends Entity implements Damageable{
public function saveNBT(){ public function saveNBT(){
parent::saveNBT(); parent::saveNBT();
$this->namedtag->Health = new Short("Health", $this->getHealth()); $this->namedtag->Health = new ShortTag("Health", $this->getHealth());
} }
public abstract function getName(); public abstract function getName();

View File

@ -26,7 +26,7 @@ use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\event\entity\ExplosionPrimeEvent; use pocketmine\event\entity\ExplosionPrimeEvent;
use pocketmine\level\Explosion; use pocketmine\level\Explosion;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\Player; use pocketmine\Player;
@ -69,7 +69,7 @@ class PrimedTNT extends Entity implements Explosive{
public function saveNBT(){ public function saveNBT(){
parent::saveNBT(); parent::saveNBT();
$this->namedtag->Fuse = new Byte("Fuse", $this->fuse); $this->namedtag->Fuse = new ByteTag("Fuse", $this->fuse);
} }
public function onUpdate($currentTick){ public function onUpdate($currentTick){

View File

@ -31,8 +31,8 @@ use pocketmine\event\entity\ProjectileHitEvent;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\level\MovingObjectPosition; use pocketmine\level\MovingObjectPosition;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
abstract class Projectile extends Entity{ abstract class Projectile extends Entity{
@ -44,7 +44,7 @@ abstract class Projectile extends Entity{
public $hadCollision = false; public $hadCollision = false;
public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null){ public function __construct(FullChunk $chunk, CompoundTag $nbt, Entity $shootingEntity = null){
$this->shootingEntity = $shootingEntity; $this->shootingEntity = $shootingEntity;
if($shootingEntity !== null){ if($shootingEntity !== null){
$this->setDataProperty(self::DATA_SHOOTER_ID, self::DATA_TYPE_LONG, $shootingEntity->getId()); $this->setDataProperty(self::DATA_SHOOTER_ID, self::DATA_TYPE_LONG, $shootingEntity->getId());
@ -75,7 +75,7 @@ abstract class Projectile extends Entity{
public function saveNBT(){ public function saveNBT(){
parent::saveNBT(); parent::saveNBT();
$this->namedtag->Age = new Short("Age", $this->age); $this->namedtag->Age = new ShortTag("Age", $this->age);
} }
public function onUpdate($currentTick){ public function onUpdate($currentTick){

View File

@ -23,7 +23,7 @@ namespace pocketmine\entity;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\Player; use pocketmine\Player;
@ -38,7 +38,7 @@ class Snowball extends Projectile{
protected $gravity = 0.03; protected $gravity = 0.03;
protected $drag = 0.01; protected $drag = 0.01;
public function __construct(FullChunk $chunk, Compound $nbt, Entity $shootingEntity = null){ public function __construct(FullChunk $chunk, CompoundTag $nbt, Entity $shootingEntity = null){
parent::__construct($chunk, $nbt, $shootingEntity); parent::__construct($chunk, $nbt, $shootingEntity);
} }

View File

@ -22,7 +22,7 @@
namespace pocketmine\entity; namespace pocketmine\entity;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\AddEntityPacket; use pocketmine\network\protocol\AddEntityPacket;
use pocketmine\Player; use pocketmine\Player;
@ -76,7 +76,7 @@ class Villager extends Creature implements NPC, Ageable{
* @param $profession * @param $profession
*/ */
public function setProfession($profession){ public function setProfession($profession){
$this->namedtag->Profession = new Int("Profession", $profession); $this->namedtag->Profession = new IntTag("Profession", $profession);
} }
public function getProfession(){ public function getProfession(){

View File

@ -57,7 +57,7 @@ class InventoryType{
} }
static::$default[static::CHEST] = new InventoryType(27, "Chest", 0); static::$default[static::CHEST] = new InventoryType(27, "Chest", 0);
static::$default[static::DOUBLE_CHEST] = new InventoryType(27 + 27, "Double Chest", 0); static::$default[static::DOUBLE_CHEST] = new InventoryType(27 + 27, "DoubleTag Chest", 0);
static::$default[static::PLAYER] = new InventoryType(40, "Player", 0); //27 CONTAINER, 4 ARMOR (9 reference HOTBAR slots) static::$default[static::PLAYER] = new InventoryType(40, "Player", 0); //27 CONTAINER, 4 ARMOR (9 reference HOTBAR slots)
static::$default[static::FURNACE] = new InventoryType(3, "Furnace", 2); static::$default[static::FURNACE] = new InventoryType(3, "Furnace", 2);
static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT

View File

@ -33,11 +33,11 @@ use pocketmine\entity\Zombie;
use pocketmine\inventory\Fuel; use pocketmine\inventory\Fuel;
use pocketmine\item\enchantment\Enchantment; use pocketmine\item\enchantment\Enchantment;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
class Item{ class Item{
@ -46,7 +46,7 @@ class Item{
/** /**
* @param $tag * @param $tag
* @return Compound * @return CompoundTag
*/ */
private static function parseCompoundTag($tag){ private static function parseCompoundTag($tag){
if(self::$cachedParser === null){ if(self::$cachedParser === null){
@ -58,10 +58,10 @@ class Item{
} }
/** /**
* @param Compound $tag * @param CompoundTag $tag
* @return string * @return string
*/ */
private static function writeCompoundTag(Compound $tag){ private static function writeCompoundTag(CompoundTag $tag){
if(self::$cachedParser === null){ if(self::$cachedParser === null){
self::$cachedParser = new NBT(NBT::LITTLE_ENDIAN); self::$cachedParser = new NBT(NBT::LITTLE_ENDIAN);
} }
@ -703,7 +703,7 @@ class Item{
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_PINK_TULIP)); self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_PINK_TULIP));
self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_OXEYE_DAISY)); self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_OXEYE_DAISY));
//TODO: Lilac //TODO: Lilac
//TODO: Double Tallgrass //TODO: DoubleTag Tallgrass
//TODO: Large Fern //TODO: Large Fern
//TODO: Rose Bush //TODO: Rose Bush
//TODO: Peony //TODO: Peony
@ -953,7 +953,7 @@ class Item{
} }
public function setCompoundTag($tags){ public function setCompoundTag($tags){
if($tags instanceof Compound){ if($tags instanceof CompoundTag){
$this->setNamedTag($tags); $this->setNamedTag($tags);
}else{ }else{
$this->tags = $tags; $this->tags = $tags;
@ -980,7 +980,7 @@ class Item{
} }
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof Compound){ if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){
return true; return true;
} }
@ -993,7 +993,7 @@ class Item{
} }
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof Compound){ if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){
unset($tag->display->BlockEntityTag); unset($tag->display->BlockEntityTag);
$this->setNamedTag($tag); $this->setNamedTag($tag);
} }
@ -1001,12 +1001,12 @@ class Item{
return $this; return $this;
} }
public function setCustomBlockData(Compound $compound){ public function setCustomBlockData(CompoundTag $compound){
$tags = clone $compound; $tags = clone $compound;
$tags->setName("BlockEntityTag"); $tags->setName("BlockEntityTag");
if(!$this->hasCompoundTag()){ if(!$this->hasCompoundTag()){
$tag = new Compound("", []); $tag = new CompoundTag("", []);
}else{ }else{
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
} }
@ -1023,7 +1023,7 @@ class Item{
} }
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof Compound){ if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){
return $tag->BlockEntityTag; return $tag->BlockEntityTag;
} }
@ -1038,7 +1038,7 @@ class Item{
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if(isset($tag->ench)){ if(isset($tag->ench)){
$tag = $tag->ench; $tag = $tag->ench;
if($tag instanceof Enum){ if($tag instanceof ListTag){
return true; return true;
} }
} }
@ -1071,13 +1071,13 @@ class Item{
*/ */
public function addEnchantment(Enchantment $ench){ public function addEnchantment(Enchantment $ench){
if(!$this->hasCompoundTag()){ if(!$this->hasCompoundTag()){
$tag = new Compound("", []); $tag = new CompoundTag("", []);
}else{ }else{
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
} }
if(!isset($tag->ench)){ if(!isset($tag->ench)){
$tag->ench = new Enum("ench", []); $tag->ench = new ListTag("ench", []);
$tag->ench->setTagType(NBT::TAG_Compound); $tag->ench->setTagType(NBT::TAG_Compound);
} }
@ -1085,9 +1085,9 @@ class Item{
foreach($tag->ench as $k => $entry){ foreach($tag->ench as $k => $entry){
if($entry["id"] === $ench->getId()){ if($entry["id"] === $ench->getId()){
$tag->ench->{$k} = new Compound("", [ $tag->ench->{$k} = new CompoundTag("", [
"id" => new Short("id", $ench->getId()), "id" => new ShortTag("id", $ench->getId()),
"lvl" => new Short("lvl", $ench->getLevel()) "lvl" => new ShortTag("lvl", $ench->getLevel())
]); ]);
$found = true; $found = true;
break; break;
@ -1095,9 +1095,9 @@ class Item{
} }
if(!$found){ if(!$found){
$tag->ench->{count($tag->ench) + 1} = new Compound("", [ $tag->ench->{count($tag->ench) + 1} = new CompoundTag("", [
"id" => new Short("id", $ench->getId()), "id" => new ShortTag("id", $ench->getId()),
"lvl" => new Short("lvl", $ench->getLevel()) "lvl" => new ShortTag("lvl", $ench->getLevel())
]); ]);
} }
@ -1131,7 +1131,7 @@ class Item{
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if(isset($tag->display)){ if(isset($tag->display)){
$tag = $tag->display; $tag = $tag->display;
if($tag instanceof Compound and isset($tag->Name) and $tag->Name instanceof String){ if($tag instanceof CompoundTag and isset($tag->Name) and $tag->Name instanceof StringTag){
return true; return true;
} }
} }
@ -1147,7 +1147,7 @@ class Item{
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if(isset($tag->display)){ if(isset($tag->display)){
$tag = $tag->display; $tag = $tag->display;
if($tag instanceof Compound and isset($tag->Name) and $tag->Name instanceof String){ if($tag instanceof CompoundTag and isset($tag->Name) and $tag->Name instanceof StringTag){
return $tag->Name->getValue(); return $tag->Name->getValue();
} }
} }
@ -1161,16 +1161,16 @@ class Item{
} }
if(!$this->hasCompoundTag()){ if(!$this->hasCompoundTag()){
$tag = new Compound("", []); $tag = new CompoundTag("", []);
}else{ }else{
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
} }
if(isset($tag->display) and $tag->display instanceof Compound){ if(isset($tag->display) and $tag->display instanceof CompoundTag){
$tag->display->Name = new String("Name", $name); $tag->display->Name = new StringTag("Name", $name);
}else{ }else{
$tag->display = new Compound("display", [ $tag->display = new CompoundTag("display", [
"Name" => new String("Name", $name) "Name" => new StringTag("Name", $name)
]); ]);
} }
@ -1183,7 +1183,7 @@ class Item{
} }
$tag = $this->getNamedTag(); $tag = $this->getNamedTag();
if(isset($tag->display) and $tag->display instanceof Compound){ if(isset($tag->display) and $tag->display instanceof CompoundTag){
unset($tag->display->Name); unset($tag->display->Name);
if($tag->display->getCount() === 0){ if($tag->display->getCount() === 0){
unset($tag->display); unset($tag->display);
@ -1213,7 +1213,7 @@ class Item{
return $this->cachedNBT = self::parseCompoundTag($this->tags); return $this->cachedNBT = self::parseCompoundTag($this->tags);
} }
public function setNamedTag(Compound $tag){ public function setNamedTag(CompoundTag $tag){
if($tag->getCount() === 0){ if($tag->getCount() === 0){
return $this->clearNamedTag(); return $this->clearNamedTag();
} }

View File

@ -25,11 +25,11 @@ use pocketmine\block\Block;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\Player; use pocketmine\Player;
class SpawnEgg extends Item{ class SpawnEgg extends Item{
@ -49,25 +49,25 @@ class SpawnEgg extends Item{
return false; return false;
} }
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
"Pos" => new Enum("Pos", [ "Pos" => new ListTag("Pos", [
new Double("", $block->getX() + 0.5), new DoubleTag("", $block->getX() + 0.5),
new Double("", $block->getY()), new DoubleTag("", $block->getY()),
new Double("", $block->getZ() + 0.5) new DoubleTag("", $block->getZ() + 0.5)
]), ]),
"Motion" => new Enum("Motion", [ "Motion" => new ListTag("Motion", [
new Double("", 0), new DoubleTag("", 0),
new Double("", 0), new DoubleTag("", 0),
new Double("", 0) new DoubleTag("", 0)
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new ListTag("Rotation", [
new Float("", lcg_value() * 360), new FloatTag("", lcg_value() * 360),
new Float("", 0) new FloatTag("", 0)
]), ]),
]); ]);
if($this->hasCustomName()){ if($this->hasCustomName()){
$nbt->CustomName = new String("CustomName", $this->getCustomName()); $nbt->CustomName = new StringTag("CustomName", $this->getCustomName());
} }
$entity = Entity::createEntity($this->meta, $chunk, $nbt); $entity = Entity::createEntity($this->meta, $chunk, $nbt);

View File

@ -24,7 +24,7 @@ namespace pocketmine\item;
use pocketmine\block\Block; use pocketmine\block\Block;
use pocketmine\entity\Entity; use pocketmine\entity\Entity;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
abstract class Tool extends Item{ abstract class Tool extends Item{
const TIER_WOODEN = 1; const TIER_WOODEN = 1;

View File

@ -32,11 +32,11 @@ use pocketmine\item\Item;
use pocketmine\math\AxisAlignedBB; use pocketmine\math\AxisAlignedBB;
use pocketmine\math\Math; use pocketmine\math\Math;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\ExplodePacket; use pocketmine\network\protocol\ExplodePacket;
@ -186,22 +186,22 @@ class Explosion{
foreach($this->affectedBlocks as $block){ foreach($this->affectedBlocks as $block){
if($block->getId() === Block::TNT){ if($block->getId() === Block::TNT){
$mot = (new Random())->nextSignedFloat() * M_PI * 2; $mot = (new Random())->nextSignedFloat() * M_PI * 2;
$tnt = Entity::createEntity("PrimedTNT", $this->level->getChunk($block->x >> 4, $block->z >> 4), new Compound("", [ $tnt = Entity::createEntity("PrimedTNT", $this->level->getChunk($block->x >> 4, $block->z >> 4), new CompoundTag("", [
"Pos" => new Enum("Pos", [ "Pos" => new ListTag("Pos", [
new Double("", $block->x + 0.5), new DoubleTag("", $block->x + 0.5),
new Double("", $block->y), new DoubleTag("", $block->y),
new Double("", $block->z + 0.5) new DoubleTag("", $block->z + 0.5)
]), ]),
"Motion" => new Enum("Motion", [ "Motion" => new ListTag("Motion", [
new Double("", -sin($mot) * 0.02), new DoubleTag("", -sin($mot) * 0.02),
new Double("", 0.2), new DoubleTag("", 0.2),
new Double("", -cos($mot) * 0.02) new DoubleTag("", -cos($mot) * 0.02)
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new ListTag("Rotation", [
new Float("", 0), new FloatTag("", 0),
new Float("", 0) new FloatTag("", 0)
]), ]),
"Fuse" => new Byte("Fuse", mt_rand(10, 30)) "Fuse" => new ByteTag("Fuse", mt_rand(10, 30))
])); ]));
$tnt->spawnToAll(); $tnt->spawnToAll();
}elseif(mt_rand(0, 100) < $yield){ }elseif(mt_rand(0, 100) < $yield){

View File

@ -81,13 +81,13 @@ use pocketmine\metadata\Metadatable;
use pocketmine\metadata\MetadataValue; use pocketmine\metadata\MetadataValue;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\DataPacket; use pocketmine\network\protocol\DataPacket;
use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\network\protocol\FullChunkDataPacket;
@ -1466,25 +1466,25 @@ class Level implements ChunkManager, Metadatable{
$itemTag->setName("Item"); $itemTag->setName("Item");
if($item->getId() > 0 and $item->getCount() > 0){ if($item->getId() > 0 and $item->getCount() > 0){
$itemEntity = Entity::createEntity("Item", $this->getChunk($source->getX() >> 4, $source->getZ() >> 4, true), new Compound("", [ $itemEntity = Entity::createEntity("Item", $this->getChunk($source->getX() >> 4, $source->getZ() >> 4, true), new CompoundTag("", [
"Pos" => new Enum("Pos", [ "Pos" => new ListTag("Pos", [
new Double("", $source->getX()), new DoubleTag("", $source->getX()),
new Double("", $source->getY()), new DoubleTag("", $source->getY()),
new Double("", $source->getZ()) new DoubleTag("", $source->getZ())
]), ]),
"Motion" => new Enum("Motion", [ "Motion" => new ListTag("Motion", [
new Double("", $motion->x), new DoubleTag("", $motion->x),
new Double("", $motion->y), new DoubleTag("", $motion->y),
new Double("", $motion->z) new DoubleTag("", $motion->z)
]), ]),
"Rotation" => new Enum("Rotation", [ "Rotation" => new ListTag("Rotation", [
new Float("", lcg_value() * 360), new FloatTag("", lcg_value() * 360),
new Float("", 0) new FloatTag("", 0)
]), ]),
"Health" => new Short("Health", 5), "Health" => new ShortTag("Health", 5),
"Item" => $itemTag, "Item" => $itemTag,
"PickupDelay" => new Short("PickupDelay", $delay) "PickupDelay" => new ShortTag("PickupDelay", $delay)
])); ]));
$itemEntity->spawnToAll(); $itemEntity->spawnToAll();
@ -1568,10 +1568,10 @@ class Level implements ChunkManager, Metadatable{
} }
$tag = $item->getNamedTagEntry("CanDestroy"); $tag = $item->getNamedTagEntry("CanDestroy");
if($tag instanceof Enum){ if($tag instanceof ListTag){
$canBreak = false; $canBreak = false;
foreach($tag as $v){ foreach($tag as $v){
if($v instanceof String){ if($v instanceof StringTag){
$entry = Item::fromString($v->getValue()); $entry = Item::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){ if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){
$canBreak = true; $canBreak = true;
@ -1730,10 +1730,10 @@ class Level implements ChunkManager, Metadatable{
} }
$tag = $item->getNamedTagEntry("CanPlaceOn"); $tag = $item->getNamedTagEntry("CanPlaceOn");
if($tag instanceof Enum){ if($tag instanceof ListTag){
$canPlace = false; $canPlace = false;
foreach($tag as $v){ foreach($tag as $v){
if($v instanceof String){ if($v instanceof StringTag){
$entry = Item::fromString($v->getValue()); $entry = Item::fromString($v->getValue());
if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){ if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){
$canPlace = true; $canPlace = true;
@ -1769,19 +1769,19 @@ class Level implements ChunkManager, Metadatable{
if($hand->getId() === Item::SIGN_POST or $hand->getId() === Item::WALL_SIGN){ if($hand->getId() === Item::SIGN_POST or $hand->getId() === Item::WALL_SIGN){
$nbt = new Compound("", [ $nbt = new CompoundTag("", [
"id" => new String("id", Tile::SIGN), "id" => new StringTag("id", Tile::SIGN),
"x" => new Int("x", $block->x), "x" => new IntTag("x", $block->x),
"y" => new Int("y", $block->y), "y" => new IntTag("y", $block->y),
"z" => new Int("z", $block->z), "z" => new IntTag("z", $block->z),
"Text1" => new String("Text1", ""), "Text1" => new StringTag("Text1", ""),
"Text2" => new String("Text2", ""), "Text2" => new StringTag("Text2", ""),
"Text3" => new String("Text3", ""), "Text3" => new StringTag("Text3", ""),
"Text4" => new String("Text4", "") "Text4" => new StringTag("Text4", "")
]); ]);
if($player !== null){ if($player !== null){
$nbt->Creator = new String("Creator", $player->getRawUniqueId()); $nbt->Creator = new StringTag("Creator", $player->getRawUniqueId());
} }
if($item->hasCustomBlockData()){ if($item->hasCustomBlockData()){

View File

@ -25,9 +25,9 @@ use pocketmine\level\format\FullChunk;
use pocketmine\level\format\mcregion\McRegion; use pocketmine\level\format\mcregion\McRegion;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\ByteArray; use pocketmine\nbt\tag\ByteArrayTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\network\protocol\FullChunkDataPacket;
use pocketmine\tile\Spawnable; use pocketmine\tile\Spawnable;
use pocketmine\utils\BinaryStream; use pocketmine\utils\BinaryStream;
@ -152,12 +152,12 @@ class Anvil extends McRegion{
} }
public static function createChunkSection($Y){ public static function createChunkSection($Y){
return new ChunkSection(new Compound("", [ return new ChunkSection(new CompoundTag("", [
"Y" => new Byte("Y", $Y), "Y" => new ByteTag("Y", $Y),
"Blocks" => new ByteArray("Blocks", str_repeat("\x00", 4096)), "Blocks" => new ByteArrayTag("Blocks", str_repeat("\x00", 4096)),
"Data" => new ByteArray("Data", str_repeat("\x00", 2048)), "Data" => new ByteArrayTag("Data", str_repeat("\x00", 2048)),
"SkyLight" => new ByteArray("SkyLight", str_repeat("\xff", 2048)), "SkyLight" => new ByteArrayTag("SkyLight", str_repeat("\xff", 2048)),
"BlockLight" => new ByteArray("BlockLight", str_repeat("\x00", 2048)) "BlockLight" => new ByteArrayTag("BlockLight", str_repeat("\x00", 2048))
])); ]));
} }

View File

@ -25,62 +25,62 @@ use pocketmine\level\format\generic\BaseChunk;
use pocketmine\level\format\generic\EmptyChunkSection; use pocketmine\level\format\generic\EmptyChunkSection;
use pocketmine\level\format\LevelProvider; use pocketmine\level\format\LevelProvider;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\ByteArray; use pocketmine\nbt\tag\ByteArrayTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\IntArray; use pocketmine\nbt\tag\IntArrayTag;
use pocketmine\nbt\tag\Long; use pocketmine\nbt\tag\LongTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\utils\Binary; use pocketmine\utils\Binary;
use pocketmine\utils\BinaryStream; use pocketmine\utils\BinaryStream;
class Chunk extends BaseChunk{ class Chunk extends BaseChunk{
/** @var Compound */ /** @var CompoundTag */
protected $nbt; protected $nbt;
public function __construct($level, Compound $nbt = null){ public function __construct($level, CompoundTag $nbt = null){
if($nbt === null){ if($nbt === null){
$this->provider = $level; $this->provider = $level;
$this->nbt = new Compound("Level", []); $this->nbt = new CompoundTag("Level", []);
return; return;
} }
$this->nbt = $nbt; $this->nbt = $nbt;
if(!isset($this->nbt->Entities) or !($this->nbt->Entities instanceof Enum)){ if(!isset($this->nbt->Entities) or !($this->nbt->Entities instanceof ListTag)){
$this->nbt->Entities = new Enum("Entities", []); $this->nbt->Entities = new ListTag("Entities", []);
$this->nbt->Entities->setTagType(NBT::TAG_Compound); $this->nbt->Entities->setTagType(NBT::TAG_Compound);
} }
if(!isset($this->nbt->TileEntities) or !($this->nbt->TileEntities instanceof Enum)){ if(!isset($this->nbt->TileEntities) or !($this->nbt->TileEntities instanceof ListTag)){
$this->nbt->TileEntities = new Enum("TileEntities", []); $this->nbt->TileEntities = new ListTag("TileEntities", []);
$this->nbt->TileEntities->setTagType(NBT::TAG_Compound); $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
} }
if(!isset($this->nbt->TileTicks) or !($this->nbt->TileTicks instanceof Enum)){ if(!isset($this->nbt->TileTicks) or !($this->nbt->TileTicks instanceof ListTag)){
$this->nbt->TileTicks = new Enum("TileTicks", []); $this->nbt->TileTicks = new ListTag("TileTicks", []);
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
} }
if(!isset($this->nbt->Sections) or !($this->nbt->Sections instanceof Enum)){ if(!isset($this->nbt->Sections) or !($this->nbt->Sections instanceof ListTag)){
$this->nbt->Sections = new Enum("Sections", []); $this->nbt->Sections = new ListTag("Sections", []);
$this->nbt->Sections->setTagType(NBT::TAG_Compound); $this->nbt->Sections->setTagType(NBT::TAG_Compound);
} }
if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){ if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArrayTag)){
$this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, 0)); $this->nbt->BiomeColors = new IntArrayTag("BiomeColors", array_fill(0, 256, 0));
} }
if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArray)){ if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArrayTag)){
$this->nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 0)); $this->nbt->HeightMap = new IntArrayTag("HeightMap", array_fill(0, 256, 0));
} }
$sections = []; $sections = [];
foreach($this->nbt->Sections as $section){ foreach($this->nbt->Sections as $section){
if($section instanceof Compound){ if($section instanceof CompoundTag){
$y = (int) $section["Y"]; $y = (int) $section["Y"];
if($y < 8){ if($y < 8){
$sections[$y] = new ChunkSection($section); $sections[$y] = new ChunkSection($section);
@ -95,8 +95,8 @@ class Chunk extends BaseChunk{
$extraData = []; $extraData = [];
if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArray)){ if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArrayTag)){
$this->nbt->ExtraData = new ByteArray("ExtraData", Binary::writeInt(0)); $this->nbt->ExtraData = new ByteArrayTag("ExtraData", Binary::writeInt(0));
}else{ }else{
$stream = new BinaryStream($this->nbt->ExtraData->getValue()); $stream = new BinaryStream($this->nbt->ExtraData->getValue());
$count = $stream->getInt(); $count = $stream->getInt();
@ -121,7 +121,7 @@ class Chunk extends BaseChunk{
} }
public function setLightPopulated($value = 1){ public function setLightPopulated($value = 1){
$this->nbt->LightPopulated = new Byte("LightPopulated", $value); $this->nbt->LightPopulated = new ByteTag("LightPopulated", $value);
$this->hasChanged = true; $this->hasChanged = true;
} }
@ -136,7 +136,7 @@ class Chunk extends BaseChunk{
* @param int $value * @param int $value
*/ */
public function setPopulated($value = 1){ public function setPopulated($value = 1){
$this->nbt->TerrainPopulated = new Byte("TerrainPopulated", $value); $this->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", $value);
$this->hasChanged = true; $this->hasChanged = true;
} }
@ -151,12 +151,12 @@ class Chunk extends BaseChunk{
* @param int $value * @param int $value
*/ */
public function setGenerated($value = 1){ public function setGenerated($value = 1){
$this->nbt->TerrainGenerated = new Byte("TerrainGenerated", $value); $this->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", $value);
$this->hasChanged = true; $this->hasChanged = true;
} }
/** /**
* @return Compound * @return CompoundTag
*/ */
public function getNBT(){ public function getNBT(){
return $this->nbt; return $this->nbt;
@ -175,7 +175,7 @@ class Chunk extends BaseChunk{
$nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE); $nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE);
$chunk = $nbt->getData(); $chunk = $nbt->getData();
if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){ if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){
return null; return null;
} }
@ -198,7 +198,7 @@ class Chunk extends BaseChunk{
$nbt->read($data); $nbt->read($data);
$chunk = $nbt->getData(); $chunk = $nbt->getData();
if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){ if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){
return null; return null;
} }
@ -211,27 +211,27 @@ class Chunk extends BaseChunk{
public function toFastBinary(){ public function toFastBinary(){
$nbt = clone $this->getNBT(); $nbt = clone $this->getNBT();
$nbt->xPos = new Int("xPos", $this->x); $nbt->xPos = new IntTag("xPos", $this->x);
$nbt->zPos = new Int("zPos", $this->z); $nbt->zPos = new IntTag("zPos", $this->z);
$nbt->Sections = new Enum("Sections", []); $nbt->Sections = new ListTag("Sections", []);
$nbt->Sections->setTagType(NBT::TAG_Compound); $nbt->Sections->setTagType(NBT::TAG_Compound);
foreach($this->getSections() as $section){ foreach($this->getSections() as $section){
if($section instanceof EmptyChunkSection){ if($section instanceof EmptyChunkSection){
continue; continue;
} }
$nbt->Sections[$section->getY()] = new Compound(null, [ $nbt->Sections[$section->getY()] = new CompoundTag(null, [
"Y" => new Byte("Y", $section->getY()), "Y" => new ByteTag("Y", $section->getY()),
"Blocks" => new ByteArray("Blocks", $section->getIdArray()), "Blocks" => new ByteArrayTag("Blocks", $section->getIdArray()),
"Data" => new ByteArray("Data", $section->getDataArray()), "Data" => new ByteArrayTag("Data", $section->getDataArray()),
"BlockLight" => new ByteArray("BlockLight", $section->getLightArray()), "BlockLight" => new ByteArrayTag("BlockLight", $section->getLightArray()),
"SkyLight" => new ByteArray("SkyLight", $section->getSkyLightArray()) "SkyLight" => new ByteArrayTag("SkyLight", $section->getSkyLightArray())
]); ]);
} }
$nbt->BiomeColors = new IntArray("BiomeColors", $this->getBiomeColorArray()); $nbt->BiomeColors = new IntArrayTag("BiomeColors", $this->getBiomeColorArray());
$nbt->HeightMap = new IntArray("HeightMap", $this->getHeightMapArray()); $nbt->HeightMap = new IntArrayTag("HeightMap", $this->getHeightMapArray());
$entities = []; $entities = [];
@ -242,7 +242,7 @@ class Chunk extends BaseChunk{
} }
} }
$nbt->Entities = new Enum("Entities", $entities); $nbt->Entities = new ListTag("Entities", $entities);
$nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->Entities->setTagType(NBT::TAG_Compound);
@ -252,7 +252,7 @@ class Chunk extends BaseChunk{
$tiles[] = $tile->namedtag; $tiles[] = $tile->namedtag;
} }
$nbt->TileEntities = new Enum("TileEntities", $tiles); $nbt->TileEntities = new ListTag("TileEntities", $tiles);
$nbt->TileEntities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound);
$extraData = new BinaryStream(); $extraData = new BinaryStream();
@ -262,11 +262,11 @@ class Chunk extends BaseChunk{
$extraData->putShort($value); $extraData->putShort($value);
} }
$nbt->ExtraData = new ByteArray("ExtraData", $extraData->getBuffer()); $nbt->ExtraData = new ByteArrayTag("ExtraData", $extraData->getBuffer());
$writer = new NBT(NBT::BIG_ENDIAN); $writer = new NBT(NBT::BIG_ENDIAN);
$nbt->setName("Level"); $nbt->setName("Level");
$writer->setData(new Compound("", ["Level" => $nbt])); $writer->setData(new CompoundTag("", ["Level" => $nbt]));
return $writer->write(); return $writer->write();
} }
@ -274,27 +274,27 @@ class Chunk extends BaseChunk{
public function toBinary(){ public function toBinary(){
$nbt = clone $this->getNBT(); $nbt = clone $this->getNBT();
$nbt->xPos = new Int("xPos", $this->x); $nbt->xPos = new IntTag("xPos", $this->x);
$nbt->zPos = new Int("zPos", $this->z); $nbt->zPos = new IntTag("zPos", $this->z);
$nbt->Sections = new Enum("Sections", []); $nbt->Sections = new ListTag("Sections", []);
$nbt->Sections->setTagType(NBT::TAG_Compound); $nbt->Sections->setTagType(NBT::TAG_Compound);
foreach($this->getSections() as $section){ foreach($this->getSections() as $section){
if($section instanceof EmptyChunkSection){ if($section instanceof EmptyChunkSection){
continue; continue;
} }
$nbt->Sections[$section->getY()] = new Compound(null, [ $nbt->Sections[$section->getY()] = new CompoundTag(null, [
"Y" => new Byte("Y", $section->getY()), "Y" => new ByteTag("Y", $section->getY()),
"Blocks" => new ByteArray("Blocks", $section->getIdArray()), "Blocks" => new ByteArrayTag("Blocks", $section->getIdArray()),
"Data" => new ByteArray("Data", $section->getDataArray()), "Data" => new ByteArrayTag("Data", $section->getDataArray()),
"BlockLight" => new ByteArray("BlockLight", $section->getLightArray()), "BlockLight" => new ByteArrayTag("BlockLight", $section->getLightArray()),
"SkyLight" => new ByteArray("SkyLight", $section->getSkyLightArray()) "SkyLight" => new ByteArrayTag("SkyLight", $section->getSkyLightArray())
]); ]);
} }
$nbt->BiomeColors = new IntArray("BiomeColors", $this->getBiomeColorArray()); $nbt->BiomeColors = new IntArrayTag("BiomeColors", $this->getBiomeColorArray());
$nbt->HeightMap = new IntArray("HeightMap", $this->getHeightMapArray()); $nbt->HeightMap = new IntArrayTag("HeightMap", $this->getHeightMapArray());
$entities = []; $entities = [];
@ -305,7 +305,7 @@ class Chunk extends BaseChunk{
} }
} }
$nbt->Entities = new Enum("Entities", $entities); $nbt->Entities = new ListTag("Entities", $entities);
$nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->Entities->setTagType(NBT::TAG_Compound);
@ -315,7 +315,7 @@ class Chunk extends BaseChunk{
$tiles[] = $tile->namedtag; $tiles[] = $tile->namedtag;
} }
$nbt->TileEntities = new Enum("TileEntities", $tiles); $nbt->TileEntities = new ListTag("TileEntities", $tiles);
$nbt->TileEntities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound);
$extraData = new BinaryStream(); $extraData = new BinaryStream();
@ -325,11 +325,11 @@ class Chunk extends BaseChunk{
$extraData->putShort($value); $extraData->putShort($value);
} }
$nbt->ExtraData = new ByteArray("ExtraData", $extraData->getBuffer()); $nbt->ExtraData = new ByteArrayTag("ExtraData", $extraData->getBuffer());
$writer = new NBT(NBT::BIG_ENDIAN); $writer = new NBT(NBT::BIG_ENDIAN);
$nbt->setName("Level"); $nbt->setName("Level");
$writer->setData(new Compound("", ["Level" => $nbt])); $writer->setData(new CompoundTag("", ["Level" => $nbt]));
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL); return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
} }
@ -354,11 +354,11 @@ class Chunk extends BaseChunk{
$chunk->heightMap = array_fill(0, 256, 0); $chunk->heightMap = array_fill(0, 256, 0);
$chunk->biomeColors = array_fill(0, 256, 0); $chunk->biomeColors = array_fill(0, 256, 0);
$chunk->nbt->V = new Byte("V", 1); $chunk->nbt->V = new ByteTag("V", 1);
$chunk->nbt->InhabitedTime = new Long("InhabitedTime", 0); $chunk->nbt->InhabitedTime = new LongTag("InhabitedTime", 0);
$chunk->nbt->TerrainGenerated = new Byte("TerrainGenerated", 0); $chunk->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", 0);
$chunk->nbt->TerrainPopulated = new Byte("TerrainPopulated", 0); $chunk->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", 0);
$chunk->nbt->LightPopulated = new Byte("LightPopulated", 0); $chunk->nbt->LightPopulated = new ByteTag("LightPopulated", 0);
return $chunk; return $chunk;
}catch(\Exception $e){ }catch(\Exception $e){

View File

@ -21,7 +21,7 @@
namespace pocketmine\level\format\anvil; namespace pocketmine\level\format\anvil;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
class ChunkSection implements \pocketmine\level\format\ChunkSection{ class ChunkSection implements \pocketmine\level\format\ChunkSection{
@ -31,7 +31,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
private $blockLight; private $blockLight;
private $skyLight; private $skyLight;
public function __construct(Compound $nbt){ public function __construct(CompoundTag $nbt){
$this->y = (int) $nbt["Y"]; $this->y = (int) $nbt["Y"];
$this->blocks = (string) $nbt["Blocks"]; $this->blocks = (string) $nbt["Blocks"];
$this->data = (string) $nbt["Data"]; $this->data = (string) $nbt["Data"];

View File

@ -24,7 +24,7 @@ namespace pocketmine\level\format\generic;
use pocketmine\level\format\Chunk; use pocketmine\level\format\Chunk;
use pocketmine\level\format\ChunkSection; use pocketmine\level\format\ChunkSection;
use pocketmine\level\format\LevelProvider; use pocketmine\level\format\LevelProvider;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\utils\Binary; use pocketmine\utils\Binary;
use pocketmine\utils\ChunkException; use pocketmine\utils\ChunkException;
@ -40,8 +40,8 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
* @param ChunkSection[] $sections * @param ChunkSection[] $sections
* @param int[] $biomeColors * @param int[] $biomeColors
* @param int[] $heightMap * @param int[] $heightMap
* @param Compound[] $entities * @param CompoundTag[] $entities
* @param Compound[] $tiles * @param CompoundTag[] $tiles
* *
* @throws ChunkException * @throws ChunkException
*/ */

View File

@ -27,7 +27,7 @@ use pocketmine\level\format\FullChunk;
use pocketmine\level\format\LevelProvider; use pocketmine\level\format\LevelProvider;
use pocketmine\level\generator\biome\Biome; use pocketmine\level\generator\biome\Biome;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\tile\Tile; use pocketmine\tile\Tile;
@ -82,8 +82,8 @@ abstract class BaseFullChunk implements FullChunk{
* @param string $blockLight * @param string $blockLight
* @param int[] $biomeColors * @param int[] $biomeColors
* @param int[] $heightMap * @param int[] $heightMap
* @param Compound[] $entities * @param CompoundTag[] $entities
* @param Compound[] $tiles * @param CompoundTag[] $tiles
*/ */
protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [], array $extraData = []){ protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [], array $extraData = []){
$this->provider = $provider; $this->provider = $provider;
@ -134,7 +134,7 @@ abstract class BaseFullChunk implements FullChunk{
if($this->NBTentities !== null){ if($this->NBTentities !== null){
$this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming(); $this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming();
foreach($this->NBTentities as $nbt){ foreach($this->NBTentities as $nbt){
if($nbt instanceof Compound){ if($nbt instanceof CompoundTag){
if(!isset($nbt->id)){ if(!isset($nbt->id)){
$this->setChanged(); $this->setChanged();
continue; continue;
@ -157,7 +157,7 @@ abstract class BaseFullChunk implements FullChunk{
$this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming(); $this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming();
foreach($this->NBTtiles as $nbt){ foreach($this->NBTtiles as $nbt){
if($nbt instanceof Compound){ if($nbt instanceof CompoundTag){
if(!isset($nbt->id)){ if(!isset($nbt->id)){
$changed = true; $changed = true;
continue; continue;

View File

@ -26,9 +26,9 @@ use pocketmine\level\generator\Generator;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\utils\LevelException; use pocketmine\utils\LevelException;
abstract class BaseLevelProvider implements LevelProvider{ abstract class BaseLevelProvider implements LevelProvider{
@ -36,7 +36,7 @@ abstract class BaseLevelProvider implements LevelProvider{
protected $level; protected $level;
/** @var string */ /** @var string */
protected $path; protected $path;
/** @var Compound */ /** @var CompoundTag */
protected $levelData; protected $levelData;
public function __construct(Level $level, $path){ public function __construct(Level $level, $path){
@ -48,18 +48,18 @@ abstract class BaseLevelProvider implements LevelProvider{
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->readCompressed(file_get_contents($this->getPath() . "level.dat")); $nbt->readCompressed(file_get_contents($this->getPath() . "level.dat"));
$levelData = $nbt->getData(); $levelData = $nbt->getData();
if($levelData->Data instanceof Compound){ if($levelData->Data instanceof CompoundTag){
$this->levelData = $levelData->Data; $this->levelData = $levelData->Data;
}else{ }else{
throw new LevelException("Invalid level.dat"); throw new LevelException("Invalid level.dat");
} }
if(!isset($this->levelData->generatorName)){ if(!isset($this->levelData->generatorName)){
$this->levelData->generatorName = new String("generatorName", Generator::getGenerator("DEFAULT")); $this->levelData->generatorName = new StringTag("generatorName", Generator::getGenerator("DEFAULT"));
} }
if(!isset($this->levelData->generatorOptions)){ if(!isset($this->levelData->generatorOptions)){
$this->levelData->generatorOptions = new String("generatorOptions", ""); $this->levelData->generatorOptions = new StringTag("generatorOptions", "");
} }
} }
@ -84,7 +84,7 @@ abstract class BaseLevelProvider implements LevelProvider{
} }
public function setTime($value){ public function setTime($value){
$this->levelData->Time = new Int("Time", (int) $value); $this->levelData->Time = new IntTag("Time", (int) $value);
} }
public function getSeed(){ public function getSeed(){
@ -92,7 +92,7 @@ abstract class BaseLevelProvider implements LevelProvider{
} }
public function setSeed($value){ public function setSeed($value){
$this->levelData->RandomSeed = new Int("RandomSeed", (int) $value); $this->levelData->RandomSeed = new IntTag("RandomSeed", (int) $value);
} }
public function getSpawn(){ public function getSpawn(){
@ -100,9 +100,9 @@ abstract class BaseLevelProvider implements LevelProvider{
} }
public function setSpawn(Vector3 $pos){ public function setSpawn(Vector3 $pos){
$this->levelData->SpawnX = new Int("SpawnX", (int) $pos->x); $this->levelData->SpawnX = new IntTag("SpawnX", (int) $pos->x);
$this->levelData->SpawnY = new Int("SpawnY", (int) $pos->y); $this->levelData->SpawnY = new IntTag("SpawnY", (int) $pos->y);
$this->levelData->SpawnZ = new Int("SpawnZ", (int) $pos->z); $this->levelData->SpawnZ = new IntTag("SpawnZ", (int) $pos->z);
} }
public function doGarbageCollection(){ public function doGarbageCollection(){
@ -110,7 +110,7 @@ abstract class BaseLevelProvider implements LevelProvider{
} }
/** /**
* @return Compound * @return CompoundTag
*/ */
public function getLevelData(){ public function getLevelData(){
return $this->levelData; return $this->levelData;
@ -118,7 +118,7 @@ abstract class BaseLevelProvider implements LevelProvider{
public function saveLevelData(){ public function saveLevelData(){
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->setData(new Compound("", [ $nbt->setData(new CompoundTag("", [
"Data" => $this->levelData "Data" => $this->levelData
])); ]));
$buffer = $nbt->writeCompressed(); $buffer = $nbt->writeCompressed();

View File

@ -26,11 +26,11 @@ use pocketmine\level\format\generic\BaseLevelProvider;
use pocketmine\level\generator\Generator; use pocketmine\level\generator\Generator;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\Long; use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\tile\Spawnable; use pocketmine\tile\Spawnable;
use pocketmine\utils\Binary; use pocketmine\utils\Binary;
use pocketmine\utils\BinaryStream; use pocketmine\utils\BinaryStream;
@ -62,18 +62,18 @@ class LevelDB extends BaseLevelProvider{
$nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->read(substr(file_get_contents($this->getPath() . "level.dat"), 8)); $nbt->read(substr(file_get_contents($this->getPath() . "level.dat"), 8));
$levelData = $nbt->getData(); $levelData = $nbt->getData();
if($levelData instanceof Compound){ if($levelData instanceof CompoundTag){
$this->levelData = $levelData; $this->levelData = $levelData;
}else{ }else{
throw new LevelException("Invalid level.dat"); throw new LevelException("Invalid level.dat");
} }
if(!isset($this->levelData->generatorName)){ if(!isset($this->levelData->generatorName)){
$this->levelData->generatorName = new String("generatorName", Generator::getGenerator("DEFAULT")); $this->levelData->generatorName = new StringTag("generatorName", Generator::getGenerator("DEFAULT"));
} }
if(!isset($this->levelData->generatorOptions)){ if(!isset($this->levelData->generatorOptions)){
$this->levelData->generatorOptions = new String("generatorOptions", ""); $this->levelData->generatorOptions = new StringTag("generatorOptions", "");
} }
$this->db = new \LevelDB($this->path . "/db", [ $this->db = new \LevelDB($this->path . "/db", [
@ -105,24 +105,24 @@ class LevelDB extends BaseLevelProvider{
mkdir($path . "/db", 0777, true); mkdir($path . "/db", 0777, true);
} }
//TODO, add extra details //TODO, add extra details
$levelData = new Compound("", [ $levelData = new CompoundTag("", [
"hardcore" => new Byte("hardcore", 0), "hardcore" => new ByteTag("hardcore", 0),
"initialized" => new Byte("initialized", 1), "initialized" => new ByteTag("initialized", 1),
"GameType" => new Int("GameType", 0), "GameType" => new IntTag("GameType", 0),
"generatorVersion" => new Int("generatorVersion", 1), //2 in MCPE "generatorVersion" => new IntTag("generatorVersion", 1), //2 in MCPE
"SpawnX" => new Int("SpawnX", 128), "SpawnX" => new IntTag("SpawnX", 128),
"SpawnY" => new Int("SpawnY", 70), "SpawnY" => new IntTag("SpawnY", 70),
"SpawnZ" => new Int("SpawnZ", 128), "SpawnZ" => new IntTag("SpawnZ", 128),
"version" => new Int("version", 19133), "version" => new IntTag("version", 19133),
"DayTime" => new Int("DayTime", 0), "DayTime" => new IntTag("DayTime", 0),
"LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), "LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000),
"RandomSeed" => new Long("RandomSeed", $seed), "RandomSeed" => new LongTag("RandomSeed", $seed),
"SizeOnDisk" => new Long("SizeOnDisk", 0), "SizeOnDisk" => new LongTag("SizeOnDisk", 0),
"Time" => new Long("Time", 0), "Time" => new LongTag("Time", 0),
"generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), "generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)),
"generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), "generatorOptions" => new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""),
"LevelName" => new String("LevelName", $name), "LevelName" => new StringTag("LevelName", $name),
"GameRules" => new Compound("GameRules", []) "GameRules" => new CompoundTag("GameRules", [])
]); ]);
$nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt = new NBT(NBT::LITTLE_ENDIAN);
$nbt->setData($levelData); $nbt->setData($levelData);

View File

@ -24,74 +24,74 @@ namespace pocketmine\level\format\mcregion;
use pocketmine\level\format\generic\BaseFullChunk; use pocketmine\level\format\generic\BaseFullChunk;
use pocketmine\level\format\LevelProvider; use pocketmine\level\format\LevelProvider;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\ByteArray; use pocketmine\nbt\tag\ByteArrayTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\IntArray; use pocketmine\nbt\tag\IntArrayTag;
use pocketmine\nbt\tag\Long; use pocketmine\nbt\tag\LongTag;
use pocketmine\Player; use pocketmine\Player;
use pocketmine\utils\Binary; use pocketmine\utils\Binary;
use pocketmine\utils\BinaryStream; use pocketmine\utils\BinaryStream;
class Chunk extends BaseFullChunk{ class Chunk extends BaseFullChunk{
/** @var Compound */ /** @var CompoundTag */
protected $nbt; protected $nbt;
public function __construct($level, Compound $nbt = null){ public function __construct($level, CompoundTag $nbt = null){
if($nbt === null){ if($nbt === null){
$this->provider = $level; $this->provider = $level;
$this->nbt = new Compound("Level", []); $this->nbt = new CompoundTag("Level", []);
return; return;
} }
$this->nbt = $nbt; $this->nbt = $nbt;
if(isset($this->nbt->Entities) and $this->nbt->Entities instanceof Enum){ if(isset($this->nbt->Entities) and $this->nbt->Entities instanceof ListTag){
$this->nbt->Entities->setTagType(NBT::TAG_Compound); $this->nbt->Entities->setTagType(NBT::TAG_Compound);
}else{ }else{
$this->nbt->Entities = new Enum("Entities", []); $this->nbt->Entities = new ListTag("Entities", []);
$this->nbt->Entities->setTagType(NBT::TAG_Compound); $this->nbt->Entities->setTagType(NBT::TAG_Compound);
} }
if(isset($this->nbt->TileEntities) and $this->nbt->TileEntities instanceof Enum){ if(isset($this->nbt->TileEntities) and $this->nbt->TileEntities instanceof ListTag){
$this->nbt->TileEntities->setTagType(NBT::TAG_Compound); $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
}else{ }else{
$this->nbt->TileEntities = new Enum("TileEntities", []); $this->nbt->TileEntities = new ListTag("TileEntities", []);
$this->nbt->TileEntities->setTagType(NBT::TAG_Compound); $this->nbt->TileEntities->setTagType(NBT::TAG_Compound);
} }
if(isset($this->nbt->TileTicks) and $this->nbt->TileTicks instanceof Enum){ if(isset($this->nbt->TileTicks) and $this->nbt->TileTicks instanceof ListTag){
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
}else{ }else{
$this->nbt->TileTicks = new Enum("TileTicks", []); $this->nbt->TileTicks = new ListTag("TileTicks", []);
$this->nbt->TileTicks->setTagType(NBT::TAG_Compound); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound);
} }
if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){ if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArrayTag)){
$this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, 0)); $this->nbt->BiomeColors = new IntArrayTag("BiomeColors", array_fill(0, 256, 0));
} }
if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArray)){ if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArrayTag)){
$this->nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 0)); $this->nbt->HeightMap = new IntArrayTag("HeightMap", array_fill(0, 256, 0));
} }
if(!isset($this->nbt->Blocks)){ if(!isset($this->nbt->Blocks)){
$this->nbt->Blocks = new ByteArray("Blocks", str_repeat("\x00", 32768)); $this->nbt->Blocks = new ByteArrayTag("Blocks", str_repeat("\x00", 32768));
} }
if(!isset($this->nbt->Data)){ if(!isset($this->nbt->Data)){
$this->nbt->Data = new ByteArray("Data", $half = str_repeat("\x00", 16384)); $this->nbt->Data = new ByteArrayTag("Data", $half = str_repeat("\x00", 16384));
$this->nbt->SkyLight = new ByteArray("SkyLight", $half); $this->nbt->SkyLight = new ByteArrayTag("SkyLight", $half);
$this->nbt->BlockLight = new ByteArray("BlockLight", $half); $this->nbt->BlockLight = new ByteArrayTag("BlockLight", $half);
} }
$extraData = []; $extraData = [];
if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArray)){ if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArrayTag)){
$this->nbt->ExtraData = new ByteArray("ExtraData", Binary::writeInt(0)); $this->nbt->ExtraData = new ByteArrayTag("ExtraData", Binary::writeInt(0));
}else{ }else{
$stream = new BinaryStream($this->nbt->ExtraData->getValue()); $stream = new BinaryStream($this->nbt->ExtraData->getValue());
$count = $stream->getInt(); $count = $stream->getInt();
@ -258,7 +258,7 @@ class Chunk extends BaseFullChunk{
} }
public function setLightPopulated($value = 1){ public function setLightPopulated($value = 1){
$this->nbt->LightPopulated = new Byte("LightPopulated", $value ? 1 : 0); $this->nbt->LightPopulated = new ByteTag("LightPopulated", $value ? 1 : 0);
$this->hasChanged = true; $this->hasChanged = true;
} }
@ -273,7 +273,7 @@ class Chunk extends BaseFullChunk{
* @param int $value * @param int $value
*/ */
public function setPopulated($value = 1){ public function setPopulated($value = 1){
$this->nbt->TerrainPopulated = new Byte("TerrainPopulated", $value ? 1 : 0); $this->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", $value ? 1 : 0);
$this->hasChanged = true; $this->hasChanged = true;
} }
@ -293,7 +293,7 @@ class Chunk extends BaseFullChunk{
* @param int $value * @param int $value
*/ */
public function setGenerated($value = 1){ public function setGenerated($value = 1){
$this->nbt->TerrainGenerated = new Byte("TerrainGenerated", (int) $value); $this->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", (int) $value);
$this->hasChanged = true; $this->hasChanged = true;
} }
@ -310,7 +310,7 @@ class Chunk extends BaseFullChunk{
$nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE); $nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE);
$chunk = $nbt->getData(); $chunk = $nbt->getData();
if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){ if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){
return null; return null;
} }
@ -348,9 +348,9 @@ class Chunk extends BaseFullChunk{
$flags = ord($data{$offset++}); $flags = ord($data{$offset++});
$chunk->nbt->TerrainGenerated = new Byte("TerrainGenerated", $flags & 0b1); $chunk->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", $flags & 0b1);
$chunk->nbt->TerrainPopulated = new Byte("TerrainPopulated", ($flags >> 1) & 0b1); $chunk->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", ($flags >> 1) & 0b1);
$chunk->nbt->LightPopulated = new Byte("LightPopulated", ($flags >> 2) & 0b1); $chunk->nbt->LightPopulated = new ByteTag("LightPopulated", ($flags >> 2) & 0b1);
return $chunk; return $chunk;
}catch(\Exception $e){ }catch(\Exception $e){
@ -374,18 +374,18 @@ class Chunk extends BaseFullChunk{
public function toBinary(){ public function toBinary(){
$nbt = clone $this->getNBT(); $nbt = clone $this->getNBT();
$nbt->xPos = new Int("xPos", $this->x); $nbt->xPos = new IntTag("xPos", $this->x);
$nbt->zPos = new Int("zPos", $this->z); $nbt->zPos = new IntTag("zPos", $this->z);
if($this->isGenerated()){ if($this->isGenerated()){
$nbt->Blocks = new ByteArray("Blocks", $this->getBlockIdArray()); $nbt->Blocks = new ByteArrayTag("Blocks", $this->getBlockIdArray());
$nbt->Data = new ByteArray("Data", $this->getBlockDataArray()); $nbt->Data = new ByteArrayTag("Data", $this->getBlockDataArray());
$nbt->SkyLight = new ByteArray("SkyLight", $this->getBlockSkyLightArray()); $nbt->SkyLight = new ByteArrayTag("SkyLight", $this->getBlockSkyLightArray());
$nbt->BlockLight = new ByteArray("BlockLight", $this->getBlockLightArray()); $nbt->BlockLight = new ByteArrayTag("BlockLight", $this->getBlockLightArray());
$nbt->BiomeColors = new IntArray("BiomeColors", $this->getBiomeColorArray()); $nbt->BiomeColors = new IntArrayTag("BiomeColors", $this->getBiomeColorArray());
$nbt->HeightMap = new IntArray("HeightMap", $this->getHeightMapArray()); $nbt->HeightMap = new IntArrayTag("HeightMap", $this->getHeightMapArray());
} }
$entities = []; $entities = [];
@ -397,7 +397,7 @@ class Chunk extends BaseFullChunk{
} }
} }
$nbt->Entities = new Enum("Entities", $entities); $nbt->Entities = new ListTag("Entities", $entities);
$nbt->Entities->setTagType(NBT::TAG_Compound); $nbt->Entities->setTagType(NBT::TAG_Compound);
@ -407,7 +407,7 @@ class Chunk extends BaseFullChunk{
$tiles[] = $tile->namedtag; $tiles[] = $tile->namedtag;
} }
$nbt->TileEntities = new Enum("TileEntities", $tiles); $nbt->TileEntities = new ListTag("TileEntities", $tiles);
$nbt->TileEntities->setTagType(NBT::TAG_Compound); $nbt->TileEntities->setTagType(NBT::TAG_Compound);
$extraData = new BinaryStream(); $extraData = new BinaryStream();
@ -417,17 +417,17 @@ class Chunk extends BaseFullChunk{
$extraData->putShort($value); $extraData->putShort($value);
} }
$nbt->ExtraData = new ByteArray("ExtraData", $extraData->getBuffer()); $nbt->ExtraData = new ByteArrayTag("ExtraData", $extraData->getBuffer());
$writer = new NBT(NBT::BIG_ENDIAN); $writer = new NBT(NBT::BIG_ENDIAN);
$nbt->setName("Level"); $nbt->setName("Level");
$writer->setData(new Compound("", ["Level" => $nbt])); $writer->setData(new CompoundTag("", ["Level" => $nbt]));
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL); return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
} }
/** /**
* @return Compound * @return CompoundTag
*/ */
public function getNBT(){ public function getNBT(){
return $this->nbt; return $this->nbt;
@ -454,11 +454,11 @@ class Chunk extends BaseFullChunk{
$chunk->heightMap = array_fill(0, 256, 0); $chunk->heightMap = array_fill(0, 256, 0);
$chunk->biomeColors = array_fill(0, 256, 0); $chunk->biomeColors = array_fill(0, 256, 0);
$chunk->nbt->V = new Byte("V", 1); $chunk->nbt->V = new ByteTag("V", 1);
$chunk->nbt->InhabitedTime = new Long("InhabitedTime", 0); $chunk->nbt->InhabitedTime = new LongTag("InhabitedTime", 0);
$chunk->nbt->TerrainGenerated = new Byte("TerrainGenerated", 0); $chunk->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", 0);
$chunk->nbt->TerrainPopulated = new Byte("TerrainPopulated", 0); $chunk->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", 0);
$chunk->nbt->LightPopulated = new Byte("LightPopulated", 0); $chunk->nbt->LightPopulated = new ByteTag("LightPopulated", 0);
return $chunk; return $chunk;
}catch(\Exception $e){ }catch(\Exception $e){

View File

@ -26,11 +26,11 @@ use pocketmine\level\format\generic\BaseLevelProvider;
use pocketmine\level\generator\Generator; use pocketmine\level\generator\Generator;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\Long; use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\tile\Spawnable; use pocketmine\tile\Spawnable;
use pocketmine\utils\BinaryStream; use pocketmine\utils\BinaryStream;
@ -81,27 +81,27 @@ class McRegion extends BaseLevelProvider{
mkdir($path . "/region", 0777); mkdir($path . "/region", 0777);
} }
//TODO, add extra details //TODO, add extra details
$levelData = new Compound("Data", [ $levelData = new CompoundTag("Data", [
"hardcore" => new Byte("hardcore", 0), "hardcore" => new ByteTag("hardcore", 0),
"initialized" => new Byte("initialized", 1), "initialized" => new ByteTag("initialized", 1),
"GameType" => new Int("GameType", 0), "GameType" => new IntTag("GameType", 0),
"generatorVersion" => new Int("generatorVersion", 1), //2 in MCPE "generatorVersion" => new IntTag("generatorVersion", 1), //2 in MCPE
"SpawnX" => new Int("SpawnX", 128), "SpawnX" => new IntTag("SpawnX", 128),
"SpawnY" => new Int("SpawnY", 70), "SpawnY" => new IntTag("SpawnY", 70),
"SpawnZ" => new Int("SpawnZ", 128), "SpawnZ" => new IntTag("SpawnZ", 128),
"version" => new Int("version", 19133), "version" => new IntTag("version", 19133),
"DayTime" => new Int("DayTime", 0), "DayTime" => new IntTag("DayTime", 0),
"LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), "LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000),
"RandomSeed" => new Long("RandomSeed", $seed), "RandomSeed" => new LongTag("RandomSeed", $seed),
"SizeOnDisk" => new Long("SizeOnDisk", 0), "SizeOnDisk" => new LongTag("SizeOnDisk", 0),
"Time" => new Long("Time", 0), "Time" => new LongTag("Time", 0),
"generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), "generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)),
"generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), "generatorOptions" => new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""),
"LevelName" => new String("LevelName", $name), "LevelName" => new StringTag("LevelName", $name),
"GameRules" => new Compound("GameRules", []) "GameRules" => new CompoundTag("GameRules", [])
]); ]);
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->setData(new Compound("", [ $nbt->setData(new CompoundTag("", [
"Data" => $levelData "Data" => $levelData
])); ]));
$buffer = $nbt->writeCompressed(); $buffer = $nbt->writeCompressed();

View File

@ -25,19 +25,19 @@
namespace pocketmine\nbt; namespace pocketmine\nbt;
use pocketmine\item\Item; use pocketmine\item\Item;
use pocketmine\nbt\tag\Byte; use pocketmine\nbt\tag\ByteTag;
use pocketmine\nbt\tag\ByteArray; use pocketmine\nbt\tag\ByteArrayTag;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Double; use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\End; use pocketmine\nbt\tag\EndTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Float; use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\IntArray; use pocketmine\nbt\tag\IntArrayTag;
use pocketmine\nbt\tag\Long; use pocketmine\nbt\tag\LongTag;
use pocketmine\nbt\tag\NamedTAG; use pocketmine\nbt\tag\NamedTAG;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\nbt\tag\Tag; use pocketmine\nbt\tag\Tag;
use pocketmine\utils\Utils; use pocketmine\utils\Utils;
@ -65,7 +65,7 @@ class NBT{
const TAG_Double = 6; const TAG_Double = 6;
const TAG_ByteArray = 7; const TAG_ByteArray = 7;
const TAG_String = 8; const TAG_String = 8;
const TAG_Enum = 9; const TAG_List = 9;
const TAG_Compound = 10; const TAG_Compound = 10;
const TAG_IntArray = 11; const TAG_IntArray = 11;
@ -78,17 +78,17 @@ class NBT{
/** /**
* @param Item $item * @param Item $item
* @param int $slot * @param int $slot
* @return Compound * @return CompoundTag
*/ */
public static function putItemHelper(Item $item, $slot = null){ public static function putItemHelper(Item $item, $slot = null){
$tag = new Compound(null, [ $tag = new CompoundTag(null, [
"id" => new Short("id", $item->getId()), "id" => new ShortTag("id", $item->getId()),
"Count" => new Byte("Count", $item->getCount()), "Count" => new ByteTag("Count", $item->getCount()),
"Damage" => new Short("Damage", $item->getDamage()) "Damage" => new ShortTag("Damage", $item->getDamage())
]); ]);
if($slot !== null){ if($slot !== null){
$tag->Slot = new Byte("Slot", (int) $slot); $tag->Slot = new ByteTag("Slot", (int) $slot);
} }
if($item->hasCompoundTag()){ if($item->hasCompoundTag()){
@ -100,24 +100,24 @@ class NBT{
} }
/** /**
* @param Compound $tag * @param CompoundTag $tag
* @return Item * @return Item
*/ */
public static function getItemHelper(Compound $tag){ public static function getItemHelper(CompoundTag $tag){
if(!isset($tag->id) or !isset($tag->Count)){ if(!isset($tag->id) or !isset($tag->Count)){
return Item::get(0); return Item::get(0);
} }
$item = Item::get($tag->id->getValue(), !isset($tag->Damage) ? 0 : $tag->Damage->getValue(), $tag->Count->getValue()); $item = Item::get($tag->id->getValue(), !isset($tag->Damage) ? 0 : $tag->Damage->getValue(), $tag->Count->getValue());
if(isset($tag->tag) and $tag->tag instanceof Compound){ if(isset($tag->tag) and $tag->tag instanceof CompoundTag){
$item->setNamedTag($tag->tag); $item->setNamedTag($tag->tag);
} }
return $item; return $item;
} }
public static function matchList(Enum $tag1, Enum $tag2){ public static function matchList(ListTag $tag1, ListTag $tag2){
if($tag1->getName() !== $tag2->getName() or $tag1->getCount() !== $tag2->getCount()){ if($tag1->getName() !== $tag2->getName() or $tag1->getCount() !== $tag2->getCount()){
return false; return false;
} }
@ -131,11 +131,11 @@ class NBT{
return false; return false;
} }
if($v instanceof Compound){ if($v instanceof CompoundTag){
if(!self::matchTree($v, $tag2->{$k})){ if(!self::matchTree($v, $tag2->{$k})){
return false; return false;
} }
}elseif($v instanceof Enum){ }elseif($v instanceof ListTag){
if(!self::matchList($v, $tag2->{$k})){ if(!self::matchList($v, $tag2->{$k})){
return false; return false;
} }
@ -149,7 +149,7 @@ class NBT{
return true; return true;
} }
public static function matchTree(Compound $tag1, Compound $tag2){ public static function matchTree(CompoundTag $tag1, CompoundTag $tag2){
if($tag1->getName() !== $tag2->getName() or $tag1->getCount() !== $tag2->getCount()){ if($tag1->getName() !== $tag2->getName() or $tag1->getCount() !== $tag2->getCount()){
return false; return false;
} }
@ -163,11 +163,11 @@ class NBT{
return false; return false;
} }
if($v instanceof Compound){ if($v instanceof CompoundTag){
if(!self::matchTree($v, $tag2->{$k})){ if(!self::matchTree($v, $tag2->{$k})){
return false; return false;
} }
}elseif($v instanceof Enum){ }elseif($v instanceof ListTag){
if(!self::matchList($v, $tag2->{$k})){ if(!self::matchList($v, $tag2->{$k})){
return false; return false;
} }
@ -188,7 +188,7 @@ class NBT{
if($c === "{"){ if($c === "{"){
++$offset; ++$offset;
$data = self::parseCompound($data, $offset); $data = self::parseCompound($data, $offset);
return new Compound("", $data); return new CompoundTag("", $data);
}elseif($c !== " " and $c !== "\r" and $c !== "\n" and $c !== "\t"){ }elseif($c !== " " and $c !== "\r" and $c !== "\n" and $c !== "\t"){
throw new \Exception("Syntax error: unexpected '$c' at offset $offset"); throw new \Exception("Syntax error: unexpected '$c' at offset $offset");
} }
@ -218,37 +218,37 @@ class NBT{
switch($type){ switch($type){
case NBT::TAG_Byte: case NBT::TAG_Byte:
$data[$key] = new Byte($key, $value); $data[$key] = new ByteTag($key, $value);
break; break;
case NBT::TAG_Short: case NBT::TAG_Short:
$data[$key] = new Short($key, $value); $data[$key] = new ShortTag($key, $value);
break; break;
case NBT::TAG_Int: case NBT::TAG_Int:
$data[$key] = new Int($key, $value); $data[$key] = new IntTag($key, $value);
break; break;
case NBT::TAG_Long: case NBT::TAG_Long:
$data[$key] = new Long($key, $value); $data[$key] = new LongTag($key, $value);
break; break;
case NBT::TAG_Float: case NBT::TAG_Float:
$data[$key] = new Float($key, $value); $data[$key] = new FloatTag($key, $value);
break; break;
case NBT::TAG_Double: case NBT::TAG_Double:
$data[$key] = new Double($key, $value); $data[$key] = new DoubleTag($key, $value);
break; break;
case NBT::TAG_ByteArray: case NBT::TAG_ByteArray:
$data[$key] = new ByteArray($key, $value); $data[$key] = new ByteArrayTag($key, $value);
break; break;
case NBT::TAG_String: case NBT::TAG_String:
$data[$key] = new Byte($key, $value); $data[$key] = new ByteTag($key, $value);
break; break;
case NBT::TAG_Enum: case NBT::TAG_List:
$data[$key] = new Enum($key, $value); $data[$key] = new ListTag($key, $value);
break; break;
case NBT::TAG_Compound: case NBT::TAG_Compound:
$data[$key] = new Compound($key, $value); $data[$key] = new CompoundTag($key, $value);
break; break;
case NBT::TAG_IntArray: case NBT::TAG_IntArray:
$data[$key] = new IntArray($key, $value); $data[$key] = new IntArrayTag($key, $value);
break; break;
} }
@ -276,37 +276,37 @@ class NBT{
switch($type){ switch($type){
case NBT::TAG_Byte: case NBT::TAG_Byte:
$data[$key] = new Byte($key, $value); $data[$key] = new ByteTag($key, $value);
break; break;
case NBT::TAG_Short: case NBT::TAG_Short:
$data[$key] = new Short($key, $value); $data[$key] = new ShortTag($key, $value);
break; break;
case NBT::TAG_Int: case NBT::TAG_Int:
$data[$key] = new Int($key, $value); $data[$key] = new IntTag($key, $value);
break; break;
case NBT::TAG_Long: case NBT::TAG_Long:
$data[$key] = new Long($key, $value); $data[$key] = new LongTag($key, $value);
break; break;
case NBT::TAG_Float: case NBT::TAG_Float:
$data[$key] = new Float($key, $value); $data[$key] = new FloatTag($key, $value);
break; break;
case NBT::TAG_Double: case NBT::TAG_Double:
$data[$key] = new Double($key, $value); $data[$key] = new DoubleTag($key, $value);
break; break;
case NBT::TAG_ByteArray: case NBT::TAG_ByteArray:
$data[$key] = new ByteArray($key, $value); $data[$key] = new ByteArrayTag($key, $value);
break; break;
case NBT::TAG_String: case NBT::TAG_String:
$data[$key] = new String($key, $value); $data[$key] = new StringTag($key, $value);
break; break;
case NBT::TAG_Enum: case NBT::TAG_List:
$data[$key] = new Enum($key, $value); $data[$key] = new ListTag($key, $value);
break; break;
case NBT::TAG_Compound: case NBT::TAG_Compound:
$data[$key] = new Compound($key, $value); $data[$key] = new CompoundTag($key, $value);
break; break;
case NBT::TAG_IntArray: case NBT::TAG_IntArray:
$data[$key] = new IntArray($key, $value); $data[$key] = new IntArrayTag($key, $value);
break; break;
} }
} }
@ -351,7 +351,7 @@ class NBT{
} }
++$offset; ++$offset;
$value = self::parseList($data, $offset); $value = self::parseList($data, $offset);
$type = self::TAG_Enum; $type = self::TAG_List;
break; break;
}else{ }else{
$value .= $c; $value .= $c;
@ -480,7 +480,7 @@ class NBT{
$this->offset = 0; $this->offset = 0;
$this->buffer = ""; $this->buffer = "";
if($this->data instanceof Compound){ if($this->data instanceof CompoundTag){
$this->writeTag($this->data); $this->writeTag($this->data);
return $this->buffer; return $this->buffer;
@ -505,53 +505,53 @@ class NBT{
public function readTag(){ public function readTag(){
switch($this->getByte()){ switch($this->getByte()){
case NBT::TAG_Byte: case NBT::TAG_Byte:
$tag = new Byte($this->getString()); $tag = new ByteTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_Short: case NBT::TAG_Short:
$tag = new Short($this->getString()); $tag = new ShortTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_Int: case NBT::TAG_Int:
$tag = new Int($this->getString()); $tag = new IntTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_Long: case NBT::TAG_Long:
$tag = new Long($this->getString()); $tag = new LongTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_Float: case NBT::TAG_Float:
$tag = new Float($this->getString()); $tag = new FloatTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_Double: case NBT::TAG_Double:
$tag = new Double($this->getString()); $tag = new DoubleTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_ByteArray: case NBT::TAG_ByteArray:
$tag = new ByteArray($this->getString()); $tag = new ByteArrayTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_String: case NBT::TAG_String:
$tag = new String($this->getString()); $tag = new StringTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_Enum: case NBT::TAG_List:
$tag = new Enum($this->getString()); $tag = new ListTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_Compound: case NBT::TAG_Compound:
$tag = new Compound($this->getString()); $tag = new CompoundTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_IntArray: case NBT::TAG_IntArray:
$tag = new IntArray($this->getString()); $tag = new IntArrayTag($this->getString());
$tag->read($this); $tag->read($this);
break; break;
case NBT::TAG_End: //No named tag case NBT::TAG_End: //No named tag
default: default:
$tag = new End; $tag = new EndTag;
break; break;
} }
return $tag; return $tag;
@ -628,9 +628,9 @@ class NBT{
} }
private static function toArray(array &$data, Tag $tag){ private static function toArray(array &$data, Tag $tag){
/** @var Compound[]|Enum[]|IntArray[] $tag */ /** @var CompoundTag[]|ListTag[]|IntArrayTag[] $tag */
foreach($tag as $key => $value){ foreach($tag as $key => $value){
if($value instanceof Compound or $value instanceof Enum or $value instanceof IntArray){ if($value instanceof CompoundTag or $value instanceof ListTag or $value instanceof IntArrayTag){
$data[$key] = []; $data[$key] = [];
self::toArray($data[$key], $value); self::toArray($data[$key], $value);
}else{ }else{
@ -641,13 +641,13 @@ class NBT{
public static function fromArrayGuesser($key, $value){ public static function fromArrayGuesser($key, $value){
if(is_int($value)){ if(is_int($value)){
return new Int($key, $value); return new IntTag($key, $value);
}elseif(is_float($value)){ }elseif(is_float($value)){
return new Float($key, $value); return new FloatTag($key, $value);
}elseif(is_string($value)){ }elseif(is_string($value)){
return new String($key, $value); return new StringTag($key, $value);
}elseif(is_bool($value)){ }elseif(is_bool($value)){
return new Byte($key, $value ? 1 : 0); return new ByteTag($key, $value ? 1 : 0);
} }
return null; return null;
@ -666,7 +666,7 @@ class NBT{
$isIntArray = false; $isIntArray = false;
} }
} }
$tag{$key} = $isNumeric ? ($isIntArray ? new IntArray($key, []) : new Enum($key, [])) : new Compound($key, []); $tag{$key} = $isNumeric ? ($isIntArray ? new IntArrayTag($key, []) : new ListTag($key, [])) : new CompoundTag($key, []);
self::fromArray($tag->{$key}, $value, $guesser); self::fromArray($tag->{$key}, $value, $guesser);
}else{ }else{
$v = call_user_func($guesser, $key, $value); $v = call_user_func($guesser, $key, $value);
@ -678,19 +678,19 @@ class NBT{
} }
public function setArray(array $data, callable $guesser = null){ public function setArray(array $data, callable $guesser = null){
$this->data = new Compound("", []); $this->data = new CompoundTag("", []);
self::fromArray($this->data, $data, $guesser === null ? [self::class, "fromArrayGuesser"] : $guesser); self::fromArray($this->data, $data, $guesser === null ? [self::class, "fromArrayGuesser"] : $guesser);
} }
/** /**
* @return Compound|array * @return CompoundTag|array
*/ */
public function getData(){ public function getData(){
return $this->data; return $this->data;
} }
/** /**
* @param Compound|array $data * @param CompoundTag|array $data
*/ */
public function setData($data){ public function setData($data){
$this->data = $data; $this->data = $data;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class ByteArray extends NamedTag{ class ByteArrayTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_ByteArray; return NBT::TAG_ByteArray;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class Byte extends NamedTag{ class ByteTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_Byte; return NBT::TAG_Byte;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class Compound extends NamedTag implements \ArrayAccess{ class CompoundTag extends NamedTag implements \ArrayAccess{
/** /**
* @param string $name * @param string $name
@ -88,16 +88,16 @@ class Compound extends NamedTag implements \ArrayAccess{
if($tag instanceof NamedTag and $tag->getName() !== ""){ if($tag instanceof NamedTag and $tag->getName() !== ""){
$this->{$tag->getName()} = $tag; $this->{$tag->getName()} = $tag;
} }
}while(!($tag instanceof End) and !$nbt->feof()); }while(!($tag instanceof EndTag) and !$nbt->feof());
} }
public function write(NBT $nbt){ public function write(NBT $nbt){
foreach($this as $tag){ foreach($this as $tag){
if($tag instanceof Tag and !($tag instanceof End)){ if($tag instanceof Tag and !($tag instanceof EndTag)){
$nbt->writeTag($tag); $nbt->writeTag($tag);
} }
} }
$nbt->writeTag(new End); $nbt->writeTag(new EndTag);
} }
public function __toString(){ public function __toString(){

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class Double extends NamedTag{ class DoubleTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_Double; return NBT::TAG_Double;

View File

@ -23,7 +23,7 @@ namespace pocketmine\nbt\tag;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
class End extends Tag{ class EndTag extends Tag{
public function getType(){ public function getType(){
return NBT::TAG_End; return NBT::TAG_End;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class Float extends NamedTag{ class FloatTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_Float; return NBT::TAG_Float;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class IntArray extends NamedTag{ class IntArrayTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_IntArray; return NBT::TAG_IntArray;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class Int extends NamedTag{ class IntTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_Int; return NBT::TAG_Int;

View File

@ -22,11 +22,11 @@
namespace pocketmine\nbt\tag; namespace pocketmine\nbt\tag;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Enum as TagEnum; use pocketmine\nbt\tag\ListTag as TagEnum;
#include <rules/NBT.h> #include <rules/NBT.h>
class Enum extends NamedTag implements \ArrayAccess, \Countable{ class ListTag extends NamedTag implements \ArrayAccess, \Countable{
private $tagType; private $tagType;
@ -103,7 +103,7 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{
} }
public function getType(){ public function getType(){
return NBT::TAG_Enum; return NBT::TAG_List;
} }
public function setTagType($type){ public function setTagType($type){
@ -121,57 +121,57 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{
for($i = 0; $i < $size and !$nbt->feof(); ++$i){ for($i = 0; $i < $size and !$nbt->feof(); ++$i){
switch($this->tagType){ switch($this->tagType){
case NBT::TAG_Byte: case NBT::TAG_Byte:
$tag = new Byte(""); $tag = new ByteTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_Short: case NBT::TAG_Short:
$tag = new Short(""); $tag = new ShortTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_Int: case NBT::TAG_Int:
$tag = new Int(""); $tag = new IntTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_Long: case NBT::TAG_Long:
$tag = new Long(""); $tag = new LongTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_Float: case NBT::TAG_Float:
$tag = new Float(""); $tag = new FloatTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_Double: case NBT::TAG_Double:
$tag = new Double(""); $tag = new DoubleTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_ByteArray: case NBT::TAG_ByteArray:
$tag = new ByteArray(""); $tag = new ByteArrayTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_String: case NBT::TAG_String:
$tag = new String(""); $tag = new StringTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_Enum: case NBT::TAG_List:
$tag = new TagEnum(""); $tag = new TagEnum("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_Compound: case NBT::TAG_Compound:
$tag = new Compound(""); $tag = new CompoundTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;
case NBT::TAG_IntArray: case NBT::TAG_IntArray:
$tag = new IntArray(""); $tag = new IntArrayTag("");
$tag->read($nbt); $tag->read($nbt);
$this->{$i} = $tag; $this->{$i} = $tag;
break; break;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class Long extends NamedTag{ class LongTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_Long; return NBT::TAG_Long;

View File

@ -28,7 +28,7 @@ abstract class NamedTag extends Tag{
/** /**
* @param string $name * @param string $name
* @param bool|float|double|int|byte|short|array|Compound|Enum|string $value * @param bool|float|double|int|ByteTag|ShortTag|array|CompoundTag|ListTag|string $value
*/ */
public function __construct($name = "", $value = null){ public function __construct($name = "", $value = null){
$this->__name = ($name === null or $name === false) ? "" : $name; $this->__name = ($name === null or $name === false) ? "" : $name;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class Short extends NamedTag{ class ShortTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_Short; return NBT::TAG_Short;

View File

@ -25,7 +25,7 @@ use pocketmine\nbt\NBT;
#include <rules/NBT.h> #include <rules/NBT.h>
class String extends NamedTag{ class StringTag extends NamedTag{
public function getType(){ public function getType(){
return NBT::TAG_String; return NBT::TAG_String;

View File

@ -29,11 +29,11 @@ use pocketmine\level\format\FullChunk;
use pocketmine\math\Vector3; use pocketmine\math\Vector3;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
@ -42,12 +42,12 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
/** @var DoubleChestInventory */ /** @var DoubleChestInventory */
protected $doubleInventory = null; protected $doubleInventory = null;
public function __construct(FullChunk $chunk, Compound $nbt){ public function __construct(FullChunk $chunk, CompoundTag $nbt){
parent::__construct($chunk, $nbt); parent::__construct($chunk, $nbt);
$this->inventory = new ChestInventory($this); $this->inventory = new ChestInventory($this);
if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof Enum)){ if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){
$this->namedtag->Items = new Enum("Items", []); $this->namedtag->Items = new ListTag("Items", []);
$this->namedtag->Items->setTagType(NBT::TAG_Compound); $this->namedtag->Items->setTagType(NBT::TAG_Compound);
} }
@ -70,7 +70,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
} }
public function saveNBT(){ public function saveNBT(){
$this->namedtag->Items = new Enum("Items", []); $this->namedtag->Items = new ListTag("Items", []);
$this->namedtag->Items->setTagType(NBT::TAG_Compound); $this->namedtag->Items->setTagType(NBT::TAG_Compound);
for($index = 0; $index < $this->getSize(); ++$index){ for($index = 0; $index < $this->getSize(); ++$index){
$this->setItem($index, $this->inventory->getItem($index)); $this->setItem($index, $this->inventory->getItem($index));
@ -196,7 +196,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
return; return;
} }
$this->namedtag->CustomName = new String("CustomName", $str); $this->namedtag->CustomName = new StringTag("CustomName", $str);
} }
public function isPaired(){ public function isPaired(){
@ -236,11 +236,11 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
} }
private function createPair(Chest $tile){ private function createPair(Chest $tile){
$this->namedtag->pairx = new Int("pairx", $tile->x); $this->namedtag->pairx = new IntTag("pairx", $tile->x);
$this->namedtag->pairz = new Int("pairz", $tile->z); $this->namedtag->pairz = new IntTag("pairz", $tile->z);
$tile->namedtag->pairx = new Int("pairx", $this->x); $tile->namedtag->pairx = new IntTag("pairx", $this->x);
$tile->namedtag->pairz = new Int("pairz", $this->z); $tile->namedtag->pairz = new IntTag("pairz", $this->z);
} }
public function unpair(){ public function unpair(){
@ -265,20 +265,20 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{
public function getSpawnCompound(){ public function getSpawnCompound(){
if($this->isPaired()){ if($this->isPaired()){
$c = new Compound("", [ $c = new CompoundTag("", [
new String("id", Tile::CHEST), new StringTag("id", Tile::CHEST),
new Int("x", (int) $this->x), new IntTag("x", (int) $this->x),
new Int("y", (int) $this->y), new IntTag("y", (int) $this->y),
new Int("z", (int) $this->z), new IntTag("z", (int) $this->z),
new Int("pairx", (int) $this->namedtag["pairx"]), new IntTag("pairx", (int) $this->namedtag["pairx"]),
new Int("pairz", (int) $this->namedtag["pairz"]) new IntTag("pairz", (int) $this->namedtag["pairz"])
]); ]);
}else{ }else{
$c = new Compound("", [ $c = new CompoundTag("", [
new String("id", Tile::CHEST), new StringTag("id", Tile::CHEST),
new Int("x", (int) $this->x), new IntTag("x", (int) $this->x),
new Int("y", (int) $this->y), new IntTag("y", (int) $this->y),
new Int("z", (int) $this->z) new IntTag("z", (int) $this->z)
]); ]);
} }

View File

@ -21,9 +21,9 @@
namespace pocketmine\tile; namespace pocketmine\tile;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
class EnchantTable extends Spawnable implements Nameable{ class EnchantTable extends Spawnable implements Nameable{
@ -42,15 +42,15 @@ class EnchantTable extends Spawnable implements Nameable{
return; return;
} }
$this->namedtag->CustomName = new String("CustomName", $str); $this->namedtag->CustomName = new StringTag("CustomName", $str);
} }
public function getSpawnCompound(){ public function getSpawnCompound(){
$c = new Compound("", [ $c = new CompoundTag("", [
new String("id", Tile::ENCHANT_TABLE), new StringTag("id", Tile::ENCHANT_TABLE),
new Int("x", (int) $this->x), new IntTag("x", (int) $this->x),
new Int("y", (int) $this->y), new IntTag("y", (int) $this->y),
new Int("z", (int) $this->z) new IntTag("z", (int) $this->z)
]); ]);
if($this->hasName()){ if($this->hasName()){

View File

@ -31,10 +31,10 @@ use pocketmine\item\Item;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Enum; use pocketmine\nbt\tag\ListTag;
use pocketmine\nbt\tag\Short; use pocketmine\nbt\tag\ShortTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\ContainerSetDataPacket; use pocketmine\network\protocol\ContainerSetDataPacket;
@ -42,12 +42,12 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
/** @var FurnaceInventory */ /** @var FurnaceInventory */
protected $inventory; protected $inventory;
public function __construct(FullChunk $chunk, Compound $nbt){ public function __construct(FullChunk $chunk, CompoundTag $nbt){
parent::__construct($chunk, $nbt); parent::__construct($chunk, $nbt);
$this->inventory = new FurnaceInventory($this); $this->inventory = new FurnaceInventory($this);
if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof Enum)){ if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){
$this->namedtag->Items = new Enum("Items", []); $this->namedtag->Items = new ListTag("Items", []);
$this->namedtag->Items->setTagType(NBT::TAG_Compound); $this->namedtag->Items->setTagType(NBT::TAG_Compound);
} }
@ -56,14 +56,14 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
} }
if(!isset($this->namedtag->BurnTime) or $this->namedtag["BurnTime"] < 0){ if(!isset($this->namedtag->BurnTime) or $this->namedtag["BurnTime"] < 0){
$this->namedtag->BurnTime = new Short("BurnTime", 0); $this->namedtag->BurnTime = new ShortTag("BurnTime", 0);
} }
if(!isset($this->namedtag->CookTime) or $this->namedtag["CookTime"] < 0 or ($this->namedtag["BurnTime"] === 0 and $this->namedtag["CookTime"] > 0)){ if(!isset($this->namedtag->CookTime) or $this->namedtag["CookTime"] < 0 or ($this->namedtag["BurnTime"] === 0 and $this->namedtag["CookTime"] > 0)){
$this->namedtag->CookTime = new Short("CookTime", 0); $this->namedtag->CookTime = new ShortTag("CookTime", 0);
} }
if(!isset($this->namedtag->MaxTime)){ if(!isset($this->namedtag->MaxTime)){
$this->namedtag->MaxTime = new Short("BurnTime", $this->namedtag["BurnTime"]); $this->namedtag->MaxTime = new ShortTag("BurnTime", $this->namedtag["BurnTime"]);
$this->namedtag->BurnTicks = new Short("BurnTicks", 0); $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0);
} }
if($this->namedtag["BurnTime"] > 0){ if($this->namedtag["BurnTime"] > 0){
$this->scheduleUpdate(); $this->scheduleUpdate();
@ -84,7 +84,7 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
return; return;
} }
$this->namedtag->CustomName = new String("CustomName", $str); $this->namedtag->CustomName = new StringTag("CustomName", $str);
} }
public function close(){ public function close(){
@ -97,7 +97,7 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
} }
public function saveNBT(){ public function saveNBT(){
$this->namedtag->Items = new Enum("Items", []); $this->namedtag->Items = new ListTag("Items", []);
$this->namedtag->Items->setTagType(NBT::TAG_Compound); $this->namedtag->Items->setTagType(NBT::TAG_Compound);
for($index = 0; $index < $this->getSize(); ++$index){ for($index = 0; $index < $this->getSize(); ++$index){
$this->setItem($index, $this->inventory->getItem($index)); $this->setItem($index, $this->inventory->getItem($index));
@ -187,9 +187,9 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
return; return;
} }
$this->namedtag->MaxTime = new Short("MaxTime", $ev->getBurnTime()); $this->namedtag->MaxTime = new ShortTag("MaxTime", $ev->getBurnTime());
$this->namedtag->BurnTime = new Short("BurnTime", $ev->getBurnTime()); $this->namedtag->BurnTime = new ShortTag("BurnTime", $ev->getBurnTime());
$this->namedtag->BurnTicks = new Short("BurnTicks", 0); $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0);
if($this->getBlock()->getId() === Item::FURNACE){ if($this->getBlock()->getId() === Item::FURNACE){
$this->getLevel()->setBlock($this, Block::get(Item::BURNING_FURNACE, $this->getBlock()->getDamage()), true); $this->getLevel()->setBlock($this, Block::get(Item::BURNING_FURNACE, $this->getBlock()->getDamage()), true);
} }
@ -223,11 +223,11 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
} }
if($this->namedtag["BurnTime"] > 0){ if($this->namedtag["BurnTime"] > 0){
$this->namedtag->BurnTime = new Short("BurnTime", $this->namedtag["BurnTime"] - 1); $this->namedtag->BurnTime = new ShortTag("BurnTime", $this->namedtag["BurnTime"] - 1);
$this->namedtag->BurnTicks = new Short("BurnTicks", ceil(($this->namedtag["BurnTime"] / $this->namedtag["MaxTime"] * 200))); $this->namedtag->BurnTicks = new ShortTag("BurnTicks", ceil(($this->namedtag["BurnTime"] / $this->namedtag["MaxTime"] * 200)));
if($smelt instanceof FurnaceRecipe and $canSmelt){ if($smelt instanceof FurnaceRecipe and $canSmelt){
$this->namedtag->CookTime = new Short("CookTime", $this->namedtag["CookTime"] + 1); $this->namedtag->CookTime = new ShortTag("CookTime", $this->namedtag["CookTime"] + 1);
if($this->namedtag["CookTime"] >= 200){ //10 seconds if($this->namedtag["CookTime"] >= 200){ //10 seconds
$product = Item::get($smelt->getResult()->getId(), $smelt->getResult()->getDamage(), $product->getCount() + 1); $product = Item::get($smelt->getResult()->getId(), $smelt->getResult()->getDamage(), $product->getCount() + 1);
@ -242,14 +242,14 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
$this->inventory->setSmelting($raw); $this->inventory->setSmelting($raw);
} }
$this->namedtag->CookTime = new Short("CookTime", $this->namedtag["CookTime"] - 200); $this->namedtag->CookTime = new ShortTag("CookTime", $this->namedtag["CookTime"] - 200);
} }
}elseif($this->namedtag["BurnTime"] <= 0){ }elseif($this->namedtag["BurnTime"] <= 0){
$this->namedtag->BurnTime = new Short("BurnTime", 0); $this->namedtag->BurnTime = new ShortTag("BurnTime", 0);
$this->namedtag->CookTime = new Short("CookTime", 0); $this->namedtag->CookTime = new ShortTag("CookTime", 0);
$this->namedtag->BurnTicks = new Short("BurnTicks", 0); $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0);
}else{ }else{
$this->namedtag->CookTime = new Short("CookTime", 0); $this->namedtag->CookTime = new ShortTag("CookTime", 0);
} }
$ret = true; $ret = true;
}else{ }else{
@ -257,9 +257,9 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{
if($this->getBlock()->getId() === Item::BURNING_FURNACE){ if($this->getBlock()->getId() === Item::BURNING_FURNACE){
$this->getLevel()->setBlock($this, Block::get(Item::FURNACE, $this->getBlock()->getDamage()), true); $this->getLevel()->setBlock($this, Block::get(Item::FURNACE, $this->getBlock()->getDamage()), true);
} }
$this->namedtag->BurnTime = new Short("BurnTime", 0); $this->namedtag->BurnTime = new ShortTag("BurnTime", 0);
$this->namedtag->CookTime = new Short("CookTime", 0); $this->namedtag->CookTime = new ShortTag("CookTime", 0);
$this->namedtag->BurnTicks = new Short("BurnTicks", 0); $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0);
} }
foreach($this->getInventory()->getViewers() as $player){ foreach($this->getInventory()->getViewers() as $player){

View File

@ -22,24 +22,24 @@
namespace pocketmine\tile; namespace pocketmine\tile;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
class Sign extends Spawnable{ class Sign extends Spawnable{
public function __construct(FullChunk $chunk, Compound $nbt){ public function __construct(FullChunk $chunk, CompoundTag $nbt){
if(!isset($nbt->Text1)){ if(!isset($nbt->Text1)){
$nbt->Text1 = new String("Text1", ""); $nbt->Text1 = new StringTag("Text1", "");
} }
if(!isset($nbt->Text2)){ if(!isset($nbt->Text2)){
$nbt->Text2 = new String("Text2", ""); $nbt->Text2 = new StringTag("Text2", "");
} }
if(!isset($nbt->Text3)){ if(!isset($nbt->Text3)){
$nbt->Text3 = new String("Text3", ""); $nbt->Text3 = new StringTag("Text3", "");
} }
if(!isset($nbt->Text4)){ if(!isset($nbt->Text4)){
$nbt->Text4 = new String("Text4", ""); $nbt->Text4 = new StringTag("Text4", "");
} }
parent::__construct($chunk, $nbt); parent::__construct($chunk, $nbt);
@ -51,10 +51,10 @@ class Sign extends Spawnable{
} }
public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){ public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){
$this->namedtag->Text1 = new String("Text1", $line1); $this->namedtag->Text1 = new StringTag("Text1", $line1);
$this->namedtag->Text2 = new String("Text2", $line2); $this->namedtag->Text2 = new StringTag("Text2", $line2);
$this->namedtag->Text3 = new String("Text3", $line3); $this->namedtag->Text3 = new StringTag("Text3", $line3);
$this->namedtag->Text4 = new String("Text4", $line4); $this->namedtag->Text4 = new StringTag("Text4", $line4);
$this->spawnToAll(); $this->spawnToAll();
if($this->chunk){ if($this->chunk){
@ -75,15 +75,15 @@ class Sign extends Spawnable{
} }
public function getSpawnCompound(){ public function getSpawnCompound(){
return new Compound("", [ return new CompoundTag("", [
new String("id", Tile::SIGN), new StringTag("id", Tile::SIGN),
$this->namedtag->Text1, $this->namedtag->Text1,
$this->namedtag->Text2, $this->namedtag->Text2,
$this->namedtag->Text3, $this->namedtag->Text3,
$this->namedtag->Text4, $this->namedtag->Text4,
new Int("x", (int) $this->x), new IntTag("x", (int) $this->x),
new Int("y", (int) $this->y), new IntTag("y", (int) $this->y),
new Int("z", (int) $this->z) new IntTag("z", (int) $this->z)
]); ]);
} }

View File

@ -23,7 +23,7 @@ namespace pocketmine\tile;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\nbt\NBT; use pocketmine\nbt\NBT;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\Network; use pocketmine\network\Network;
use pocketmine\network\protocol\TileEntityDataPacket; use pocketmine\network\protocol\TileEntityDataPacket;
use pocketmine\Player; use pocketmine\Player;
@ -48,11 +48,11 @@ abstract class Spawnable extends Tile{
} }
/** /**
* @return Compound * @return CompoundTag
*/ */
public abstract function getSpawnCompound(); public abstract function getSpawnCompound();
public function __construct(FullChunk $chunk, Compound $nbt){ public function __construct(FullChunk $chunk, CompoundTag $nbt){
parent::__construct($chunk, $nbt); parent::__construct($chunk, $nbt);
$this->spawnToAll(); $this->spawnToAll();
} }

View File

@ -30,9 +30,9 @@ use pocketmine\level\format\Chunk;
use pocketmine\level\format\FullChunk; use pocketmine\level\format\FullChunk;
use pocketmine\level\Level; use pocketmine\level\Level;
use pocketmine\level\Position; use pocketmine\level\Position;
use pocketmine\nbt\tag\Compound; use pocketmine\nbt\tag\CompoundTag;
use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntTag;
use pocketmine\nbt\tag\String; use pocketmine\nbt\tag\StringTag;
use pocketmine\utils\ChunkException; use pocketmine\utils\ChunkException;
abstract class Tile extends Position{ abstract class Tile extends Position{
@ -71,12 +71,12 @@ abstract class Tile extends Position{
/** /**
* @param string $type * @param string $type
* @param FullChunk $chunk * @param FullChunk $chunk
* @param Compound $nbt * @param CompoundTag $nbt
* @param $args * @param $args
* *
* @return Tile * @return Tile
*/ */
public static function createTile($type, FullChunk $chunk, Compound $nbt, ...$args){ public static function createTile($type, FullChunk $chunk, CompoundTag $nbt, ...$args){
if(isset(self::$knownTiles[$type])){ if(isset(self::$knownTiles[$type])){
$class = self::$knownTiles[$type]; $class = self::$knownTiles[$type];
return new $class($chunk, $nbt, ...$args); return new $class($chunk, $nbt, ...$args);
@ -110,7 +110,7 @@ abstract class Tile extends Position{
return self::$shortNames[static::class]; return self::$shortNames[static::class];
} }
public function __construct(FullChunk $chunk, Compound $nbt){ public function __construct(FullChunk $chunk, CompoundTag $nbt){
if($chunk === null or $chunk->getProvider() === null){ if($chunk === null or $chunk->getProvider() === null){
throw new ChunkException("Invalid garbage Chunk given to Tile"); throw new ChunkException("Invalid garbage Chunk given to Tile");
} }
@ -138,10 +138,10 @@ abstract class Tile extends Position{
} }
public function saveNBT(){ public function saveNBT(){
$this->namedtag->id = new String("id", $this->getSaveId()); $this->namedtag->id = new StringTag("id", $this->getSaveId());
$this->namedtag->x = new Int("x", $this->x); $this->namedtag->x = new IntTag("x", $this->x);
$this->namedtag->y = new Int("y", $this->y); $this->namedtag->y = new IntTag("y", $this->y);
$this->namedtag->z = new Int("z", $this->z); $this->namedtag->z = new IntTag("z", $this->z);
} }
/** /**