Renamed NBT tags to have Tag in the name

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

View File

@ -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();
}

View File

@ -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);

View File

@ -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;