diff --git a/src/pocketmine/OfflinePlayer.php b/src/pocketmine/OfflinePlayer.php index 03bdeab49..f195ededa 100644 --- a/src/pocketmine/OfflinePlayer.php +++ b/src/pocketmine/OfflinePlayer.php @@ -23,7 +23,7 @@ namespace pocketmine; use pocketmine\metadata\MetadataValue; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\plugin\Plugin; class OfflinePlayer implements IPlayer{ @@ -103,15 +103,15 @@ class OfflinePlayer implements IPlayer{ } public function getFirstPlayed(){ - return $this->namedtag instanceof Compound ? $this->namedtag["firstPlayed"] : null; + return $this->namedtag instanceof CompoundTag ? $this->namedtag["firstPlayed"] : null; } public function getLastPlayed(){ - return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null; + return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null; } public function hasPlayedBefore(){ - return $this->namedtag instanceof Compound; + return $this->namedtag instanceof CompoundTag; } public function setMetadata($metadataKey, MetadataValue $metadataValue){ diff --git a/src/pocketmine/Player.php b/src/pocketmine/Player.php index befe7c73c..d1e4ae8b9 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -91,15 +91,15 @@ use pocketmine\math\Vector2; use pocketmine\math\Vector3; use pocketmine\metadata\MetadataValue; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\Long; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\LongTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\Network; use pocketmine\network\protocol\AdventureSettingsPacket; use pocketmine\network\protocol\AnimatePacket; @@ -296,15 +296,15 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } public function getFirstPlayed(){ - return $this->namedtag instanceof Compound ? $this->namedtag["firstPlayed"] : null; + return $this->namedtag instanceof CompoundTag ? $this->namedtag["firstPlayed"] : null; } public function getLastPlayed(){ - return $this->namedtag instanceof Compound ? $this->namedtag["lastPlayed"] : null; + return $this->namedtag instanceof CompoundTag ? $this->namedtag["lastPlayed"] : null; } public function hasPlayedBefore(){ - return $this->namedtag instanceof Compound; + return $this->namedtag instanceof CompoundTag; } public function setAllowFlight($value){ @@ -503,7 +503,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->interface = $interface; $this->windows = new \SplObjectStorage(); $this->perm = new PermissibleBase($this); - $this->namedtag = new Compound(); + $this->namedtag = new CompoundTag(); $this->server = Server::getInstance(); $this->lastBreak = PHP_INT_MAX; $this->ip = $ip; @@ -1097,7 +1097,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->spawnToAll(); } - $this->namedtag->playerGameType = new Int("playerGameType", $this->gamemode); + $this->namedtag->playerGameType = new IntTag("playerGameType", $this->gamemode); $spawnPosition = $this->getSpawn(); @@ -1636,14 +1636,14 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $nbt = $this->server->getOfflinePlayerData($this->username); if(!isset($nbt->NameTag)){ - $nbt->NameTag = new String("NameTag", $this->username); + $nbt->NameTag = new StringTag("NameTag", $this->username); }else{ $nbt["NameTag"] = $this->username; } $this->gamemode = $nbt["playerGameType"] & 0x03; if($this->server->getForceGamemode()){ $this->gamemode = $this->server->getGamemode(); - $nbt->playerGameType = new Int("playerGameType", $this->gamemode); + $nbt->playerGameType = new IntTag("playerGameType", $this->gamemode); } $this->allowFlight = $this->isCreative(); @@ -1659,7 +1659,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->setLevel($level); } - if(!($nbt instanceof Compound)){ + if(!($nbt instanceof CompoundTag)){ $this->close($this->getLeaveMessage(), "Invalid data"); return; @@ -1672,7 +1672,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $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()){ $this->server->saveOfflinePlayerData($this->username, $nbt, true); } @@ -2039,20 +2039,20 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } if($item->getId() === Item::SNOWBALL){ - $nbt = new Compound("", [ - "Pos" => new Enum("Pos", [ - new Double("", $this->x), - new Double("", $this->y + $this->getEyeHeight()), - new Double("", $this->z) + $nbt = new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $this->x), + new DoubleTag("", $this->y + $this->getEyeHeight()), + new DoubleTag("", $this->z) ]), - "Motion" => new Enum("Motion", [ - new Double("", $aimPos->x), - new Double("", $aimPos->y), - new Double("", $aimPos->z) + "Motion" => new ListTag("Motion", [ + new DoubleTag("", $aimPos->x), + new DoubleTag("", $aimPos->y), + new DoubleTag("", $aimPos->z) ]), - "Rotation" => new Enum("Rotation", [ - new Float("", $this->yaw), - new Float("", $this->pitch) + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", $this->yaw), + new FloatTag("", $this->pitch) ]), ]); @@ -2115,22 +2115,22 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } - $nbt = new Compound("", [ - "Pos" => new Enum("Pos", [ - new Double("", $this->x), - new Double("", $this->y + $this->getEyeHeight()), - new Double("", $this->z) + $nbt = new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $this->x), + new DoubleTag("", $this->y + $this->getEyeHeight()), + new DoubleTag("", $this->z) ]), - "Motion" => new Enum("Motion", [ - new Double("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), - new Double("", -sin($this->pitch / 180 * M_PI)), - new Double("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)) + "Motion" => new ListTag("Motion", [ + new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)), + new DoubleTag("", -sin($this->pitch / 180 * M_PI)), + new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)) ]), - "Rotation" => new Enum("Rotation", [ - new Float("", $this->yaw), - new Float("", $this->pitch) + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", $this->yaw), + 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); @@ -3102,7 +3102,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade parent::saveNBT(); 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){ $this->namedtag["SpawnLevel"] = $this->spawnPosition->getLevel()->getName(); $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){ - $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["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); } } diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 261219566..ca45a2974 100644 --- a/src/pocketmine/Server.php +++ b/src/pocketmine/Server.php @@ -73,15 +73,15 @@ use pocketmine\metadata\EntityMetadataStore; use pocketmine\metadata\LevelMetadataStore; use pocketmine\metadata\PlayerMetadataStore; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\Long; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\LongTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\CompressBatchedTask; use pocketmine\network\Network; use pocketmine\network\protocol\BatchPacket; @@ -743,7 +743,7 @@ class Server{ /** * @param string $name * - * @return Compound + * @return CompoundTag */ public function getOfflinePlayerData($name){ $name = strtolower($name); @@ -762,38 +762,38 @@ class Server{ $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerNotFound", [$name])); } $spawn = $this->getDefaultLevel()->getSafeSpawn(); - $nbt = new Compound("", [ - new Long("firstPlayed", floor(microtime(true) * 1000)), - new Long("lastPlayed", floor(microtime(true) * 1000)), - new Enum("Pos", [ - new Double(0, $spawn->x), - new Double(1, $spawn->y), - new Double(2, $spawn->z) + $nbt = new CompoundTag("", [ + new LongTag("firstPlayed", floor(microtime(true) * 1000)), + new LongTag("lastPlayed", floor(microtime(true) * 1000)), + new ListTag("Pos", [ + new DoubleTag(0, $spawn->x), + new DoubleTag(1, $spawn->y), + new DoubleTag(2, $spawn->z) ]), - new String("Level", $this->getDefaultLevel()->getName()), - //new String("SpawnLevel", $this->getDefaultLevel()->getName()), - //new Int("SpawnX", (int) $spawn->x), - //new Int("SpawnY", (int) $spawn->y), - //new Int("SpawnZ", (int) $spawn->z), - //new Byte("SpawnForced", 1), //TODO - new Enum("Inventory", []), - new Compound("Achievements", []), - new Int("playerGameType", $this->getGamemode()), - new Enum("Motion", [ - new Double(0, 0.0), - new Double(1, 0.0), - new Double(2, 0.0) + new StringTag("Level", $this->getDefaultLevel()->getName()), + //new StringTag("SpawnLevel", $this->getDefaultLevel()->getName()), + //new IntTag("SpawnX", (int) $spawn->x), + //new IntTag("SpawnY", (int) $spawn->y), + //new IntTag("SpawnZ", (int) $spawn->z), + //new ByteTag("SpawnForced", 1), //TODO + new ListTag("Inventory", []), + new CompoundTag("Achievements", []), + new IntTag("playerGameType", $this->getGamemode()), + new ListTag("Motion", [ + new DoubleTag(0, 0.0), + new DoubleTag(1, 0.0), + new DoubleTag(2, 0.0) ]), - new Enum("Rotation", [ - new Float(0, 0.0), - new Float(1, 0.0) + new ListTag("Rotation", [ + new FloatTag(0, 0.0), + new FloatTag(1, 0.0) ]), - new Float("FallDistance", 0.0), - new Short("Fire", 0), - new Short("Air", 300), - new Byte("OnGround", 1), - new Byte("Invulnerable", 0), - new String("NameTag", $name), + new FloatTag("FallDistance", 0.0), + new ShortTag("Fire", 0), + new ShortTag("Air", 300), + new ByteTag("OnGround", 1), + new ByteTag("Invulnerable", 0), + new StringTag("NameTag", $name), ]); $nbt->Pos->setTagType(NBT::TAG_Double); $nbt->Inventory->setTagType(NBT::TAG_Compound); @@ -814,39 +814,39 @@ class Server{ $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerOld", [$name])); foreach($data->get("inventory") as $slot => $item){ if(count($item) === 3){ - $nbt->Inventory[$slot + 9] = new Compound("", [ - new Short("id", $item[0]), - new Short("Damage", $item[1]), - new Byte("Count", $item[2]), - new Byte("Slot", $slot + 9), - new Byte("TrueSlot", $slot + 9) + $nbt->Inventory[$slot + 9] = new CompoundTag("", [ + new ShortTag("id", $item[0]), + new ShortTag("Damage", $item[1]), + new ByteTag("Count", $item[2]), + new ByteTag("Slot", $slot + 9), + new ByteTag("TrueSlot", $slot + 9) ]); } } foreach($data->get("hotbar") as $slot => $itemSlot){ if(isset($nbt->Inventory[$itemSlot + 9])){ $item = $nbt->Inventory[$itemSlot + 9]; - $nbt->Inventory[$slot] = new Compound("", [ - new Short("id", $item["id"]), - new Short("Damage", $item["Damage"]), - new Byte("Count", $item["Count"]), - new Byte("Slot", $slot), - new Byte("TrueSlot", $item["TrueSlot"]) + $nbt->Inventory[$slot] = new CompoundTag("", [ + new ShortTag("id", $item["id"]), + new ShortTag("Damage", $item["Damage"]), + new ByteTag("Count", $item["Count"]), + new ByteTag("Slot", $slot), + new ByteTag("TrueSlot", $item["TrueSlot"]) ]); } } foreach($data->get("armor") as $slot => $item){ if(count($item) === 2){ - $nbt->Inventory[$slot + 100] = new Compound("", [ - new Short("id", $item[0]), - new Short("Damage", $item[1]), - new Byte("Count", 1), - new Byte("Slot", $slot + 100) + $nbt->Inventory[$slot + 100] = new CompoundTag("", [ + new ShortTag("id", $item[0]), + new ShortTag("Damage", $item[1]), + new ByteTag("Count", 1), + new ByteTag("Slot", $slot + 100) ]); } } 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"); } @@ -858,10 +858,10 @@ class Server{ /** * @param string $name - * @param Compound $nbtTag + * @param CompoundTag $nbtTag * @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); try{ $nbt->setData($nbtTag); diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index 18d028e73..4b2638378 100644 --- a/src/pocketmine/block/BurningFurnace.php +++ b/src/pocketmine/block/BurningFurnace.php @@ -24,10 +24,10 @@ namespace pocketmine\block; use pocketmine\item\Item; use pocketmine\item\Tool; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\Player; use pocketmine\tile\Furnace; use pocketmine\tile\Tile; @@ -69,17 +69,17 @@ class BurningFurnace extends Solid{ ]; $this->meta = $faces[$player instanceof Player ? $player->getDirection() : 0]; $this->getLevel()->setBlock($block, $this, true, true); - $nbt = new Compound("", [ - new Enum("Items", []), - new String("id", Tile::FURNACE), - new Int("x", $this->x), - new Int("y", $this->y), - new Int("z", $this->z) + $nbt = new CompoundTag("", [ + new ListTag("Items", []), + new StringTag("id", Tile::FURNACE), + new IntTag("x", $this->x), + new IntTag("y", $this->y), + new IntTag("z", $this->z) ]); $nbt->Items->setTagType(NBT::TAG_Compound); if($item->hasCustomName()){ - $nbt->CustomName = new String("CustomName", $item->getCustomName()); + $nbt->CustomName = new StringTag("CustomName", $item->getCustomName()); } if($item->hasCustomBlockData()){ @@ -106,18 +106,18 @@ class BurningFurnace extends Solid{ if($t instanceof Furnace){ $furnace = $t; }else{ - $nbt = new Compound("", [ - new Enum("Items", []), - new String("id", Tile::FURNACE), - new Int("x", $this->x), - new Int("y", $this->y), - new Int("z", $this->z) + $nbt = new CompoundTag("", [ + new ListTag("Items", []), + new StringTag("id", Tile::FURNACE), + new IntTag("x", $this->x), + new IntTag("y", $this->y), + new IntTag("z", $this->z) ]); $nbt->Items->setTagType(NBT::TAG_Compound); $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()){ return true; } diff --git a/src/pocketmine/block/Chest.php b/src/pocketmine/block/Chest.php index 1f7017abd..c0c4eed9a 100644 --- a/src/pocketmine/block/Chest.php +++ b/src/pocketmine/block/Chest.php @@ -25,10 +25,10 @@ use pocketmine\item\Item; use pocketmine\item\Tool; use pocketmine\math\AxisAlignedBB; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\Player; use pocketmine\tile\Chest as TileChest; use pocketmine\tile\Tile; @@ -96,17 +96,17 @@ class Chest extends Transparent{ } $this->getLevel()->setBlock($block, $this, true, true); - $nbt = new Compound("", [ - new Enum("Items", []), - new String("id", Tile::CHEST), - new Int("x", $this->x), - new Int("y", $this->y), - new Int("z", $this->z) + $nbt = new CompoundTag("", [ + new ListTag("Items", []), + new StringTag("id", Tile::CHEST), + new IntTag("x", $this->x), + new IntTag("y", $this->y), + new IntTag("z", $this->z) ]); $nbt->Items->setTagType(NBT::TAG_Compound); if($item->hasCustomName()){ - $nbt->CustomName = new String("CustomName", $item->getCustomName()); + $nbt->CustomName = new StringTag("CustomName", $item->getCustomName()); } if($item->hasCustomBlockData()){ @@ -147,18 +147,18 @@ class Chest extends Transparent{ if($t instanceof TileChest){ $chest = $t; }else{ - $nbt = new Compound("", [ - new Enum("Items", []), - new String("id", Tile::CHEST), - new Int("x", $this->x), - new Int("y", $this->y), - new Int("z", $this->z) + $nbt = new CompoundTag("", [ + new ListTag("Items", []), + new StringTag("id", Tile::CHEST), + new IntTag("x", $this->x), + new IntTag("y", $this->y), + new IntTag("z", $this->z) ]); $nbt->Items->setTagType(NBT::TAG_Compound); $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()){ return true; } diff --git a/src/pocketmine/block/DoubleSlab.php b/src/pocketmine/block/DoubleSlab.php index 23c712ab8..295856128 100644 --- a/src/pocketmine/block/DoubleSlab.php +++ b/src/pocketmine/block/DoubleSlab.php @@ -51,7 +51,7 @@ class DoubleSlab extends Solid{ 6 => "Quartz", 7 => "", ]; - return "Double " . $names[$this->meta & 0x07] . " Slab"; + return "DoubleTag " . $names[$this->meta & 0x07] . " Slab"; } public function getDrops(Item $item){ diff --git a/src/pocketmine/block/DoubleWoodSlab.php b/src/pocketmine/block/DoubleWoodSlab.php index f8f3310ee..a28170e39 100644 --- a/src/pocketmine/block/DoubleWoodSlab.php +++ b/src/pocketmine/block/DoubleWoodSlab.php @@ -50,7 +50,7 @@ class DoubleWoodSlab extends Solid{ 6 => "", 7 => "" ]; - return "Double " . $names[$this->meta & 0x07] . " Wooden Slab"; + return "DoubleTag " . $names[$this->meta & 0x07] . " Wooden Slab"; } public function getDrops(Item $item){ diff --git a/src/pocketmine/block/EnchantingTable.php b/src/pocketmine/block/EnchantingTable.php index f65c5f8bc..f6c4e1d9d 100644 --- a/src/pocketmine/block/EnchantingTable.php +++ b/src/pocketmine/block/EnchantingTable.php @@ -25,9 +25,9 @@ use pocketmine\inventory\EnchantInventory; use pocketmine\item\Item; use pocketmine\item\Tool; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\Player; 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){ $this->getLevel()->setBlock($block, $this, true, true); - $nbt = new Compound("", [ - new String("id", Tile::ENCHANT_TABLE), - new Int("x", $this->x), - new Int("y", $this->y), - new Int("z", $this->z) + $nbt = new CompoundTag("", [ + new StringTag("id", Tile::ENCHANT_TABLE), + new IntTag("x", $this->x), + new IntTag("y", $this->y), + new IntTag("z", $this->z) ]); if($item->hasCustomName()){ - $nbt->CustomName = new String("CustomName", $item->getCustomName()); + $nbt->CustomName = new StringTag("CustomName", $item->getCustomName()); } if($item->hasCustomBlockData()){ diff --git a/src/pocketmine/block/EndPortalFrame.php b/src/pocketmine/block/EndPortalFrame.php index c5ab69f27..0cecd31ca 100644 --- a/src/pocketmine/block/EndPortalFrame.php +++ b/src/pocketmine/block/EndPortalFrame.php @@ -37,7 +37,7 @@ class EndPortalFrame extends Solid{ } public function getName(){ - return "End Portal Frame"; + return "EndTag Portal Frame"; } public function getHardness(){ diff --git a/src/pocketmine/block/EndStone.php b/src/pocketmine/block/EndStone.php index fe67d2b84..62c88cbc9 100644 --- a/src/pocketmine/block/EndStone.php +++ b/src/pocketmine/block/EndStone.php @@ -33,7 +33,7 @@ class EndStone extends Solid{ } public function getName(){ - return "End Stone"; + return "EndTag Stone"; } public function getToolType(){ diff --git a/src/pocketmine/block/Fallable.php b/src/pocketmine/block/Fallable.php index eb4854ccf..db952e50a 100644 --- a/src/pocketmine/block/Fallable.php +++ b/src/pocketmine/block/Fallable.php @@ -25,12 +25,12 @@ use pocketmine\entity\Entity; use pocketmine\item\Item; use pocketmine\level\Level; use pocketmine\math\Vector3; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; -use pocketmine\nbt\tag\Int; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; use pocketmine\Player; abstract class Fallable extends Solid{ @@ -45,23 +45,23 @@ abstract class Fallable extends Solid{ if($type === Level::BLOCK_UPDATE_NORMAL){ $down = $this->getSide(Vector3::SIDE_DOWN); if($down->getId() === self::AIR or ($down instanceof Liquid)){ - $fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [ - "Pos" => new Enum("Pos", [ - new Double("", $this->x + 0.5), - new Double("", $this->y), - new Double("", $this->z + 0.5) + $fall = Entity::createEntity("FallingSand", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $this->x + 0.5), + new DoubleTag("", $this->y), + new DoubleTag("", $this->z + 0.5) ]), - "Motion" => new Enum("Motion", [ - new Double("", 0), - new Double("", 0), - new Double("", 0) + "Motion" => new ListTag("Motion", [ + new DoubleTag("", 0), + new DoubleTag("", 0), + new DoubleTag("", 0) ]), - "Rotation" => new Enum("Rotation", [ - new Float("", 0), - new Float("", 0) + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", 0), + new FloatTag("", 0) ]), - "TileID" => new Int("TileID", $this->getId()), - "Data" => new Byte("Data", $this->getDamage()), + "TileID" => new IntTag("TileID", $this->getId()), + "Data" => new ByteTag("Data", $this->getDamage()), ])); $fall->spawnToAll(); diff --git a/src/pocketmine/block/TNT.php b/src/pocketmine/block/TNT.php index 7212a33d4..d3e74fece 100644 --- a/src/pocketmine/block/TNT.php +++ b/src/pocketmine/block/TNT.php @@ -23,11 +23,11 @@ namespace pocketmine\block; use pocketmine\entity\Entity; use pocketmine\item\Item; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; use pocketmine\Player; use pocketmine\utils\Random; @@ -57,22 +57,22 @@ class TNT extends Solid{ $this->getLevel()->setBlock($this, new Air(), true); $mot = (new Random())->nextSignedFloat() * M_PI * 2; - $tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new Compound("", [ - "Pos" => new Enum("Pos", [ - new Double("", $this->x + 0.5), - new Double("", $this->y), - new Double("", $this->z + 0.5) + $tnt = Entity::createEntity("PrimedTNT", $this->getLevel()->getChunk($this->x >> 4, $this->z >> 4), new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $this->x + 0.5), + new DoubleTag("", $this->y), + new DoubleTag("", $this->z + 0.5) ]), - "Motion" => new Enum("Motion", [ - new Double("", -sin($mot) * 0.02), - new Double("", 0.2), - new Double("", -cos($mot) * 0.02) + "Motion" => new ListTag("Motion", [ + new DoubleTag("", -sin($mot) * 0.02), + new DoubleTag("", 0.2), + new DoubleTag("", -cos($mot) * 0.02) ]), - "Rotation" => new Enum("Rotation", [ - new Float("", 0), - new Float("", 0) + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", 0), + new FloatTag("", 0) ]), - "Fuse" => new Byte("Fuse", 80) + "Fuse" => new ByteTag("Fuse", 80) ])); $tnt->spawnToAll(); diff --git a/src/pocketmine/command/defaults/GiveCommand.php b/src/pocketmine/command/defaults/GiveCommand.php index b8cd20e39..3c7578d5e 100644 --- a/src/pocketmine/command/defaults/GiveCommand.php +++ b/src/pocketmine/command/defaults/GiveCommand.php @@ -26,7 +26,7 @@ use pocketmine\command\CommandSender; use pocketmine\event\TranslationContainer; use pocketmine\item\Item; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\Player; use pocketmine\utils\TextFormat; @@ -70,7 +70,7 @@ class GiveCommand extends VanillaCommand{ $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"])); return true; } diff --git a/src/pocketmine/entity/Arrow.php b/src/pocketmine/entity/Arrow.php index dd473637d..15e1f74fe 100644 --- a/src/pocketmine/entity/Arrow.php +++ b/src/pocketmine/entity/Arrow.php @@ -23,7 +23,7 @@ namespace pocketmine\entity; use pocketmine\level\format\FullChunk; use pocketmine\level\particle\CriticalParticle; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddEntityPacket; use pocketmine\Player; @@ -42,7 +42,7 @@ class Arrow extends Projectile{ 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; parent::__construct($chunk, $nbt, $shootingEntity); } diff --git a/src/pocketmine/entity/Entity.php b/src/pocketmine/entity/Entity.php index 96ea8d498..173cf5140 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -45,14 +45,14 @@ use pocketmine\math\Vector2; use pocketmine\math\Vector3; use pocketmine\metadata\Metadatable; use pocketmine\metadata\MetadataValue; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\Network; use pocketmine\network\protocol\MobEffectPacket; use pocketmine\network\protocol\RemoveEntityPacket; @@ -205,7 +205,7 @@ abstract class Entity extends Location implements Metadatable{ protected $isPlayer = false; - public function __construct(FullChunk $chunk, Compound $nbt){ + public function __construct(FullChunk $chunk, CompoundTag $nbt){ if($chunk === null or $chunk->getProvider() === null){ 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])); if(!isset($this->namedtag->FallDistance)){ - $this->namedtag->FallDistance = new Float("FallDistance", 0); + $this->namedtag->FallDistance = new FloatTag("FallDistance", 0); } $this->fallDistance = $this->namedtag["FallDistance"]; if(!isset($this->namedtag->Fire)){ - $this->namedtag->Fire = new Short("Fire", 0); + $this->namedtag->Fire = new ShortTag("Fire", 0); } $this->fireTicks = $this->namedtag["Fire"]; 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"]); 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; 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; @@ -407,12 +407,12 @@ abstract class Entity extends Location implements Metadatable{ /** * @param int|string $type * @param FullChunk $chunk - * @param Compound $nbt + * @param CompoundTag $nbt * @param $args * * @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])){ $class = self::$knownEntities[$type]; return new $class($chunk, $nbt, ...$args); @@ -449,52 +449,52 @@ abstract class Entity extends Location implements Metadatable{ public function saveNBT(){ if(!($this instanceof Player)){ - $this->namedtag->id = new String("id", $this->getSaveId()); + $this->namedtag->id = new StringTag("id", $this->getSaveId()); if($this->getNameTag() !== ""){ - $this->namedtag->CustomName = new String("CustomName", $this->getNameTag()); - $this->namedtag->CustomNameVisible = new String("CustomNameVisible", $this->isNameTagVisible()); + $this->namedtag->CustomName = new StringTag("CustomName", $this->getNameTag()); + $this->namedtag->CustomNameVisible = new StringTag("CustomNameVisible", $this->isNameTagVisible()); }else{ unset($this->namedtag->CustomName); unset($this->namedtag->CustomNameVisible); } } - $this->namedtag->Pos = new Enum("Pos", [ - new Double(0, $this->x), - new Double(1, $this->y), - new Double(2, $this->z) + $this->namedtag->Pos = new ListTag("Pos", [ + new DoubleTag(0, $this->x), + new DoubleTag(1, $this->y), + new DoubleTag(2, $this->z) ]); - $this->namedtag->Motion = new Enum("Motion", [ - new Double(0, $this->motionX), - new Double(1, $this->motionY), - new Double(2, $this->motionZ) + $this->namedtag->Motion = new ListTag("Motion", [ + new DoubleTag(0, $this->motionX), + new DoubleTag(1, $this->motionY), + new DoubleTag(2, $this->motionZ) ]); - $this->namedtag->Rotation = new Enum("Rotation", [ - new Float(0, $this->yaw), - new Float(1, $this->pitch) + $this->namedtag->Rotation = new ListTag("Rotation", [ + new FloatTag(0, $this->yaw), + new FloatTag(1, $this->pitch) ]); - $this->namedtag->FallDistance = new Float("FallDistance", $this->fallDistance); - $this->namedtag->Fire = new Short("Fire", $this->fireTicks); - $this->namedtag->Air = new Short("Air", $this->getDataProperty(self::DATA_AIR)); - $this->namedtag->OnGround = new Byte("OnGround", $this->onGround == true ? 1 : 0); - $this->namedtag->Invulnerable = new Byte("Invulnerable", $this->invulnerable == true ? 1 : 0); + $this->namedtag->FallDistance = new FloatTag("FallDistance", $this->fallDistance); + $this->namedtag->Fire = new ShortTag("Fire", $this->fireTicks); + $this->namedtag->Air = new ShortTag("Air", $this->getDataProperty(self::DATA_AIR)); + $this->namedtag->OnGround = new ByteTag("OnGround", $this->onGround == true ? 1 : 0); + $this->namedtag->Invulnerable = new ByteTag("Invulnerable", $this->invulnerable == true ? 1 : 0); if(count($this->effects) > 0){ $effects = []; foreach($this->effects as $effect){ - $effects[$effect->getId()] = new Compound($effect->getId(), [ - "Id" => new Byte("Id", $effect->getId()), - "Amplifier" => new Byte("Amplifier", $effect->getAmplifier()), - "Duration" => new Int("Duration", $effect->getDuration()), - "Ambient" => new Byte("Ambient", 0), - "ShowParticles" => new Byte("ShowParticles", $effect->isVisible() ? 1 : 0) + $effects[$effect->getId()] = new CompoundTag($effect->getId(), [ + "Id" => new ByteTag("Id", $effect->getId()), + "Amplifier" => new ByteTag("Amplifier", $effect->getAmplifier()), + "Duration" => new IntTag("Duration", $effect->getDuration()), + "Ambient" => new ByteTag("Ambient", 0), + "ShowParticles" => new ByteTag("ShowParticles", $effect->isVisible() ? 1 : 0) ]); } - $this->namedtag->ActiveEffects = new Enum("ActiveEffects", $effects); + $this->namedtag->ActiveEffects = new ListTag("ActiveEffects", $effects); }else{ unset($this->namedtag->ActiveEffects); } diff --git a/src/pocketmine/entity/FallingSand.php b/src/pocketmine/entity/FallingSand.php index 645741586..9d84af27d 100644 --- a/src/pocketmine/entity/FallingSand.php +++ b/src/pocketmine/entity/FallingSand.php @@ -30,8 +30,8 @@ use pocketmine\event\entity\EntityDamageEvent; use pocketmine\item\Item as ItemItem; use pocketmine\math\Vector3; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Int; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\IntTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddEntityPacket; use pocketmine\Player; @@ -58,7 +58,7 @@ class FallingSand extends Entity{ $this->blockId = $this->namedtag["TileID"]; }elseif(isset($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)){ @@ -153,8 +153,8 @@ class FallingSand extends Entity{ } public function saveNBT(){ - $this->namedtag->TileID = new Int("TileID", $this->blockId); - $this->namedtag->Data = new Byte("Data", $this->damage); + $this->namedtag->TileID = new IntTag("TileID", $this->blockId); + $this->namedtag->Data = new ByteTag("Data", $this->damage); } public function spawnTo(Player $player){ diff --git a/src/pocketmine/entity/Human.php b/src/pocketmine/entity/Human.php index 34e15f785..b02595962 100644 --- a/src/pocketmine/entity/Human.php +++ b/src/pocketmine/entity/Human.php @@ -26,11 +26,11 @@ use pocketmine\inventory\PlayerInventory; use pocketmine\item\Item as ItemItem; use pocketmine\utils\UUID; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddPlayerPacket; use pocketmine\network\protocol\RemovePlayerPacket; @@ -111,14 +111,14 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $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->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){ if($item["Slot"] >= 0 and $item["Slot"] < 9){ //Hotbar $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(){ parent::saveNBT(); - $this->namedtag->Inventory = new Enum("Inventory", []); + $this->namedtag->Inventory = new ListTag("Inventory", []); $this->namedtag->Inventory->setTagType(NBT::TAG_Compound); if($this->inventory !== null){ for($slot = 0; $slot < 9; ++$slot){ @@ -159,19 +159,19 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ $item = $this->inventory->getItem($hotbarSlot); if($item->getId() !== 0 and $item->getCount() > 0){ $tag = NBT::putItemHelper($item, $slot); - $tag->TrueSlot = new Byte("TrueSlot", $hotbarSlot); + $tag->TrueSlot = new ByteTag("TrueSlot", $hotbarSlot); $this->namedtag->Inventory[$slot] = $tag; continue; } } - $this->namedtag->Inventory[$slot] = new Compound("", [ - new Byte("Count", 0), - new Short("Damage", 0), - new Byte("Slot", $slot), - new Byte("TrueSlot", -1), - new Short("id", 0), + $this->namedtag->Inventory[$slot] = new CompoundTag("", [ + new ByteTag("Count", 0), + new ShortTag("Damage", 0), + new ByteTag("Slot", $slot), + new ByteTag("TrueSlot", -1), + new ShortTag("id", 0), ]); } @@ -193,9 +193,9 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{ } if(strlen($this->getSkinData()) > 0){ - $this->namedtag->Skin = new Compound("Skin", [ - "Data" => new String("Data", $this->getSkinData()), - "Slim" => new Byte("Slim", $this->isSkinSlim() ? 1 : 0) + $this->namedtag->Skin = new CompoundTag("Skin", [ + "Data" => new StringTag("Data", $this->getSkinData()), + "Slim" => new ByteTag("Slim", $this->isSkinSlim() ? 1 : 0) ]); } } diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index 686a6ed4a..e0df967bf 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -30,8 +30,8 @@ use pocketmine\item\Item as ItemItem; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddItemEntityPacket; use pocketmine\Player; @@ -160,14 +160,14 @@ class Item extends Entity{ public function saveNBT(){ parent::saveNBT(); $this->namedtag->Item = NBT::putItemHelper($this->item); - $this->namedtag->Health = new Short("Health", $this->getHealth()); - $this->namedtag->Age = new Short("Age", $this->age); - $this->namedtag->PickupDelay = new Short("PickupDelay", $this->pickupDelay); + $this->namedtag->Health = new ShortTag("Health", $this->getHealth()); + $this->namedtag->Age = new ShortTag("Age", $this->age); + $this->namedtag->PickupDelay = new ShortTag("PickupDelay", $this->pickupDelay); if($this->owner !== null){ - $this->namedtag->Owner = new String("Owner", $this->owner); + $this->namedtag->Owner = new StringTag("Owner", $this->owner); } if($this->thrower !== null){ - $this->namedtag->Thrower = new String("Thrower", $this->thrower); + $this->namedtag->Thrower = new StringTag("Thrower", $this->thrower); } } diff --git a/src/pocketmine/entity/Living.php b/src/pocketmine/entity/Living.php index 99c5514ef..c65d0bfa8 100644 --- a/src/pocketmine/entity/Living.php +++ b/src/pocketmine/entity/Living.php @@ -31,7 +31,7 @@ use pocketmine\event\entity\EntityRegainHealthEvent; use pocketmine\event\Timings; use pocketmine\item\Item as ItemItem; use pocketmine\math\Vector3; -use pocketmine\nbt\tag\Short; +use pocketmine\nbt\tag\ShortTag; use pocketmine\network\Network; use pocketmine\network\protocol\EntityEventPacket; @@ -51,12 +51,12 @@ abstract class Living extends Entity implements Damageable{ parent::initEntity(); 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); } - if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof Short)){ - $this->namedtag->Health = new Short("Health", $this->getMaxHealth()); + if(!isset($this->namedtag->Health) or !($this->namedtag->Health instanceof ShortTag)){ + $this->namedtag->Health = new ShortTag("Health", $this->getMaxHealth()); } $this->setHealth($this->namedtag["Health"]); @@ -75,7 +75,7 @@ abstract class Living extends Entity implements Damageable{ public function saveNBT(){ parent::saveNBT(); - $this->namedtag->Health = new Short("Health", $this->getHealth()); + $this->namedtag->Health = new ShortTag("Health", $this->getHealth()); } public abstract function getName(); diff --git a/src/pocketmine/entity/PrimedTNT.php b/src/pocketmine/entity/PrimedTNT.php index 3eb546d9e..7396a0339 100644 --- a/src/pocketmine/entity/PrimedTNT.php +++ b/src/pocketmine/entity/PrimedTNT.php @@ -26,7 +26,7 @@ use pocketmine\event\entity\EntityDamageEvent; use pocketmine\event\entity\ExplosionPrimeEvent; use pocketmine\level\Explosion; -use pocketmine\nbt\tag\Byte; +use pocketmine\nbt\tag\ByteTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddEntityPacket; use pocketmine\Player; @@ -69,7 +69,7 @@ class PrimedTNT extends Entity implements Explosive{ public function saveNBT(){ parent::saveNBT(); - $this->namedtag->Fuse = new Byte("Fuse", $this->fuse); + $this->namedtag->Fuse = new ByteTag("Fuse", $this->fuse); } public function onUpdate($currentTick){ diff --git a/src/pocketmine/entity/Projectile.php b/src/pocketmine/entity/Projectile.php index e37a418a6..31d238185 100644 --- a/src/pocketmine/entity/Projectile.php +++ b/src/pocketmine/entity/Projectile.php @@ -31,8 +31,8 @@ use pocketmine\event\entity\ProjectileHitEvent; use pocketmine\level\format\FullChunk; use pocketmine\level\MovingObjectPosition; use pocketmine\math\Vector3; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Short; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ShortTag; abstract class Projectile extends Entity{ @@ -44,7 +44,7 @@ abstract class Projectile extends Entity{ 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; if($shootingEntity !== null){ $this->setDataProperty(self::DATA_SHOOTER_ID, self::DATA_TYPE_LONG, $shootingEntity->getId()); @@ -75,7 +75,7 @@ abstract class Projectile extends Entity{ public function saveNBT(){ parent::saveNBT(); - $this->namedtag->Age = new Short("Age", $this->age); + $this->namedtag->Age = new ShortTag("Age", $this->age); } public function onUpdate($currentTick){ diff --git a/src/pocketmine/entity/Snowball.php b/src/pocketmine/entity/Snowball.php index b35d590af..fea8e55a0 100644 --- a/src/pocketmine/entity/Snowball.php +++ b/src/pocketmine/entity/Snowball.php @@ -23,7 +23,7 @@ namespace pocketmine\entity; use pocketmine\level\format\FullChunk; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddEntityPacket; use pocketmine\Player; @@ -38,7 +38,7 @@ class Snowball extends Projectile{ protected $gravity = 0.03; 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); } diff --git a/src/pocketmine/entity/Villager.php b/src/pocketmine/entity/Villager.php index 3aa458911..da304b55f 100644 --- a/src/pocketmine/entity/Villager.php +++ b/src/pocketmine/entity/Villager.php @@ -22,7 +22,7 @@ namespace pocketmine\entity; -use pocketmine\nbt\tag\Int; +use pocketmine\nbt\tag\IntTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddEntityPacket; use pocketmine\Player; @@ -76,7 +76,7 @@ class Villager extends Creature implements NPC, Ageable{ * @param $profession */ public function setProfession($profession){ - $this->namedtag->Profession = new Int("Profession", $profession); + $this->namedtag->Profession = new IntTag("Profession", $profession); } public function getProfession(){ diff --git a/src/pocketmine/inventory/InventoryType.php b/src/pocketmine/inventory/InventoryType.php index 046a6464f..4cdb22e6a 100644 --- a/src/pocketmine/inventory/InventoryType.php +++ b/src/pocketmine/inventory/InventoryType.php @@ -57,7 +57,7 @@ class InventoryType{ } 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::FURNACE] = new InventoryType(3, "Furnace", 2); static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT diff --git a/src/pocketmine/item/Item.php b/src/pocketmine/item/Item.php index e58fbd533..cb73fb81f 100644 --- a/src/pocketmine/item/Item.php +++ b/src/pocketmine/item/Item.php @@ -33,11 +33,11 @@ use pocketmine\entity\Zombie; use pocketmine\inventory\Fuel; use pocketmine\item\enchantment\Enchantment; use pocketmine\level\Level; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\Player; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\nbt\NBT; class Item{ @@ -46,7 +46,7 @@ class Item{ /** * @param $tag - * @return Compound + * @return CompoundTag */ private static function parseCompoundTag($tag){ if(self::$cachedParser === null){ @@ -58,10 +58,10 @@ class Item{ } /** - * @param Compound $tag + * @param CompoundTag $tag * @return string */ - private static function writeCompoundTag(Compound $tag){ + private static function writeCompoundTag(CompoundTag $tag){ if(self::$cachedParser === null){ 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_OXEYE_DAISY)); //TODO: Lilac - //TODO: Double Tallgrass + //TODO: DoubleTag Tallgrass //TODO: Large Fern //TODO: Rose Bush //TODO: Peony @@ -953,7 +953,7 @@ class Item{ } public function setCompoundTag($tags){ - if($tags instanceof Compound){ + if($tags instanceof CompoundTag){ $this->setNamedTag($tags); }else{ $this->tags = $tags; @@ -980,7 +980,7 @@ class Item{ } $tag = $this->getNamedTag(); - if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof Compound){ + if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){ return true; } @@ -993,7 +993,7 @@ class Item{ } $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); $this->setNamedTag($tag); } @@ -1001,12 +1001,12 @@ class Item{ return $this; } - public function setCustomBlockData(Compound $compound){ + public function setCustomBlockData(CompoundTag $compound){ $tags = clone $compound; $tags->setName("BlockEntityTag"); if(!$this->hasCompoundTag()){ - $tag = new Compound("", []); + $tag = new CompoundTag("", []); }else{ $tag = $this->getNamedTag(); } @@ -1023,7 +1023,7 @@ class Item{ } $tag = $this->getNamedTag(); - if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof Compound){ + if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){ return $tag->BlockEntityTag; } @@ -1038,7 +1038,7 @@ class Item{ $tag = $this->getNamedTag(); if(isset($tag->ench)){ $tag = $tag->ench; - if($tag instanceof Enum){ + if($tag instanceof ListTag){ return true; } } @@ -1071,13 +1071,13 @@ class Item{ */ public function addEnchantment(Enchantment $ench){ if(!$this->hasCompoundTag()){ - $tag = new Compound("", []); + $tag = new CompoundTag("", []); }else{ $tag = $this->getNamedTag(); } if(!isset($tag->ench)){ - $tag->ench = new Enum("ench", []); + $tag->ench = new ListTag("ench", []); $tag->ench->setTagType(NBT::TAG_Compound); } @@ -1085,9 +1085,9 @@ class Item{ foreach($tag->ench as $k => $entry){ if($entry["id"] === $ench->getId()){ - $tag->ench->{$k} = new Compound("", [ - "id" => new Short("id", $ench->getId()), - "lvl" => new Short("lvl", $ench->getLevel()) + $tag->ench->{$k} = new CompoundTag("", [ + "id" => new ShortTag("id", $ench->getId()), + "lvl" => new ShortTag("lvl", $ench->getLevel()) ]); $found = true; break; @@ -1095,9 +1095,9 @@ class Item{ } if(!$found){ - $tag->ench->{count($tag->ench) + 1} = new Compound("", [ - "id" => new Short("id", $ench->getId()), - "lvl" => new Short("lvl", $ench->getLevel()) + $tag->ench->{count($tag->ench) + 1} = new CompoundTag("", [ + "id" => new ShortTag("id", $ench->getId()), + "lvl" => new ShortTag("lvl", $ench->getLevel()) ]); } @@ -1131,7 +1131,7 @@ class Item{ $tag = $this->getNamedTag(); if(isset($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; } } @@ -1147,7 +1147,7 @@ class Item{ $tag = $this->getNamedTag(); if(isset($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(); } } @@ -1161,16 +1161,16 @@ class Item{ } if(!$this->hasCompoundTag()){ - $tag = new Compound("", []); + $tag = new CompoundTag("", []); }else{ $tag = $this->getNamedTag(); } - if(isset($tag->display) and $tag->display instanceof Compound){ - $tag->display->Name = new String("Name", $name); + if(isset($tag->display) and $tag->display instanceof CompoundTag){ + $tag->display->Name = new StringTag("Name", $name); }else{ - $tag->display = new Compound("display", [ - "Name" => new String("Name", $name) + $tag->display = new CompoundTag("display", [ + "Name" => new StringTag("Name", $name) ]); } @@ -1183,7 +1183,7 @@ class Item{ } $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); if($tag->display->getCount() === 0){ unset($tag->display); @@ -1213,7 +1213,7 @@ class Item{ return $this->cachedNBT = self::parseCompoundTag($this->tags); } - public function setNamedTag(Compound $tag){ + public function setNamedTag(CompoundTag $tag){ if($tag->getCount() === 0){ return $this->clearNamedTag(); } diff --git a/src/pocketmine/item/SpawnEgg.php b/src/pocketmine/item/SpawnEgg.php index 032882abd..8512d43dd 100644 --- a/src/pocketmine/item/SpawnEgg.php +++ b/src/pocketmine/item/SpawnEgg.php @@ -25,11 +25,11 @@ use pocketmine\block\Block; use pocketmine\entity\Entity; use pocketmine\level\format\FullChunk; use pocketmine\level\Level; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\Player; class SpawnEgg extends Item{ @@ -49,25 +49,25 @@ class SpawnEgg extends Item{ return false; } - $nbt = new Compound("", [ - "Pos" => new Enum("Pos", [ - new Double("", $block->getX() + 0.5), - new Double("", $block->getY()), - new Double("", $block->getZ() + 0.5) + $nbt = new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $block->getX() + 0.5), + new DoubleTag("", $block->getY()), + new DoubleTag("", $block->getZ() + 0.5) ]), - "Motion" => new Enum("Motion", [ - new Double("", 0), - new Double("", 0), - new Double("", 0) + "Motion" => new ListTag("Motion", [ + new DoubleTag("", 0), + new DoubleTag("", 0), + new DoubleTag("", 0) ]), - "Rotation" => new Enum("Rotation", [ - new Float("", lcg_value() * 360), - new Float("", 0) + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", lcg_value() * 360), + new FloatTag("", 0) ]), ]); if($this->hasCustomName()){ - $nbt->CustomName = new String("CustomName", $this->getCustomName()); + $nbt->CustomName = new StringTag("CustomName", $this->getCustomName()); } $entity = Entity::createEntity($this->meta, $chunk, $nbt); diff --git a/src/pocketmine/item/Tool.php b/src/pocketmine/item/Tool.php index cc3121025..7f3c0b833 100644 --- a/src/pocketmine/item/Tool.php +++ b/src/pocketmine/item/Tool.php @@ -24,7 +24,7 @@ namespace pocketmine\item; use pocketmine\block\Block; use pocketmine\entity\Entity; -use pocketmine\nbt\tag\Byte; +use pocketmine\nbt\tag\ByteTag; abstract class Tool extends Item{ const TIER_WOODEN = 1; diff --git a/src/pocketmine/level/Explosion.php b/src/pocketmine/level/Explosion.php index 8f6270cd5..706905804 100644 --- a/src/pocketmine/level/Explosion.php +++ b/src/pocketmine/level/Explosion.php @@ -32,11 +32,11 @@ use pocketmine\item\Item; use pocketmine\math\AxisAlignedBB; use pocketmine\math\Math; use pocketmine\math\Vector3; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; use pocketmine\network\Network; use pocketmine\network\protocol\ExplodePacket; @@ -186,22 +186,22 @@ class Explosion{ foreach($this->affectedBlocks as $block){ if($block->getId() === Block::TNT){ $mot = (new Random())->nextSignedFloat() * M_PI * 2; - $tnt = Entity::createEntity("PrimedTNT", $this->level->getChunk($block->x >> 4, $block->z >> 4), new Compound("", [ - "Pos" => new Enum("Pos", [ - new Double("", $block->x + 0.5), - new Double("", $block->y), - new Double("", $block->z + 0.5) + $tnt = Entity::createEntity("PrimedTNT", $this->level->getChunk($block->x >> 4, $block->z >> 4), new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $block->x + 0.5), + new DoubleTag("", $block->y), + new DoubleTag("", $block->z + 0.5) ]), - "Motion" => new Enum("Motion", [ - new Double("", -sin($mot) * 0.02), - new Double("", 0.2), - new Double("", -cos($mot) * 0.02) + "Motion" => new ListTag("Motion", [ + new DoubleTag("", -sin($mot) * 0.02), + new DoubleTag("", 0.2), + new DoubleTag("", -cos($mot) * 0.02) ]), - "Rotation" => new Enum("Rotation", [ - new Float("", 0), - new Float("", 0) + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", 0), + new FloatTag("", 0) ]), - "Fuse" => new Byte("Fuse", mt_rand(10, 30)) + "Fuse" => new ByteTag("Fuse", mt_rand(10, 30)) ])); $tnt->spawnToAll(); }elseif(mt_rand(0, 100) < $yield){ diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 173d367bb..f6afcdfd0 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -81,13 +81,13 @@ use pocketmine\metadata\Metadatable; use pocketmine\metadata\MetadataValue; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\Network; use pocketmine\network\protocol\DataPacket; use pocketmine\network\protocol\FullChunkDataPacket; @@ -1466,25 +1466,25 @@ class Level implements ChunkManager, Metadatable{ $itemTag->setName("Item"); if($item->getId() > 0 and $item->getCount() > 0){ - $itemEntity = Entity::createEntity("Item", $this->getChunk($source->getX() >> 4, $source->getZ() >> 4, true), new Compound("", [ - "Pos" => new Enum("Pos", [ - new Double("", $source->getX()), - new Double("", $source->getY()), - new Double("", $source->getZ()) + $itemEntity = Entity::createEntity("Item", $this->getChunk($source->getX() >> 4, $source->getZ() >> 4, true), new CompoundTag("", [ + "Pos" => new ListTag("Pos", [ + new DoubleTag("", $source->getX()), + new DoubleTag("", $source->getY()), + new DoubleTag("", $source->getZ()) ]), - "Motion" => new Enum("Motion", [ - new Double("", $motion->x), - new Double("", $motion->y), - new Double("", $motion->z) + "Motion" => new ListTag("Motion", [ + new DoubleTag("", $motion->x), + new DoubleTag("", $motion->y), + new DoubleTag("", $motion->z) ]), - "Rotation" => new Enum("Rotation", [ - new Float("", lcg_value() * 360), - new Float("", 0) + "Rotation" => new ListTag("Rotation", [ + new FloatTag("", lcg_value() * 360), + new FloatTag("", 0) ]), - "Health" => new Short("Health", 5), + "Health" => new ShortTag("Health", 5), "Item" => $itemTag, - "PickupDelay" => new Short("PickupDelay", $delay) + "PickupDelay" => new ShortTag("PickupDelay", $delay) ])); $itemEntity->spawnToAll(); @@ -1568,10 +1568,10 @@ class Level implements ChunkManager, Metadatable{ } $tag = $item->getNamedTagEntry("CanDestroy"); - if($tag instanceof Enum){ + if($tag instanceof ListTag){ $canBreak = false; foreach($tag as $v){ - if($v instanceof String){ + if($v instanceof StringTag){ $entry = Item::fromString($v->getValue()); if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){ $canBreak = true; @@ -1730,10 +1730,10 @@ class Level implements ChunkManager, Metadatable{ } $tag = $item->getNamedTagEntry("CanPlaceOn"); - if($tag instanceof Enum){ + if($tag instanceof ListTag){ $canPlace = false; foreach($tag as $v){ - if($v instanceof String){ + if($v instanceof StringTag){ $entry = Item::fromString($v->getValue()); if($entry->getId() > 0 and $entry->getBlock() !== null and $entry->getBlock()->getId() === $target->getId()){ $canPlace = true; @@ -1769,19 +1769,19 @@ class Level implements ChunkManager, Metadatable{ if($hand->getId() === Item::SIGN_POST or $hand->getId() === Item::WALL_SIGN){ - $nbt = new Compound("", [ - "id" => new String("id", Tile::SIGN), - "x" => new Int("x", $block->x), - "y" => new Int("y", $block->y), - "z" => new Int("z", $block->z), - "Text1" => new String("Text1", ""), - "Text2" => new String("Text2", ""), - "Text3" => new String("Text3", ""), - "Text4" => new String("Text4", "") + $nbt = new CompoundTag("", [ + "id" => new StringTag("id", Tile::SIGN), + "x" => new IntTag("x", $block->x), + "y" => new IntTag("y", $block->y), + "z" => new IntTag("z", $block->z), + "Text1" => new StringTag("Text1", ""), + "Text2" => new StringTag("Text2", ""), + "Text3" => new StringTag("Text3", ""), + "Text4" => new StringTag("Text4", "") ]); if($player !== null){ - $nbt->Creator = new String("Creator", $player->getRawUniqueId()); + $nbt->Creator = new StringTag("Creator", $player->getRawUniqueId()); } if($item->hasCustomBlockData()){ diff --git a/src/pocketmine/level/format/anvil/Anvil.php b/src/pocketmine/level/format/anvil/Anvil.php index 5e0ccd5a6..a12881ded 100644 --- a/src/pocketmine/level/format/anvil/Anvil.php +++ b/src/pocketmine/level/format/anvil/Anvil.php @@ -25,9 +25,9 @@ use pocketmine\level\format\FullChunk; use pocketmine\level\format\mcregion\McRegion; use pocketmine\level\Level; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\ByteArray; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\ByteArrayTag; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\tile\Spawnable; use pocketmine\utils\BinaryStream; @@ -152,12 +152,12 @@ class Anvil extends McRegion{ } public static function createChunkSection($Y){ - return new ChunkSection(new Compound("", [ - "Y" => new Byte("Y", $Y), - "Blocks" => new ByteArray("Blocks", str_repeat("\x00", 4096)), - "Data" => new ByteArray("Data", str_repeat("\x00", 2048)), - "SkyLight" => new ByteArray("SkyLight", str_repeat("\xff", 2048)), - "BlockLight" => new ByteArray("BlockLight", str_repeat("\x00", 2048)) + return new ChunkSection(new CompoundTag("", [ + "Y" => new ByteTag("Y", $Y), + "Blocks" => new ByteArrayTag("Blocks", str_repeat("\x00", 4096)), + "Data" => new ByteArrayTag("Data", str_repeat("\x00", 2048)), + "SkyLight" => new ByteArrayTag("SkyLight", str_repeat("\xff", 2048)), + "BlockLight" => new ByteArrayTag("BlockLight", str_repeat("\x00", 2048)) ])); } diff --git a/src/pocketmine/level/format/anvil/Chunk.php b/src/pocketmine/level/format/anvil/Chunk.php index 557db546e..d4ebd564a 100644 --- a/src/pocketmine/level/format/anvil/Chunk.php +++ b/src/pocketmine/level/format/anvil/Chunk.php @@ -25,62 +25,62 @@ use pocketmine\level\format\generic\BaseChunk; use pocketmine\level\format\generic\EmptyChunkSection; use pocketmine\level\format\LevelProvider; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\ByteArray; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\IntArray; -use pocketmine\nbt\tag\Long; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\ByteArrayTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\IntArrayTag; +use pocketmine\nbt\tag\LongTag; use pocketmine\Player; use pocketmine\utils\Binary; use pocketmine\utils\BinaryStream; class Chunk extends BaseChunk{ - /** @var Compound */ + /** @var CompoundTag */ protected $nbt; - public function __construct($level, Compound $nbt = null){ + public function __construct($level, CompoundTag $nbt = null){ if($nbt === null){ $this->provider = $level; - $this->nbt = new Compound("Level", []); + $this->nbt = new CompoundTag("Level", []); return; } $this->nbt = $nbt; - if(!isset($this->nbt->Entities) or !($this->nbt->Entities instanceof Enum)){ - $this->nbt->Entities = new Enum("Entities", []); + if(!isset($this->nbt->Entities) or !($this->nbt->Entities instanceof ListTag)){ + $this->nbt->Entities = new ListTag("Entities", []); $this->nbt->Entities->setTagType(NBT::TAG_Compound); } - if(!isset($this->nbt->TileEntities) or !($this->nbt->TileEntities instanceof Enum)){ - $this->nbt->TileEntities = new Enum("TileEntities", []); + if(!isset($this->nbt->TileEntities) or !($this->nbt->TileEntities instanceof ListTag)){ + $this->nbt->TileEntities = new ListTag("TileEntities", []); $this->nbt->TileEntities->setTagType(NBT::TAG_Compound); } - if(!isset($this->nbt->TileTicks) or !($this->nbt->TileTicks instanceof Enum)){ - $this->nbt->TileTicks = new Enum("TileTicks", []); + if(!isset($this->nbt->TileTicks) or !($this->nbt->TileTicks instanceof ListTag)){ + $this->nbt->TileTicks = new ListTag("TileTicks", []); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound); } - if(!isset($this->nbt->Sections) or !($this->nbt->Sections instanceof Enum)){ - $this->nbt->Sections = new Enum("Sections", []); + if(!isset($this->nbt->Sections) or !($this->nbt->Sections instanceof ListTag)){ + $this->nbt->Sections = new ListTag("Sections", []); $this->nbt->Sections->setTagType(NBT::TAG_Compound); } - if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){ - $this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, 0)); + if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArrayTag)){ + $this->nbt->BiomeColors = new IntArrayTag("BiomeColors", array_fill(0, 256, 0)); } - if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArray)){ - $this->nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 0)); + if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArrayTag)){ + $this->nbt->HeightMap = new IntArrayTag("HeightMap", array_fill(0, 256, 0)); } $sections = []; foreach($this->nbt->Sections as $section){ - if($section instanceof Compound){ + if($section instanceof CompoundTag){ $y = (int) $section["Y"]; if($y < 8){ $sections[$y] = new ChunkSection($section); @@ -95,8 +95,8 @@ class Chunk extends BaseChunk{ $extraData = []; - if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArray)){ - $this->nbt->ExtraData = new ByteArray("ExtraData", Binary::writeInt(0)); + if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArrayTag)){ + $this->nbt->ExtraData = new ByteArrayTag("ExtraData", Binary::writeInt(0)); }else{ $stream = new BinaryStream($this->nbt->ExtraData->getValue()); $count = $stream->getInt(); @@ -121,7 +121,7 @@ class Chunk extends BaseChunk{ } public function setLightPopulated($value = 1){ - $this->nbt->LightPopulated = new Byte("LightPopulated", $value); + $this->nbt->LightPopulated = new ByteTag("LightPopulated", $value); $this->hasChanged = true; } @@ -136,7 +136,7 @@ class Chunk extends BaseChunk{ * @param int $value */ public function setPopulated($value = 1){ - $this->nbt->TerrainPopulated = new Byte("TerrainPopulated", $value); + $this->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", $value); $this->hasChanged = true; } @@ -151,12 +151,12 @@ class Chunk extends BaseChunk{ * @param int $value */ public function setGenerated($value = 1){ - $this->nbt->TerrainGenerated = new Byte("TerrainGenerated", $value); + $this->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", $value); $this->hasChanged = true; } /** - * @return Compound + * @return CompoundTag */ public function getNBT(){ return $this->nbt; @@ -175,7 +175,7 @@ class Chunk extends BaseChunk{ $nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE); $chunk = $nbt->getData(); - if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){ + if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){ return null; } @@ -198,7 +198,7 @@ class Chunk extends BaseChunk{ $nbt->read($data); $chunk = $nbt->getData(); - if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){ + if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){ return null; } @@ -211,27 +211,27 @@ class Chunk extends BaseChunk{ public function toFastBinary(){ $nbt = clone $this->getNBT(); - $nbt->xPos = new Int("xPos", $this->x); - $nbt->zPos = new Int("zPos", $this->z); + $nbt->xPos = new IntTag("xPos", $this->x); + $nbt->zPos = new IntTag("zPos", $this->z); - $nbt->Sections = new Enum("Sections", []); + $nbt->Sections = new ListTag("Sections", []); $nbt->Sections->setTagType(NBT::TAG_Compound); foreach($this->getSections() as $section){ if($section instanceof EmptyChunkSection){ continue; } - $nbt->Sections[$section->getY()] = new Compound(null, [ - "Y" => new Byte("Y", $section->getY()), - "Blocks" => new ByteArray("Blocks", $section->getIdArray()), - "Data" => new ByteArray("Data", $section->getDataArray()), - "BlockLight" => new ByteArray("BlockLight", $section->getLightArray()), - "SkyLight" => new ByteArray("SkyLight", $section->getSkyLightArray()) + $nbt->Sections[$section->getY()] = new CompoundTag(null, [ + "Y" => new ByteTag("Y", $section->getY()), + "Blocks" => new ByteArrayTag("Blocks", $section->getIdArray()), + "Data" => new ByteArrayTag("Data", $section->getDataArray()), + "BlockLight" => new ByteArrayTag("BlockLight", $section->getLightArray()), + "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 = []; @@ -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); @@ -252,7 +252,7 @@ class Chunk extends BaseChunk{ $tiles[] = $tile->namedtag; } - $nbt->TileEntities = new Enum("TileEntities", $tiles); + $nbt->TileEntities = new ListTag("TileEntities", $tiles); $nbt->TileEntities->setTagType(NBT::TAG_Compound); $extraData = new BinaryStream(); @@ -262,11 +262,11 @@ class Chunk extends BaseChunk{ $extraData->putShort($value); } - $nbt->ExtraData = new ByteArray("ExtraData", $extraData->getBuffer()); + $nbt->ExtraData = new ByteArrayTag("ExtraData", $extraData->getBuffer()); $writer = new NBT(NBT::BIG_ENDIAN); $nbt->setName("Level"); - $writer->setData(new Compound("", ["Level" => $nbt])); + $writer->setData(new CompoundTag("", ["Level" => $nbt])); return $writer->write(); } @@ -274,27 +274,27 @@ class Chunk extends BaseChunk{ public function toBinary(){ $nbt = clone $this->getNBT(); - $nbt->xPos = new Int("xPos", $this->x); - $nbt->zPos = new Int("zPos", $this->z); + $nbt->xPos = new IntTag("xPos", $this->x); + $nbt->zPos = new IntTag("zPos", $this->z); - $nbt->Sections = new Enum("Sections", []); + $nbt->Sections = new ListTag("Sections", []); $nbt->Sections->setTagType(NBT::TAG_Compound); foreach($this->getSections() as $section){ if($section instanceof EmptyChunkSection){ continue; } - $nbt->Sections[$section->getY()] = new Compound(null, [ - "Y" => new Byte("Y", $section->getY()), - "Blocks" => new ByteArray("Blocks", $section->getIdArray()), - "Data" => new ByteArray("Data", $section->getDataArray()), - "BlockLight" => new ByteArray("BlockLight", $section->getLightArray()), - "SkyLight" => new ByteArray("SkyLight", $section->getSkyLightArray()) + $nbt->Sections[$section->getY()] = new CompoundTag(null, [ + "Y" => new ByteTag("Y", $section->getY()), + "Blocks" => new ByteArrayTag("Blocks", $section->getIdArray()), + "Data" => new ByteArrayTag("Data", $section->getDataArray()), + "BlockLight" => new ByteArrayTag("BlockLight", $section->getLightArray()), + "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 = []; @@ -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); @@ -315,7 +315,7 @@ class Chunk extends BaseChunk{ $tiles[] = $tile->namedtag; } - $nbt->TileEntities = new Enum("TileEntities", $tiles); + $nbt->TileEntities = new ListTag("TileEntities", $tiles); $nbt->TileEntities->setTagType(NBT::TAG_Compound); $extraData = new BinaryStream(); @@ -325,11 +325,11 @@ class Chunk extends BaseChunk{ $extraData->putShort($value); } - $nbt->ExtraData = new ByteArray("ExtraData", $extraData->getBuffer()); + $nbt->ExtraData = new ByteArrayTag("ExtraData", $extraData->getBuffer()); $writer = new NBT(NBT::BIG_ENDIAN); $nbt->setName("Level"); - $writer->setData(new Compound("", ["Level" => $nbt])); + $writer->setData(new CompoundTag("", ["Level" => $nbt])); 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->biomeColors = array_fill(0, 256, 0); - $chunk->nbt->V = new Byte("V", 1); - $chunk->nbt->InhabitedTime = new Long("InhabitedTime", 0); - $chunk->nbt->TerrainGenerated = new Byte("TerrainGenerated", 0); - $chunk->nbt->TerrainPopulated = new Byte("TerrainPopulated", 0); - $chunk->nbt->LightPopulated = new Byte("LightPopulated", 0); + $chunk->nbt->V = new ByteTag("V", 1); + $chunk->nbt->InhabitedTime = new LongTag("InhabitedTime", 0); + $chunk->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", 0); + $chunk->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", 0); + $chunk->nbt->LightPopulated = new ByteTag("LightPopulated", 0); return $chunk; }catch(\Exception $e){ diff --git a/src/pocketmine/level/format/anvil/ChunkSection.php b/src/pocketmine/level/format/anvil/ChunkSection.php index bb42a551d..b1c8731f9 100644 --- a/src/pocketmine/level/format/anvil/ChunkSection.php +++ b/src/pocketmine/level/format/anvil/ChunkSection.php @@ -21,7 +21,7 @@ namespace pocketmine\level\format\anvil; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; class ChunkSection implements \pocketmine\level\format\ChunkSection{ @@ -31,7 +31,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{ private $blockLight; private $skyLight; - public function __construct(Compound $nbt){ + public function __construct(CompoundTag $nbt){ $this->y = (int) $nbt["Y"]; $this->blocks = (string) $nbt["Blocks"]; $this->data = (string) $nbt["Data"]; diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index 1b54b1603..0baab47f1 100644 --- a/src/pocketmine/level/format/generic/BaseChunk.php +++ b/src/pocketmine/level/format/generic/BaseChunk.php @@ -24,7 +24,7 @@ namespace pocketmine\level\format\generic; use pocketmine\level\format\Chunk; use pocketmine\level\format\ChunkSection; use pocketmine\level\format\LevelProvider; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\utils\Binary; use pocketmine\utils\ChunkException; @@ -40,8 +40,8 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ * @param ChunkSection[] $sections * @param int[] $biomeColors * @param int[] $heightMap - * @param Compound[] $entities - * @param Compound[] $tiles + * @param CompoundTag[] $entities + * @param CompoundTag[] $tiles * * @throws ChunkException */ diff --git a/src/pocketmine/level/format/generic/BaseFullChunk.php b/src/pocketmine/level/format/generic/BaseFullChunk.php index 4a163eca0..d1d89bf12 100644 --- a/src/pocketmine/level/format/generic/BaseFullChunk.php +++ b/src/pocketmine/level/format/generic/BaseFullChunk.php @@ -27,7 +27,7 @@ use pocketmine\level\format\FullChunk; use pocketmine\level\format\LevelProvider; use pocketmine\level\generator\biome\Biome; use pocketmine\level\Level; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\Player; use pocketmine\tile\Tile; @@ -82,8 +82,8 @@ abstract class BaseFullChunk implements FullChunk{ * @param string $blockLight * @param int[] $biomeColors * @param int[] $heightMap - * @param Compound[] $entities - * @param Compound[] $tiles + * @param CompoundTag[] $entities + * @param CompoundTag[] $tiles */ protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = [], array $extraData = []){ $this->provider = $provider; @@ -134,7 +134,7 @@ abstract class BaseFullChunk implements FullChunk{ if($this->NBTentities !== null){ $this->getProvider()->getLevel()->timings->syncChunkLoadEntitiesTimer->startTiming(); foreach($this->NBTentities as $nbt){ - if($nbt instanceof Compound){ + if($nbt instanceof CompoundTag){ if(!isset($nbt->id)){ $this->setChanged(); continue; @@ -157,7 +157,7 @@ abstract class BaseFullChunk implements FullChunk{ $this->getProvider()->getLevel()->timings->syncChunkLoadTileEntitiesTimer->startTiming(); foreach($this->NBTtiles as $nbt){ - if($nbt instanceof Compound){ + if($nbt instanceof CompoundTag){ if(!isset($nbt->id)){ $changed = true; continue; diff --git a/src/pocketmine/level/format/generic/BaseLevelProvider.php b/src/pocketmine/level/format/generic/BaseLevelProvider.php index 2682b5cdf..dd5d2c11b 100644 --- a/src/pocketmine/level/format/generic/BaseLevelProvider.php +++ b/src/pocketmine/level/format/generic/BaseLevelProvider.php @@ -26,9 +26,9 @@ use pocketmine\level\generator\Generator; use pocketmine\level\Level; use pocketmine\math\Vector3; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\utils\LevelException; abstract class BaseLevelProvider implements LevelProvider{ @@ -36,7 +36,7 @@ abstract class BaseLevelProvider implements LevelProvider{ protected $level; /** @var string */ protected $path; - /** @var Compound */ + /** @var CompoundTag */ protected $levelData; public function __construct(Level $level, $path){ @@ -48,18 +48,18 @@ abstract class BaseLevelProvider implements LevelProvider{ $nbt = new NBT(NBT::BIG_ENDIAN); $nbt->readCompressed(file_get_contents($this->getPath() . "level.dat")); $levelData = $nbt->getData(); - if($levelData->Data instanceof Compound){ + if($levelData->Data instanceof CompoundTag){ $this->levelData = $levelData->Data; }else{ throw new LevelException("Invalid level.dat"); } 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)){ - $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){ - $this->levelData->Time = new Int("Time", (int) $value); + $this->levelData->Time = new IntTag("Time", (int) $value); } public function getSeed(){ @@ -92,7 +92,7 @@ abstract class BaseLevelProvider implements LevelProvider{ } public function setSeed($value){ - $this->levelData->RandomSeed = new Int("RandomSeed", (int) $value); + $this->levelData->RandomSeed = new IntTag("RandomSeed", (int) $value); } public function getSpawn(){ @@ -100,9 +100,9 @@ abstract class BaseLevelProvider implements LevelProvider{ } public function setSpawn(Vector3 $pos){ - $this->levelData->SpawnX = new Int("SpawnX", (int) $pos->x); - $this->levelData->SpawnY = new Int("SpawnY", (int) $pos->y); - $this->levelData->SpawnZ = new Int("SpawnZ", (int) $pos->z); + $this->levelData->SpawnX = new IntTag("SpawnX", (int) $pos->x); + $this->levelData->SpawnY = new IntTag("SpawnY", (int) $pos->y); + $this->levelData->SpawnZ = new IntTag("SpawnZ", (int) $pos->z); } public function doGarbageCollection(){ @@ -110,7 +110,7 @@ abstract class BaseLevelProvider implements LevelProvider{ } /** - * @return Compound + * @return CompoundTag */ public function getLevelData(){ return $this->levelData; @@ -118,7 +118,7 @@ abstract class BaseLevelProvider implements LevelProvider{ public function saveLevelData(){ $nbt = new NBT(NBT::BIG_ENDIAN); - $nbt->setData(new Compound("", [ + $nbt->setData(new CompoundTag("", [ "Data" => $this->levelData ])); $buffer = $nbt->writeCompressed(); diff --git a/src/pocketmine/level/format/leveldb/LevelDB.php b/src/pocketmine/level/format/leveldb/LevelDB.php index 819f7fc7f..2d94241e9 100644 --- a/src/pocketmine/level/format/leveldb/LevelDB.php +++ b/src/pocketmine/level/format/leveldb/LevelDB.php @@ -26,11 +26,11 @@ use pocketmine\level\format\generic\BaseLevelProvider; use pocketmine\level\generator\Generator; use pocketmine\level\Level; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\Long; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\LongTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\tile\Spawnable; use pocketmine\utils\Binary; use pocketmine\utils\BinaryStream; @@ -62,18 +62,18 @@ class LevelDB extends BaseLevelProvider{ $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->read(substr(file_get_contents($this->getPath() . "level.dat"), 8)); $levelData = $nbt->getData(); - if($levelData instanceof Compound){ + if($levelData instanceof CompoundTag){ $this->levelData = $levelData; }else{ throw new LevelException("Invalid level.dat"); } 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)){ - $this->levelData->generatorOptions = new String("generatorOptions", ""); + $this->levelData->generatorOptions = new StringTag("generatorOptions", ""); } $this->db = new \LevelDB($this->path . "/db", [ @@ -105,24 +105,24 @@ class LevelDB extends BaseLevelProvider{ mkdir($path . "/db", 0777, true); } //TODO, add extra details - $levelData = new Compound("", [ - "hardcore" => new Byte("hardcore", 0), - "initialized" => new Byte("initialized", 1), - "GameType" => new Int("GameType", 0), - "generatorVersion" => new Int("generatorVersion", 1), //2 in MCPE - "SpawnX" => new Int("SpawnX", 128), - "SpawnY" => new Int("SpawnY", 70), - "SpawnZ" => new Int("SpawnZ", 128), - "version" => new Int("version", 19133), - "DayTime" => new Int("DayTime", 0), - "LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), - "RandomSeed" => new Long("RandomSeed", $seed), - "SizeOnDisk" => new Long("SizeOnDisk", 0), - "Time" => new Long("Time", 0), - "generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), - "generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), - "LevelName" => new String("LevelName", $name), - "GameRules" => new Compound("GameRules", []) + $levelData = new CompoundTag("", [ + "hardcore" => new ByteTag("hardcore", 0), + "initialized" => new ByteTag("initialized", 1), + "GameType" => new IntTag("GameType", 0), + "generatorVersion" => new IntTag("generatorVersion", 1), //2 in MCPE + "SpawnX" => new IntTag("SpawnX", 128), + "SpawnY" => new IntTag("SpawnY", 70), + "SpawnZ" => new IntTag("SpawnZ", 128), + "version" => new IntTag("version", 19133), + "DayTime" => new IntTag("DayTime", 0), + "LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000), + "RandomSeed" => new LongTag("RandomSeed", $seed), + "SizeOnDisk" => new LongTag("SizeOnDisk", 0), + "Time" => new LongTag("Time", 0), + "generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)), + "generatorOptions" => new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), + "LevelName" => new StringTag("LevelName", $name), + "GameRules" => new CompoundTag("GameRules", []) ]); $nbt = new NBT(NBT::LITTLE_ENDIAN); $nbt->setData($levelData); diff --git a/src/pocketmine/level/format/mcregion/Chunk.php b/src/pocketmine/level/format/mcregion/Chunk.php index aee98c90d..0d4909f31 100644 --- a/src/pocketmine/level/format/mcregion/Chunk.php +++ b/src/pocketmine/level/format/mcregion/Chunk.php @@ -24,74 +24,74 @@ namespace pocketmine\level\format\mcregion; use pocketmine\level\format\generic\BaseFullChunk; use pocketmine\level\format\LevelProvider; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\ByteArray; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\IntArray; -use pocketmine\nbt\tag\Long; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\ByteArrayTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\IntArrayTag; +use pocketmine\nbt\tag\LongTag; use pocketmine\Player; use pocketmine\utils\Binary; use pocketmine\utils\BinaryStream; class Chunk extends BaseFullChunk{ - /** @var Compound */ + /** @var CompoundTag */ protected $nbt; - public function __construct($level, Compound $nbt = null){ + public function __construct($level, CompoundTag $nbt = null){ if($nbt === null){ $this->provider = $level; - $this->nbt = new Compound("Level", []); + $this->nbt = new CompoundTag("Level", []); return; } $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); }else{ - $this->nbt->Entities = new Enum("Entities", []); + $this->nbt->Entities = new ListTag("Entities", []); $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); }else{ - $this->nbt->TileEntities = new Enum("TileEntities", []); + $this->nbt->TileEntities = new ListTag("TileEntities", []); $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); }else{ - $this->nbt->TileTicks = new Enum("TileTicks", []); + $this->nbt->TileTicks = new ListTag("TileTicks", []); $this->nbt->TileTicks->setTagType(NBT::TAG_Compound); } - if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArray)){ - $this->nbt->BiomeColors = new IntArray("BiomeColors", array_fill(0, 256, 0)); + if(!isset($this->nbt->BiomeColors) or !($this->nbt->BiomeColors instanceof IntArrayTag)){ + $this->nbt->BiomeColors = new IntArrayTag("BiomeColors", array_fill(0, 256, 0)); } - if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArray)){ - $this->nbt->HeightMap = new IntArray("HeightMap", array_fill(0, 256, 0)); + if(!isset($this->nbt->HeightMap) or !($this->nbt->HeightMap instanceof IntArrayTag)){ + $this->nbt->HeightMap = new IntArrayTag("HeightMap", array_fill(0, 256, 0)); } 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)){ - $this->nbt->Data = new ByteArray("Data", $half = str_repeat("\x00", 16384)); - $this->nbt->SkyLight = new ByteArray("SkyLight", $half); - $this->nbt->BlockLight = new ByteArray("BlockLight", $half); + $this->nbt->Data = new ByteArrayTag("Data", $half = str_repeat("\x00", 16384)); + $this->nbt->SkyLight = new ByteArrayTag("SkyLight", $half); + $this->nbt->BlockLight = new ByteArrayTag("BlockLight", $half); } $extraData = []; - if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArray)){ - $this->nbt->ExtraData = new ByteArray("ExtraData", Binary::writeInt(0)); + if(!isset($this->nbt->ExtraData) or !($this->nbt->ExtraData instanceof ByteArrayTag)){ + $this->nbt->ExtraData = new ByteArrayTag("ExtraData", Binary::writeInt(0)); }else{ $stream = new BinaryStream($this->nbt->ExtraData->getValue()); $count = $stream->getInt(); @@ -258,7 +258,7 @@ class Chunk extends BaseFullChunk{ } 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; } @@ -273,7 +273,7 @@ class Chunk extends BaseFullChunk{ * @param int $value */ 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; } @@ -293,7 +293,7 @@ class Chunk extends BaseFullChunk{ * @param int $value */ public function setGenerated($value = 1){ - $this->nbt->TerrainGenerated = new Byte("TerrainGenerated", (int) $value); + $this->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", (int) $value); $this->hasChanged = true; } @@ -310,7 +310,7 @@ class Chunk extends BaseFullChunk{ $nbt->readCompressed($data, ZLIB_ENCODING_DEFLATE); $chunk = $nbt->getData(); - if(!isset($chunk->Level) or !($chunk->Level instanceof Compound)){ + if(!isset($chunk->Level) or !($chunk->Level instanceof CompoundTag)){ return null; } @@ -348,9 +348,9 @@ class Chunk extends BaseFullChunk{ $flags = ord($data{$offset++}); - $chunk->nbt->TerrainGenerated = new Byte("TerrainGenerated", $flags & 0b1); - $chunk->nbt->TerrainPopulated = new Byte("TerrainPopulated", ($flags >> 1) & 0b1); - $chunk->nbt->LightPopulated = new Byte("LightPopulated", ($flags >> 2) & 0b1); + $chunk->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", $flags & 0b1); + $chunk->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", ($flags >> 1) & 0b1); + $chunk->nbt->LightPopulated = new ByteTag("LightPopulated", ($flags >> 2) & 0b1); return $chunk; }catch(\Exception $e){ @@ -374,18 +374,18 @@ class Chunk extends BaseFullChunk{ public function toBinary(){ $nbt = clone $this->getNBT(); - $nbt->xPos = new Int("xPos", $this->x); - $nbt->zPos = new Int("zPos", $this->z); + $nbt->xPos = new IntTag("xPos", $this->x); + $nbt->zPos = new IntTag("zPos", $this->z); if($this->isGenerated()){ - $nbt->Blocks = new ByteArray("Blocks", $this->getBlockIdArray()); - $nbt->Data = new ByteArray("Data", $this->getBlockDataArray()); - $nbt->SkyLight = new ByteArray("SkyLight", $this->getBlockSkyLightArray()); - $nbt->BlockLight = new ByteArray("BlockLight", $this->getBlockLightArray()); + $nbt->Blocks = new ByteArrayTag("Blocks", $this->getBlockIdArray()); + $nbt->Data = new ByteArrayTag("Data", $this->getBlockDataArray()); + $nbt->SkyLight = new ByteArrayTag("SkyLight", $this->getBlockSkyLightArray()); + $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 = []; @@ -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); @@ -407,7 +407,7 @@ class Chunk extends BaseFullChunk{ $tiles[] = $tile->namedtag; } - $nbt->TileEntities = new Enum("TileEntities", $tiles); + $nbt->TileEntities = new ListTag("TileEntities", $tiles); $nbt->TileEntities->setTagType(NBT::TAG_Compound); $extraData = new BinaryStream(); @@ -417,17 +417,17 @@ class Chunk extends BaseFullChunk{ $extraData->putShort($value); } - $nbt->ExtraData = new ByteArray("ExtraData", $extraData->getBuffer()); + $nbt->ExtraData = new ByteArrayTag("ExtraData", $extraData->getBuffer()); $writer = new NBT(NBT::BIG_ENDIAN); $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 Compound + * @return CompoundTag */ public function getNBT(){ return $this->nbt; @@ -454,11 +454,11 @@ class Chunk extends BaseFullChunk{ $chunk->heightMap = array_fill(0, 256, 0); $chunk->biomeColors = array_fill(0, 256, 0); - $chunk->nbt->V = new Byte("V", 1); - $chunk->nbt->InhabitedTime = new Long("InhabitedTime", 0); - $chunk->nbt->TerrainGenerated = new Byte("TerrainGenerated", 0); - $chunk->nbt->TerrainPopulated = new Byte("TerrainPopulated", 0); - $chunk->nbt->LightPopulated = new Byte("LightPopulated", 0); + $chunk->nbt->V = new ByteTag("V", 1); + $chunk->nbt->InhabitedTime = new LongTag("InhabitedTime", 0); + $chunk->nbt->TerrainGenerated = new ByteTag("TerrainGenerated", 0); + $chunk->nbt->TerrainPopulated = new ByteTag("TerrainPopulated", 0); + $chunk->nbt->LightPopulated = new ByteTag("LightPopulated", 0); return $chunk; }catch(\Exception $e){ diff --git a/src/pocketmine/level/format/mcregion/McRegion.php b/src/pocketmine/level/format/mcregion/McRegion.php index d30f2682b..9d00c0b16 100644 --- a/src/pocketmine/level/format/mcregion/McRegion.php +++ b/src/pocketmine/level/format/mcregion/McRegion.php @@ -26,11 +26,11 @@ use pocketmine\level\format\generic\BaseLevelProvider; use pocketmine\level\generator\Generator; use pocketmine\level\Level; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\Long; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\LongTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\tile\Spawnable; use pocketmine\utils\BinaryStream; @@ -81,27 +81,27 @@ class McRegion extends BaseLevelProvider{ mkdir($path . "/region", 0777); } //TODO, add extra details - $levelData = new Compound("Data", [ - "hardcore" => new Byte("hardcore", 0), - "initialized" => new Byte("initialized", 1), - "GameType" => new Int("GameType", 0), - "generatorVersion" => new Int("generatorVersion", 1), //2 in MCPE - "SpawnX" => new Int("SpawnX", 128), - "SpawnY" => new Int("SpawnY", 70), - "SpawnZ" => new Int("SpawnZ", 128), - "version" => new Int("version", 19133), - "DayTime" => new Int("DayTime", 0), - "LastPlayed" => new Long("LastPlayed", microtime(true) * 1000), - "RandomSeed" => new Long("RandomSeed", $seed), - "SizeOnDisk" => new Long("SizeOnDisk", 0), - "Time" => new Long("Time", 0), - "generatorName" => new String("generatorName", Generator::getGeneratorName($generator)), - "generatorOptions" => new String("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), - "LevelName" => new String("LevelName", $name), - "GameRules" => new Compound("GameRules", []) + $levelData = new CompoundTag("Data", [ + "hardcore" => new ByteTag("hardcore", 0), + "initialized" => new ByteTag("initialized", 1), + "GameType" => new IntTag("GameType", 0), + "generatorVersion" => new IntTag("generatorVersion", 1), //2 in MCPE + "SpawnX" => new IntTag("SpawnX", 128), + "SpawnY" => new IntTag("SpawnY", 70), + "SpawnZ" => new IntTag("SpawnZ", 128), + "version" => new IntTag("version", 19133), + "DayTime" => new IntTag("DayTime", 0), + "LastPlayed" => new LongTag("LastPlayed", microtime(true) * 1000), + "RandomSeed" => new LongTag("RandomSeed", $seed), + "SizeOnDisk" => new LongTag("SizeOnDisk", 0), + "Time" => new LongTag("Time", 0), + "generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)), + "generatorOptions" => new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""), + "LevelName" => new StringTag("LevelName", $name), + "GameRules" => new CompoundTag("GameRules", []) ]); $nbt = new NBT(NBT::BIG_ENDIAN); - $nbt->setData(new Compound("", [ + $nbt->setData(new CompoundTag("", [ "Data" => $levelData ])); $buffer = $nbt->writeCompressed(); diff --git a/src/pocketmine/nbt/NBT.php b/src/pocketmine/nbt/NBT.php index ef7197349..89004bb3e 100644 --- a/src/pocketmine/nbt/NBT.php +++ b/src/pocketmine/nbt/NBT.php @@ -25,19 +25,19 @@ namespace pocketmine\nbt; use pocketmine\item\Item; -use pocketmine\nbt\tag\Byte; -use pocketmine\nbt\tag\ByteArray; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Double; -use pocketmine\nbt\tag\End; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Float; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\IntArray; -use pocketmine\nbt\tag\Long; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\ByteArrayTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\EndTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\IntArrayTag; +use pocketmine\nbt\tag\LongTag; use pocketmine\nbt\tag\NamedTAG; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\nbt\tag\Tag; use pocketmine\utils\Utils; @@ -65,7 +65,7 @@ class NBT{ const TAG_Double = 6; const TAG_ByteArray = 7; const TAG_String = 8; - const TAG_Enum = 9; + const TAG_List = 9; const TAG_Compound = 10; const TAG_IntArray = 11; @@ -78,17 +78,17 @@ class NBT{ /** * @param Item $item * @param int $slot - * @return Compound + * @return CompoundTag */ public static function putItemHelper(Item $item, $slot = null){ - $tag = new Compound(null, [ - "id" => new Short("id", $item->getId()), - "Count" => new Byte("Count", $item->getCount()), - "Damage" => new Short("Damage", $item->getDamage()) + $tag = new CompoundTag(null, [ + "id" => new ShortTag("id", $item->getId()), + "Count" => new ByteTag("Count", $item->getCount()), + "Damage" => new ShortTag("Damage", $item->getDamage()) ]); if($slot !== null){ - $tag->Slot = new Byte("Slot", (int) $slot); + $tag->Slot = new ByteTag("Slot", (int) $slot); } if($item->hasCompoundTag()){ @@ -100,24 +100,24 @@ class NBT{ } /** - * @param Compound $tag + * @param CompoundTag $tag * @return Item */ - public static function getItemHelper(Compound $tag){ + public static function getItemHelper(CompoundTag $tag){ if(!isset($tag->id) or !isset($tag->Count)){ return Item::get(0); } $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); } 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()){ return false; } @@ -131,11 +131,11 @@ class NBT{ return false; } - if($v instanceof Compound){ + if($v instanceof CompoundTag){ if(!self::matchTree($v, $tag2->{$k})){ return false; } - }elseif($v instanceof Enum){ + }elseif($v instanceof ListTag){ if(!self::matchList($v, $tag2->{$k})){ return false; } @@ -149,7 +149,7 @@ class NBT{ 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()){ return false; } @@ -163,11 +163,11 @@ class NBT{ return false; } - if($v instanceof Compound){ + if($v instanceof CompoundTag){ if(!self::matchTree($v, $tag2->{$k})){ return false; } - }elseif($v instanceof Enum){ + }elseif($v instanceof ListTag){ if(!self::matchList($v, $tag2->{$k})){ return false; } @@ -188,7 +188,7 @@ class NBT{ if($c === "{"){ ++$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"){ throw new \Exception("Syntax error: unexpected '$c' at offset $offset"); } @@ -218,37 +218,37 @@ class NBT{ switch($type){ case NBT::TAG_Byte: - $data[$key] = new Byte($key, $value); + $data[$key] = new ByteTag($key, $value); break; case NBT::TAG_Short: - $data[$key] = new Short($key, $value); + $data[$key] = new ShortTag($key, $value); break; case NBT::TAG_Int: - $data[$key] = new Int($key, $value); + $data[$key] = new IntTag($key, $value); break; case NBT::TAG_Long: - $data[$key] = new Long($key, $value); + $data[$key] = new LongTag($key, $value); break; case NBT::TAG_Float: - $data[$key] = new Float($key, $value); + $data[$key] = new FloatTag($key, $value); break; case NBT::TAG_Double: - $data[$key] = new Double($key, $value); + $data[$key] = new DoubleTag($key, $value); break; case NBT::TAG_ByteArray: - $data[$key] = new ByteArray($key, $value); + $data[$key] = new ByteArrayTag($key, $value); break; case NBT::TAG_String: - $data[$key] = new Byte($key, $value); + $data[$key] = new ByteTag($key, $value); break; - case NBT::TAG_Enum: - $data[$key] = new Enum($key, $value); + case NBT::TAG_List: + $data[$key] = new ListTag($key, $value); break; case NBT::TAG_Compound: - $data[$key] = new Compound($key, $value); + $data[$key] = new CompoundTag($key, $value); break; case NBT::TAG_IntArray: - $data[$key] = new IntArray($key, $value); + $data[$key] = new IntArrayTag($key, $value); break; } @@ -276,37 +276,37 @@ class NBT{ switch($type){ case NBT::TAG_Byte: - $data[$key] = new Byte($key, $value); + $data[$key] = new ByteTag($key, $value); break; case NBT::TAG_Short: - $data[$key] = new Short($key, $value); + $data[$key] = new ShortTag($key, $value); break; case NBT::TAG_Int: - $data[$key] = new Int($key, $value); + $data[$key] = new IntTag($key, $value); break; case NBT::TAG_Long: - $data[$key] = new Long($key, $value); + $data[$key] = new LongTag($key, $value); break; case NBT::TAG_Float: - $data[$key] = new Float($key, $value); + $data[$key] = new FloatTag($key, $value); break; case NBT::TAG_Double: - $data[$key] = new Double($key, $value); + $data[$key] = new DoubleTag($key, $value); break; case NBT::TAG_ByteArray: - $data[$key] = new ByteArray($key, $value); + $data[$key] = new ByteArrayTag($key, $value); break; case NBT::TAG_String: - $data[$key] = new String($key, $value); + $data[$key] = new StringTag($key, $value); break; - case NBT::TAG_Enum: - $data[$key] = new Enum($key, $value); + case NBT::TAG_List: + $data[$key] = new ListTag($key, $value); break; case NBT::TAG_Compound: - $data[$key] = new Compound($key, $value); + $data[$key] = new CompoundTag($key, $value); break; case NBT::TAG_IntArray: - $data[$key] = new IntArray($key, $value); + $data[$key] = new IntArrayTag($key, $value); break; } } @@ -351,7 +351,7 @@ class NBT{ } ++$offset; $value = self::parseList($data, $offset); - $type = self::TAG_Enum; + $type = self::TAG_List; break; }else{ $value .= $c; @@ -480,7 +480,7 @@ class NBT{ $this->offset = 0; $this->buffer = ""; - if($this->data instanceof Compound){ + if($this->data instanceof CompoundTag){ $this->writeTag($this->data); return $this->buffer; @@ -505,53 +505,53 @@ class NBT{ public function readTag(){ switch($this->getByte()){ case NBT::TAG_Byte: - $tag = new Byte($this->getString()); + $tag = new ByteTag($this->getString()); $tag->read($this); break; case NBT::TAG_Short: - $tag = new Short($this->getString()); + $tag = new ShortTag($this->getString()); $tag->read($this); break; case NBT::TAG_Int: - $tag = new Int($this->getString()); + $tag = new IntTag($this->getString()); $tag->read($this); break; case NBT::TAG_Long: - $tag = new Long($this->getString()); + $tag = new LongTag($this->getString()); $tag->read($this); break; case NBT::TAG_Float: - $tag = new Float($this->getString()); + $tag = new FloatTag($this->getString()); $tag->read($this); break; case NBT::TAG_Double: - $tag = new Double($this->getString()); + $tag = new DoubleTag($this->getString()); $tag->read($this); break; case NBT::TAG_ByteArray: - $tag = new ByteArray($this->getString()); + $tag = new ByteArrayTag($this->getString()); $tag->read($this); break; case NBT::TAG_String: - $tag = new String($this->getString()); + $tag = new StringTag($this->getString()); $tag->read($this); break; - case NBT::TAG_Enum: - $tag = new Enum($this->getString()); + case NBT::TAG_List: + $tag = new ListTag($this->getString()); $tag->read($this); break; case NBT::TAG_Compound: - $tag = new Compound($this->getString()); + $tag = new CompoundTag($this->getString()); $tag->read($this); break; case NBT::TAG_IntArray: - $tag = new IntArray($this->getString()); + $tag = new IntArrayTag($this->getString()); $tag->read($this); break; case NBT::TAG_End: //No named tag default: - $tag = new End; + $tag = new EndTag; break; } return $tag; @@ -628,9 +628,9 @@ class NBT{ } private static function toArray(array &$data, Tag $tag){ - /** @var Compound[]|Enum[]|IntArray[] $tag */ + /** @var CompoundTag[]|ListTag[]|IntArrayTag[] $tag */ 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] = []; self::toArray($data[$key], $value); }else{ @@ -641,13 +641,13 @@ class NBT{ public static function fromArrayGuesser($key, $value){ if(is_int($value)){ - return new Int($key, $value); + return new IntTag($key, $value); }elseif(is_float($value)){ - return new Float($key, $value); + return new FloatTag($key, $value); }elseif(is_string($value)){ - return new String($key, $value); + return new StringTag($key, $value); }elseif(is_bool($value)){ - return new Byte($key, $value ? 1 : 0); + return new ByteTag($key, $value ? 1 : 0); } return null; @@ -666,7 +666,7 @@ class NBT{ $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); }else{ $v = call_user_func($guesser, $key, $value); @@ -678,19 +678,19 @@ class NBT{ } 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); } /** - * @return Compound|array + * @return CompoundTag|array */ public function getData(){ return $this->data; } /** - * @param Compound|array $data + * @param CompoundTag|array $data */ public function setData($data){ $this->data = $data; diff --git a/src/pocketmine/nbt/tag/ByteArray.php b/src/pocketmine/nbt/tag/ByteArrayTag.php similarity index 96% rename from src/pocketmine/nbt/tag/ByteArray.php rename to src/pocketmine/nbt/tag/ByteArrayTag.php index 5f80e1452..9bfdf7559 100644 --- a/src/pocketmine/nbt/tag/ByteArray.php +++ b/src/pocketmine/nbt/tag/ByteArrayTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class ByteArray extends NamedTag{ +class ByteArrayTag extends NamedTag{ public function getType(){ return NBT::TAG_ByteArray; diff --git a/src/pocketmine/nbt/tag/Byte.php b/src/pocketmine/nbt/tag/ByteTag.php similarity index 96% rename from src/pocketmine/nbt/tag/Byte.php rename to src/pocketmine/nbt/tag/ByteTag.php index 07b72e641..46caa2798 100644 --- a/src/pocketmine/nbt/tag/Byte.php +++ b/src/pocketmine/nbt/tag/ByteTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class Byte extends NamedTag{ +class ByteTag extends NamedTag{ public function getType(){ return NBT::TAG_Byte; diff --git a/src/pocketmine/nbt/tag/Compound.php b/src/pocketmine/nbt/tag/CompoundTag.php similarity index 92% rename from src/pocketmine/nbt/tag/Compound.php rename to src/pocketmine/nbt/tag/CompoundTag.php index 654f33aa1..7c8ba10a0 100644 --- a/src/pocketmine/nbt/tag/Compound.php +++ b/src/pocketmine/nbt/tag/CompoundTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class Compound extends NamedTag implements \ArrayAccess{ +class CompoundTag extends NamedTag implements \ArrayAccess{ /** * @param string $name @@ -88,16 +88,16 @@ class Compound extends NamedTag implements \ArrayAccess{ if($tag instanceof NamedTag and $tag->getName() !== ""){ $this->{$tag->getName()} = $tag; } - }while(!($tag instanceof End) and !$nbt->feof()); + }while(!($tag instanceof EndTag) and !$nbt->feof()); } public function write(NBT $nbt){ 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(new End); + $nbt->writeTag(new EndTag); } public function __toString(){ diff --git a/src/pocketmine/nbt/tag/Double.php b/src/pocketmine/nbt/tag/DoubleTag.php similarity index 96% rename from src/pocketmine/nbt/tag/Double.php rename to src/pocketmine/nbt/tag/DoubleTag.php index 45be031c8..f25379248 100644 --- a/src/pocketmine/nbt/tag/Double.php +++ b/src/pocketmine/nbt/tag/DoubleTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class Double extends NamedTag{ +class DoubleTag extends NamedTag{ public function getType(){ return NBT::TAG_Double; diff --git a/src/pocketmine/nbt/tag/End.php b/src/pocketmine/nbt/tag/EndTag.php similarity index 97% rename from src/pocketmine/nbt/tag/End.php rename to src/pocketmine/nbt/tag/EndTag.php index 660998b93..0a9af721b 100644 --- a/src/pocketmine/nbt/tag/End.php +++ b/src/pocketmine/nbt/tag/EndTag.php @@ -23,7 +23,7 @@ namespace pocketmine\nbt\tag; use pocketmine\nbt\NBT; -class End extends Tag{ +class EndTag extends Tag{ public function getType(){ return NBT::TAG_End; diff --git a/src/pocketmine/nbt/tag/Float.php b/src/pocketmine/nbt/tag/FloatTag.php similarity index 96% rename from src/pocketmine/nbt/tag/Float.php rename to src/pocketmine/nbt/tag/FloatTag.php index fffebf70e..3e80ff6c5 100644 --- a/src/pocketmine/nbt/tag/Float.php +++ b/src/pocketmine/nbt/tag/FloatTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class Float extends NamedTag{ +class FloatTag extends NamedTag{ public function getType(){ return NBT::TAG_Float; diff --git a/src/pocketmine/nbt/tag/IntArray.php b/src/pocketmine/nbt/tag/IntArrayTag.php similarity index 97% rename from src/pocketmine/nbt/tag/IntArray.php rename to src/pocketmine/nbt/tag/IntArrayTag.php index 106fefd97..5df45c201 100644 --- a/src/pocketmine/nbt/tag/IntArray.php +++ b/src/pocketmine/nbt/tag/IntArrayTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class IntArray extends NamedTag{ +class IntArrayTag extends NamedTag{ public function getType(){ return NBT::TAG_IntArray; diff --git a/src/pocketmine/nbt/tag/Int.php b/src/pocketmine/nbt/tag/IntTag.php similarity index 96% rename from src/pocketmine/nbt/tag/Int.php rename to src/pocketmine/nbt/tag/IntTag.php index a479faca2..db5643bec 100644 --- a/src/pocketmine/nbt/tag/Int.php +++ b/src/pocketmine/nbt/tag/IntTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class Int extends NamedTag{ +class IntTag extends NamedTag{ public function getType(){ return NBT::TAG_Int; diff --git a/src/pocketmine/nbt/tag/Enum.php b/src/pocketmine/nbt/tag/ListTag.php similarity index 89% rename from src/pocketmine/nbt/tag/Enum.php rename to src/pocketmine/nbt/tag/ListTag.php index 30d4dd1be..d60b44209 100644 --- a/src/pocketmine/nbt/tag/Enum.php +++ b/src/pocketmine/nbt/tag/ListTag.php @@ -22,11 +22,11 @@ namespace pocketmine\nbt\tag; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Enum as TagEnum; +use pocketmine\nbt\tag\ListTag as TagEnum; #include -class Enum extends NamedTag implements \ArrayAccess, \Countable{ +class ListTag extends NamedTag implements \ArrayAccess, \Countable{ private $tagType; @@ -103,7 +103,7 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{ } public function getType(){ - return NBT::TAG_Enum; + return NBT::TAG_List; } public function setTagType($type){ @@ -121,57 +121,57 @@ class Enum extends NamedTag implements \ArrayAccess, \Countable{ for($i = 0; $i < $size and !$nbt->feof(); ++$i){ switch($this->tagType){ case NBT::TAG_Byte: - $tag = new Byte(""); + $tag = new ByteTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_Short: - $tag = new Short(""); + $tag = new ShortTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_Int: - $tag = new Int(""); + $tag = new IntTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_Long: - $tag = new Long(""); + $tag = new LongTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_Float: - $tag = new Float(""); + $tag = new FloatTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_Double: - $tag = new Double(""); + $tag = new DoubleTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_ByteArray: - $tag = new ByteArray(""); + $tag = new ByteArrayTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_String: - $tag = new String(""); + $tag = new StringTag(""); $tag->read($nbt); $this->{$i} = $tag; break; - case NBT::TAG_Enum: + case NBT::TAG_List: $tag = new TagEnum(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_Compound: - $tag = new Compound(""); + $tag = new CompoundTag(""); $tag->read($nbt); $this->{$i} = $tag; break; case NBT::TAG_IntArray: - $tag = new IntArray(""); + $tag = new IntArrayTag(""); $tag->read($nbt); $this->{$i} = $tag; break; diff --git a/src/pocketmine/nbt/tag/Long.php b/src/pocketmine/nbt/tag/LongTag.php similarity index 96% rename from src/pocketmine/nbt/tag/Long.php rename to src/pocketmine/nbt/tag/LongTag.php index 43d899282..ca822905b 100644 --- a/src/pocketmine/nbt/tag/Long.php +++ b/src/pocketmine/nbt/tag/LongTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class Long extends NamedTag{ +class LongTag extends NamedTag{ public function getType(){ return NBT::TAG_Long; diff --git a/src/pocketmine/nbt/tag/NamedTag.php b/src/pocketmine/nbt/tag/NamedTag.php index 723e174bc..64302786b 100644 --- a/src/pocketmine/nbt/tag/NamedTag.php +++ b/src/pocketmine/nbt/tag/NamedTag.php @@ -28,7 +28,7 @@ abstract class NamedTag extends Tag{ /** * @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){ $this->__name = ($name === null or $name === false) ? "" : $name; diff --git a/src/pocketmine/nbt/tag/Short.php b/src/pocketmine/nbt/tag/ShortTag.php similarity index 96% rename from src/pocketmine/nbt/tag/Short.php rename to src/pocketmine/nbt/tag/ShortTag.php index f2f1698ad..b35cdbbad 100644 --- a/src/pocketmine/nbt/tag/Short.php +++ b/src/pocketmine/nbt/tag/ShortTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class Short extends NamedTag{ +class ShortTag extends NamedTag{ public function getType(){ return NBT::TAG_Short; diff --git a/src/pocketmine/nbt/tag/String.php b/src/pocketmine/nbt/tag/StringTag.php similarity index 96% rename from src/pocketmine/nbt/tag/String.php rename to src/pocketmine/nbt/tag/StringTag.php index 40aae2cd6..25836ecbb 100644 --- a/src/pocketmine/nbt/tag/String.php +++ b/src/pocketmine/nbt/tag/StringTag.php @@ -25,7 +25,7 @@ use pocketmine\nbt\NBT; #include -class String extends NamedTag{ +class StringTag extends NamedTag{ public function getType(){ return NBT::TAG_String; diff --git a/src/pocketmine/tile/Chest.php b/src/pocketmine/tile/Chest.php index 69f4892aa..cdb09fe83 100644 --- a/src/pocketmine/tile/Chest.php +++ b/src/pocketmine/tile/Chest.php @@ -29,11 +29,11 @@ use pocketmine\level\format\FullChunk; use pocketmine\math\Vector3; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Int; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\IntTag; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\StringTag; class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ @@ -42,12 +42,12 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ /** @var DoubleChestInventory */ protected $doubleInventory = null; - public function __construct(FullChunk $chunk, Compound $nbt){ + public function __construct(FullChunk $chunk, CompoundTag $nbt){ parent::__construct($chunk, $nbt); $this->inventory = new ChestInventory($this); - if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof Enum)){ - $this->namedtag->Items = new Enum("Items", []); + if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){ + $this->namedtag->Items = new ListTag("Items", []); $this->namedtag->Items->setTagType(NBT::TAG_Compound); } @@ -70,7 +70,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ } public function saveNBT(){ - $this->namedtag->Items = new Enum("Items", []); + $this->namedtag->Items = new ListTag("Items", []); $this->namedtag->Items->setTagType(NBT::TAG_Compound); for($index = 0; $index < $this->getSize(); ++$index){ $this->setItem($index, $this->inventory->getItem($index)); @@ -196,7 +196,7 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ return; } - $this->namedtag->CustomName = new String("CustomName", $str); + $this->namedtag->CustomName = new StringTag("CustomName", $str); } public function isPaired(){ @@ -236,11 +236,11 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ } private function createPair(Chest $tile){ - $this->namedtag->pairx = new Int("pairx", $tile->x); - $this->namedtag->pairz = new Int("pairz", $tile->z); + $this->namedtag->pairx = new IntTag("pairx", $tile->x); + $this->namedtag->pairz = new IntTag("pairz", $tile->z); - $tile->namedtag->pairx = new Int("pairx", $this->x); - $tile->namedtag->pairz = new Int("pairz", $this->z); + $tile->namedtag->pairx = new IntTag("pairx", $this->x); + $tile->namedtag->pairz = new IntTag("pairz", $this->z); } public function unpair(){ @@ -265,20 +265,20 @@ class Chest extends Spawnable implements InventoryHolder, Container, Nameable{ public function getSpawnCompound(){ if($this->isPaired()){ - $c = new Compound("", [ - new String("id", Tile::CHEST), - new Int("x", (int) $this->x), - new Int("y", (int) $this->y), - new Int("z", (int) $this->z), - new Int("pairx", (int) $this->namedtag["pairx"]), - new Int("pairz", (int) $this->namedtag["pairz"]) + $c = new CompoundTag("", [ + new StringTag("id", Tile::CHEST), + new IntTag("x", (int) $this->x), + new IntTag("y", (int) $this->y), + new IntTag("z", (int) $this->z), + new IntTag("pairx", (int) $this->namedtag["pairx"]), + new IntTag("pairz", (int) $this->namedtag["pairz"]) ]); }else{ - $c = new Compound("", [ - new String("id", Tile::CHEST), - new Int("x", (int) $this->x), - new Int("y", (int) $this->y), - new Int("z", (int) $this->z) + $c = new CompoundTag("", [ + new StringTag("id", Tile::CHEST), + new IntTag("x", (int) $this->x), + new IntTag("y", (int) $this->y), + new IntTag("z", (int) $this->z) ]); } diff --git a/src/pocketmine/tile/EnchantTable.php b/src/pocketmine/tile/EnchantTable.php index 09e3cfc48..c906edf2e 100644 --- a/src/pocketmine/tile/EnchantTable.php +++ b/src/pocketmine/tile/EnchantTable.php @@ -21,9 +21,9 @@ namespace pocketmine\tile; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; class EnchantTable extends Spawnable implements Nameable{ @@ -42,15 +42,15 @@ class EnchantTable extends Spawnable implements Nameable{ return; } - $this->namedtag->CustomName = new String("CustomName", $str); + $this->namedtag->CustomName = new StringTag("CustomName", $str); } public function getSpawnCompound(){ - $c = new Compound("", [ - new String("id", Tile::ENCHANT_TABLE), - new Int("x", (int) $this->x), - new Int("y", (int) $this->y), - new Int("z", (int) $this->z) + $c = new CompoundTag("", [ + new StringTag("id", Tile::ENCHANT_TABLE), + new IntTag("x", (int) $this->x), + new IntTag("y", (int) $this->y), + new IntTag("z", (int) $this->z) ]); if($this->hasName()){ diff --git a/src/pocketmine/tile/Furnace.php b/src/pocketmine/tile/Furnace.php index e24a0bb86..9deaee8b2 100644 --- a/src/pocketmine/tile/Furnace.php +++ b/src/pocketmine/tile/Furnace.php @@ -31,10 +31,10 @@ use pocketmine\item\Item; use pocketmine\level\format\FullChunk; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\Network; use pocketmine\network\protocol\ContainerSetDataPacket; @@ -42,12 +42,12 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{ /** @var FurnaceInventory */ protected $inventory; - public function __construct(FullChunk $chunk, Compound $nbt){ + public function __construct(FullChunk $chunk, CompoundTag $nbt){ parent::__construct($chunk, $nbt); $this->inventory = new FurnaceInventory($this); - if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof Enum)){ - $this->namedtag->Items = new Enum("Items", []); + if(!isset($this->namedtag->Items) or !($this->namedtag->Items instanceof ListTag)){ + $this->namedtag->Items = new ListTag("Items", []); $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){ - $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)){ - $this->namedtag->CookTime = new Short("CookTime", 0); + $this->namedtag->CookTime = new ShortTag("CookTime", 0); } if(!isset($this->namedtag->MaxTime)){ - $this->namedtag->MaxTime = new Short("BurnTime", $this->namedtag["BurnTime"]); - $this->namedtag->BurnTicks = new Short("BurnTicks", 0); + $this->namedtag->MaxTime = new ShortTag("BurnTime", $this->namedtag["BurnTime"]); + $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0); } if($this->namedtag["BurnTime"] > 0){ $this->scheduleUpdate(); @@ -84,7 +84,7 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{ return; } - $this->namedtag->CustomName = new String("CustomName", $str); + $this->namedtag->CustomName = new StringTag("CustomName", $str); } public function close(){ @@ -97,7 +97,7 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{ } public function saveNBT(){ - $this->namedtag->Items = new Enum("Items", []); + $this->namedtag->Items = new ListTag("Items", []); $this->namedtag->Items->setTagType(NBT::TAG_Compound); for($index = 0; $index < $this->getSize(); ++$index){ $this->setItem($index, $this->inventory->getItem($index)); @@ -187,9 +187,9 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{ return; } - $this->namedtag->MaxTime = new Short("MaxTime", $ev->getBurnTime()); - $this->namedtag->BurnTime = new Short("BurnTime", $ev->getBurnTime()); - $this->namedtag->BurnTicks = new Short("BurnTicks", 0); + $this->namedtag->MaxTime = new ShortTag("MaxTime", $ev->getBurnTime()); + $this->namedtag->BurnTime = new ShortTag("BurnTime", $ev->getBurnTime()); + $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0); if($this->getBlock()->getId() === Item::FURNACE){ $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){ - $this->namedtag->BurnTime = new Short("BurnTime", $this->namedtag["BurnTime"] - 1); - $this->namedtag->BurnTicks = new Short("BurnTicks", ceil(($this->namedtag["BurnTime"] / $this->namedtag["MaxTime"] * 200))); + $this->namedtag->BurnTime = new ShortTag("BurnTime", $this->namedtag["BurnTime"] - 1); + $this->namedtag->BurnTicks = new ShortTag("BurnTicks", ceil(($this->namedtag["BurnTime"] / $this->namedtag["MaxTime"] * 200))); 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 $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->namedtag->CookTime = new Short("CookTime", $this->namedtag["CookTime"] - 200); + $this->namedtag->CookTime = new ShortTag("CookTime", $this->namedtag["CookTime"] - 200); } }elseif($this->namedtag["BurnTime"] <= 0){ - $this->namedtag->BurnTime = new Short("BurnTime", 0); - $this->namedtag->CookTime = new Short("CookTime", 0); - $this->namedtag->BurnTicks = new Short("BurnTicks", 0); + $this->namedtag->BurnTime = new ShortTag("BurnTime", 0); + $this->namedtag->CookTime = new ShortTag("CookTime", 0); + $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0); }else{ - $this->namedtag->CookTime = new Short("CookTime", 0); + $this->namedtag->CookTime = new ShortTag("CookTime", 0); } $ret = true; }else{ @@ -257,9 +257,9 @@ class Furnace extends Tile implements InventoryHolder, Container, Nameable{ if($this->getBlock()->getId() === Item::BURNING_FURNACE){ $this->getLevel()->setBlock($this, Block::get(Item::FURNACE, $this->getBlock()->getDamage()), true); } - $this->namedtag->BurnTime = new Short("BurnTime", 0); - $this->namedtag->CookTime = new Short("CookTime", 0); - $this->namedtag->BurnTicks = new Short("BurnTicks", 0); + $this->namedtag->BurnTime = new ShortTag("BurnTime", 0); + $this->namedtag->CookTime = new ShortTag("CookTime", 0); + $this->namedtag->BurnTicks = new ShortTag("BurnTicks", 0); } foreach($this->getInventory()->getViewers() as $player){ diff --git a/src/pocketmine/tile/Sign.php b/src/pocketmine/tile/Sign.php index 94cab70b1..b3f2c63c7 100644 --- a/src/pocketmine/tile/Sign.php +++ b/src/pocketmine/tile/Sign.php @@ -22,24 +22,24 @@ namespace pocketmine\tile; use pocketmine\level\format\FullChunk; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; class Sign extends Spawnable{ - public function __construct(FullChunk $chunk, Compound $nbt){ + public function __construct(FullChunk $chunk, CompoundTag $nbt){ if(!isset($nbt->Text1)){ - $nbt->Text1 = new String("Text1", ""); + $nbt->Text1 = new StringTag("Text1", ""); } if(!isset($nbt->Text2)){ - $nbt->Text2 = new String("Text2", ""); + $nbt->Text2 = new StringTag("Text2", ""); } if(!isset($nbt->Text3)){ - $nbt->Text3 = new String("Text3", ""); + $nbt->Text3 = new StringTag("Text3", ""); } if(!isset($nbt->Text4)){ - $nbt->Text4 = new String("Text4", ""); + $nbt->Text4 = new StringTag("Text4", ""); } parent::__construct($chunk, $nbt); @@ -51,10 +51,10 @@ class Sign extends Spawnable{ } public function setText($line1 = "", $line2 = "", $line3 = "", $line4 = ""){ - $this->namedtag->Text1 = new String("Text1", $line1); - $this->namedtag->Text2 = new String("Text2", $line2); - $this->namedtag->Text3 = new String("Text3", $line3); - $this->namedtag->Text4 = new String("Text4", $line4); + $this->namedtag->Text1 = new StringTag("Text1", $line1); + $this->namedtag->Text2 = new StringTag("Text2", $line2); + $this->namedtag->Text3 = new StringTag("Text3", $line3); + $this->namedtag->Text4 = new StringTag("Text4", $line4); $this->spawnToAll(); if($this->chunk){ @@ -75,15 +75,15 @@ class Sign extends Spawnable{ } public function getSpawnCompound(){ - return new Compound("", [ - new String("id", Tile::SIGN), + return new CompoundTag("", [ + new StringTag("id", Tile::SIGN), $this->namedtag->Text1, $this->namedtag->Text2, $this->namedtag->Text3, $this->namedtag->Text4, - new Int("x", (int) $this->x), - new Int("y", (int) $this->y), - new Int("z", (int) $this->z) + new IntTag("x", (int) $this->x), + new IntTag("y", (int) $this->y), + new IntTag("z", (int) $this->z) ]); } diff --git a/src/pocketmine/tile/Spawnable.php b/src/pocketmine/tile/Spawnable.php index 37828e0c3..706f91cc1 100644 --- a/src/pocketmine/tile/Spawnable.php +++ b/src/pocketmine/tile/Spawnable.php @@ -23,7 +23,7 @@ namespace pocketmine\tile; use pocketmine\level\format\FullChunk; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Compound; +use pocketmine\nbt\tag\CompoundTag; use pocketmine\network\Network; use pocketmine\network\protocol\TileEntityDataPacket; use pocketmine\Player; @@ -48,11 +48,11 @@ abstract class Spawnable extends Tile{ } /** - * @return Compound + * @return CompoundTag */ public abstract function getSpawnCompound(); - public function __construct(FullChunk $chunk, Compound $nbt){ + public function __construct(FullChunk $chunk, CompoundTag $nbt){ parent::__construct($chunk, $nbt); $this->spawnToAll(); } diff --git a/src/pocketmine/tile/Tile.php b/src/pocketmine/tile/Tile.php index d3ad814f1..450288160 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -30,9 +30,9 @@ use pocketmine\level\format\Chunk; use pocketmine\level\format\FullChunk; use pocketmine\level\Level; use pocketmine\level\Position; -use pocketmine\nbt\tag\Compound; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\utils\ChunkException; abstract class Tile extends Position{ @@ -71,12 +71,12 @@ abstract class Tile extends Position{ /** * @param string $type * @param FullChunk $chunk - * @param Compound $nbt + * @param CompoundTag $nbt * @param $args * * @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])){ $class = self::$knownTiles[$type]; return new $class($chunk, $nbt, ...$args); @@ -110,7 +110,7 @@ abstract class Tile extends Position{ 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){ throw new ChunkException("Invalid garbage Chunk given to Tile"); } @@ -138,10 +138,10 @@ abstract class Tile extends Position{ } public function saveNBT(){ - $this->namedtag->id = new String("id", $this->getSaveId()); - $this->namedtag->x = new Int("x", $this->x); - $this->namedtag->y = new Int("y", $this->y); - $this->namedtag->z = new Int("z", $this->z); + $this->namedtag->id = new StringTag("id", $this->getSaveId()); + $this->namedtag->x = new IntTag("x", $this->x); + $this->namedtag->y = new IntTag("y", $this->y); + $this->namedtag->z = new IntTag("z", $this->z); } /**