mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 01:46:04 +00:00
Renamed NBT tags to have Tag in the name
This commit is contained in:
@ -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)
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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()){
|
||||
|
@ -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){
|
||||
|
@ -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)
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user