diff --git a/src/pocketmine/Collectable.php b/src/pocketmine/Collectable.php new file mode 100644 index 000000000..c05a1aed3 --- /dev/null +++ b/src/pocketmine/Collectable.php @@ -0,0 +1,35 @@ +isGarbage; + } + + public function setGarbage(){ + $this->isGarbage = true; + } +} diff --git a/src/pocketmine/CompatibleClassLoader.php b/src/pocketmine/CompatibleClassLoader.php index 42bbffec8..07a03e691 100644 --- a/src/pocketmine/CompatibleClassLoader.php +++ b/src/pocketmine/CompatibleClassLoader.php @@ -23,10 +23,4 @@ namespace pocketmine; class CompatibleClassLoader extends \BaseClassLoader{ - /** - * @deprecated - */ - public function add($namespace, $paths){ - $this->addPath(array_shift($paths)); - } } \ No newline at end of file diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index bbca6a3ca..22bd10de0 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -55,13 +55,6 @@ class MemoryManager{ private $chunkCache; private $cacheTrigger; - /** @var \WeakRef[] */ - private $leakWatch = []; - - private $leakInfo = []; - - private $leakSeed = 0; - public function __construct(Server $server){ $this->server = $server; @@ -214,87 +207,6 @@ class MemoryManager{ return $cycles; } - /** - * @param object $object - * - * @return string Object identifier for future checks - */ - public function addObjectWatcher($object){ - if(!is_object($object)){ - throw new \InvalidArgumentException("Not an object!"); - } - - - $identifier = spl_object_hash($object) . ":" . get_class($object); - - if(isset($this->leakInfo[$identifier])){ - return $this->leakInfo["id"]; - } - - $this->leakInfo[$identifier] = [ - "id" => $id = md5($identifier . ":" . $this->leakSeed++), - "class" => get_class($object), - "hash" => $identifier - ]; - $this->leakInfo[$id] = $this->leakInfo[$identifier]; - - $this->leakWatch[$id] = new \WeakRef($object); - - return $id; - } - - public function isObjectAlive($id){ - if(isset($this->leakWatch[$id])){ - return $this->leakWatch[$id]->valid(); - } - - return false; - } - - public function removeObjectWatch($id){ - if(!isset($this->leakWatch[$id])){ - return; - } - unset($this->leakInfo[$this->leakInfo[$id]["hash"]]); - unset($this->leakInfo[$id]); - unset($this->leakWatch[$id]); - } - - public function doObjectCleanup(){ - foreach($this->leakWatch as $id => $w){ - if(!$w->valid()){ - $this->removeObjectWatch($id); - } - } - } - - public function getObjectInformation($id, $includeObject = false){ - if(!isset($this->leakWatch[$id])){ - return null; - } - - $valid = false; - $references = 0; - $object = null; - - if($this->leakWatch[$id]->acquire()){ - $object = $this->leakWatch[$id]->get(); - $this->leakWatch[$id]->release(); - - $valid = true; - $references = getReferenceCount($object, false); - } - - return [ - "id" => $id, - "class" => $this->leakInfo[$id]["class"], - "hash" => $this->leakInfo[$id]["hash"], - "valid" => $valid, - "references" => $references, - "object" => $includeObject ? $object : null - ]; - } - public function dumpServerMemory($outputFolder, $maxNesting, $maxStringSize){ gc_disable(); 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 964673d59..c9a89e286 100644 --- a/src/pocketmine/Player.php +++ b/src/pocketmine/Player.php @@ -21,6 +21,7 @@ namespace pocketmine; +use pocketmine\block\Air; use pocketmine\block\Block; use pocketmine\command\CommandSender; use pocketmine\entity\Arrow; @@ -76,11 +77,9 @@ use pocketmine\inventory\PlayerInventory; use pocketmine\inventory\ShapedRecipe; use pocketmine\inventory\ShapelessRecipe; use pocketmine\inventory\SimpleTransactionGroup; - use pocketmine\item\Item; use pocketmine\level\ChunkLoader; use pocketmine\level\format\FullChunk; -use pocketmine\level\format\LevelProvider; use pocketmine\level\Level; use pocketmine\level\Location; use pocketmine\level\Position; @@ -90,16 +89,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\network\Network; +use pocketmine\nbt\tag\ByteTag; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\DoubleTag; +use pocketmine\nbt\tag\FloatTag; +use pocketmine\nbt\tag\IntTag; +use pocketmine\nbt\tag\ListTag; +use pocketmine\nbt\tag\LongTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\protocol\AdventureSettingsPacket; use pocketmine\network\protocol\AnimatePacket; use pocketmine\network\protocol\BatchPacket; @@ -110,20 +108,19 @@ use pocketmine\network\protocol\DisconnectPacket; use pocketmine\network\protocol\EntityEventPacket; use pocketmine\network\protocol\FullChunkDataPacket; use pocketmine\network\protocol\Info as ProtocolInfo; +use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\PlayerActionPacket; use pocketmine\network\protocol\PlayStatusPacket; use pocketmine\network\protocol\RespawnPacket; -use pocketmine\network\protocol\SetPlayerGameTypePacket; -use pocketmine\network\protocol\TextPacket; - -use pocketmine\network\protocol\MovePlayerPacket; use pocketmine\network\protocol\SetDifficultyPacket; use pocketmine\network\protocol\SetEntityMotionPacket; use pocketmine\network\protocol\SetHealthPacket; +use pocketmine\network\protocol\SetPlayerGameTypePacket; use pocketmine\network\protocol\SetSpawnPositionPacket; use pocketmine\network\protocol\SetTimePacket; use pocketmine\network\protocol\StartGamePacket; use pocketmine\network\protocol\TakeItemEntityPacket; +use pocketmine\network\protocol\TextPacket; use pocketmine\network\protocol\UpdateBlockPacket; use pocketmine\network\SourceInterface; use pocketmine\permission\PermissibleBase; @@ -133,10 +130,9 @@ use pocketmine\tile\Sign; use pocketmine\tile\Spawnable; use pocketmine\tile\Tile; use pocketmine\utils\TextFormat; - - use raklib\Binary; + /** * Main class that handles networking, recovery, and packet sending to the server part */ @@ -183,12 +179,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade protected $isCrafting = false; - /** - * @deprecated - * @var array - */ - public $loginData = []; - public $creationTime = 0; protected $randomClientId; @@ -227,7 +217,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade protected $viewDistance; protected $chunksPerTick; - protected $spawnThreshold; + protected $spawnThreshold; /** @var null|Position */ private $spawnPosition = null; @@ -296,15 +286,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 +493,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; @@ -511,7 +501,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->clientID = $clientID; $this->loaderId = Level::generateChunkLoaderId($this); $this->chunksPerTick = (int) $this->server->getProperty("chunk-sending.per-tick", 4); - $this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56); + $this->spawnThreshold = (int) $this->server->getProperty("chunk-sending.spawn-threshold", 56); $this->spawnPosition = null; $this->gamemode = $this->server->getGamemode(); $this->setLevel($this->server->getDefaultLevel()); @@ -565,9 +555,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return $this->displayName; } - /** - * @param string $name - */ + /** + * @param string $name + */ public function setDisplayName($name){ $this->displayName = $name; if($this->spawned){ @@ -889,11 +879,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return false; } - if(!isset($this->batchedPackets[$packet->getChannel()])){ - $this->batchedPackets[$packet->getChannel()] = []; - } - - $this->batchedPackets[$packet->getChannel()][] = clone $packet; + $this->batchedPackets[] = clone $packet; $timings->stopTiming(); return true; } @@ -1100,7 +1086,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); $pk = new SetPlayerGameTypePacket(); $pk->gamemode = $this->gamemode & 0x01; @@ -1216,20 +1202,6 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return []; } - /** - * @deprecated - */ - public function addEntityMotion($entityId, $x, $y, $z){ - - } - - /** - * @deprecated - */ - public function addEntityMovement($entityId, $x, $y, $z, $yaw, $pitch, $headYaw = null){ - - } - public function setDataProperty($id, $type, $value){ if(parent::setDataProperty($id, $type, $value)){ $this->sendData($this, [$id => $this->dataProperties[$id]]); @@ -1554,9 +1526,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } if(count($this->batchedPackets) > 0){ - foreach($this->batchedPackets as $channel => $list){ - $this->server->batchPackets([$this], $list, false, $channel); - } + $this->server->batchPackets([$this], $this->batchedPackets, false); $this->batchedPackets = []; } @@ -1628,14 +1598,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(); @@ -1651,7 +1621,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; @@ -1664,7 +1634,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); } @@ -1936,13 +1906,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade break; } }else{ - if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){ - $this->inventory->setHeldItemIndex($packet->selectedSlot); - $this->inventory->setHeldItemSlot($packet->slot); - }else{ - $this->inventory->sendContents($this); - break; - } + if($packet->selectedSlot >= 0 and $packet->selectedSlot < 9){ + $this->inventory->setHeldItemIndex($packet->selectedSlot); + $this->inventory->setHeldItemSlot($packet->slot); + }else{ + $this->inventory->sendContents($this); + break; + } } }elseif($item === null or $slot === -1 or !$item->deepEquals($packet->item)){ // packet error or not implemented $this->inventory->sendContents($this); @@ -1952,13 +1922,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->inventory->setItem($packet->selectedSlot, $item); $this->inventory->setHeldItemSlot($packet->selectedSlot); }else{ - if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){ - $this->inventory->setHeldItemIndex($packet->selectedSlot); - $this->inventory->setHeldItemSlot($slot); - }else{ - $this->inventory->sendContents($this); - break; - } + if($packet->selectedSlot >= 0 and $packet->selectedSlot < $this->inventory->getHotbarSize()){ + $this->inventory->setHeldItemIndex($packet->selectedSlot); + $this->inventory->setHeldItemSlot($slot); + }else{ + $this->inventory->sendContents($this); + break; + } } $this->inventory->sendHeldItem($this->hasSpawned); @@ -2031,20 +2001,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) ]), ]); @@ -2092,6 +2062,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->inventory->sendHeldItem($this); break; } + $block = $target->getSide($packet->face); + if($block->getId() === Block::FIRE){ + $this->level->setBlock($block, new Air()); + } $this->lastBreak = microtime(true); break; case PlayerActionPacket::ACTION_ABORT_BREAK: @@ -2099,30 +2073,30 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade break; case PlayerActionPacket::ACTION_RELEASE_ITEM: if($this->startAction > -1 and $this->getDataFlag(self::DATA_FLAGS, self::DATA_FLAG_ACTION)){ - if($this->inventory->getItemInHand()->getId() === Item::BOW) { + if($this->inventory->getItemInHand()->getId() === Item::BOW){ $bow = $this->inventory->getItemInHand(); - if ($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))) { + if($this->isSurvival() and !$this->inventory->contains(Item::get(Item::ARROW, 0, 1))){ $this->inventory->sendContents($this); break; } - $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); @@ -2130,35 +2104,35 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $f = min((($p ** 2) + $p * 2) / 3, 1) * 2; $ev = new EntityShootBowEvent($this, $bow, Entity::createEntity("Arrow", $this->chunk, $nbt, $this, $f == 2 ? true : false), $f); - if ($f < 0.1 or $diff < 5) { + if($f < 0.1 or $diff < 5){ $ev->setCancelled(); } $this->server->getPluginManager()->callEvent($ev); - if ($ev->isCancelled()) { + if($ev->isCancelled()){ $ev->getProjectile()->kill(); $this->inventory->sendContents($this); - } else { + }else{ $ev->getProjectile()->setMotion($ev->getProjectile()->getMotion()->multiply($ev->getForce())); if($this->isSurvival()){ $this->inventory->removeItem(Item::get(Item::ARROW, 0, 1)); $bow->setDamage($bow->getDamage() + 1); - if ($bow->getDamage() >= 385) { + if($bow->getDamage() >= 385){ $this->inventory->setItemInHand(Item::get(Item::AIR, 0, 0)); - } else { + }else{ $this->inventory->setItemInHand($bow); } } - if ($ev->getProjectile() instanceof Projectile) { + if($ev->getProjectile() instanceof Projectile){ $this->server->getPluginManager()->callEvent($projectileEv = new ProjectileLaunchEvent($ev->getProjectile())); - if ($projectileEv->isCancelled()) { + if($projectileEv->isCancelled()){ $ev->getProjectile()->kill(); - } else { + }else{ $ev->getProjectile()->spawnToAll(); $this->level->addSound(new LaunchSound($this), $this->getViewers()); } - } else { + }else{ $ev->getProjectile()->spawnToAll(); } } @@ -2176,7 +2150,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->dataPacket($pk); Server::broadcastPacket($this->getViewers(), $pk); - if ($this->isSurvival()) { + if($this->isSurvival()){ $slot = $this->inventory->getItemInHand(); --$slot->count; $this->inventory->setItemInHand($slot); @@ -2304,7 +2278,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->level->sendBlocks([$this], [$target], UpdateBlockPacket::FLAG_ALL_PRIORITY); - $this->inventory->sendHeldItem($this); + $this->inventory->sendHeldItem($this); if($tile instanceof Spawnable){ $tile->spawnTo($this); @@ -2511,7 +2485,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade if(is_array($amount)){ $amount = isset($amount[$slot->getDamage()]) ? $amount[$slot->getDamage()] : 0; } - $ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING); + $ev = new EntityRegainHealthEvent($this, $amount, EntityRegainHealthEvent::CAUSE_EATING); $this->heal($ev->getAmount(), $ev); --$slot->count; @@ -2675,7 +2649,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $result = $packet->output[0]; if(!$canCraft or !$recipe->getResult()->deepEquals($result)){ - $this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": expected " . $recipe->getResult() . ", got ". $result .", using: " . implode(", ", $ingredients)); + $this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": expected " . $recipe->getResult() . ", got " . $result . ", using: " . implode(", ", $ingredients)); $this->inventory->sendContents($this); break; } @@ -2685,7 +2659,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade foreach($ingredients as $ingredient){ $slot = -1; foreach($this->inventory->getContents() as $index => $i){ - if($ingredient->getId() !== 0 and $ingredient->deepEquals($i, $i->getDamage() !== null) and ($i->getCount() - $used[$index]) >= 1){ + if($ingredient->getId() !== 0 and $ingredient->deepEquals($i, $ingredient->getDamage() !== null) and ($i->getCount() - $used[$index]) >= 1){ $slot = $index; $used[$index]++; break; @@ -2699,7 +2673,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade } if(!$canCraft){ - $this->server->getLogger()->debug("Unmatched recipe ". $recipe->getId() ." from player ". $this->getName() .": client does not have enough items, using: " . implode(", ", $ingredients)); + $this->server->getLogger()->debug("Unmatched recipe " . $recipe->getId() . " from player " . $this->getName() . ": client does not have enough items, using: " . implode(", ", $ingredients)); $this->inventory->sendContents($this); break; } @@ -2913,11 +2887,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade $this->server->getPluginManager()->callEvent($ev = new PlayerKickEvent($this, $reason, $this->getLeaveMessage())); if(!$ev->isCancelled()){ if($isAdmin){ - if(!$this->isBanned()) { - $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : ""); - }else{ - $message = $reason; - } + if(!$this->isBanned()){ + $message = "Kicked by admin." . ($reason !== "" ? " Reason: " . $reason : ""); + }else{ + $message = $reason; + } }else{ if($reason === ""){ $message = "disconnectionScreen.noReason"; @@ -2940,11 +2914,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade */ public function sendMessage($message){ if($message instanceof TextContainer){ - if ($message instanceof TranslationContainer) { - $this->sendTranslation($message->getText(), $message->getParameters()); - return; - } - $message = $message->getText(); + if($message instanceof TranslationContainer){ + $this->sendTranslation($message->getText(), $message->getParameters()); + return; + } + $message = $message->getText(); } @@ -2996,7 +2970,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade * * @param string $message Message to be broadcasted * @param string $reason Reason showed in console - * @param bool $notify + * @param bool $notify */ public final function close($message = "", $reason = "generic reason", $notify = true){ @@ -3092,7 +3066,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; @@ -3101,13 +3075,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); } } @@ -3280,13 +3254,13 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade return; } - if($this->isCreative() - and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC - and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE - and $source->getCause() !== EntityDamageEvent::CAUSE_VOID - ){ - $source->setCancelled(); - }elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){ + if($this->isCreative() + and $source->getCause() !== EntityDamageEvent::CAUSE_MAGIC + and $source->getCause() !== EntityDamageEvent::CAUSE_SUICIDE + and $source->getCause() !== EntityDamageEvent::CAUSE_VOID + ){ + $source->setCancelled(); + }elseif($this->allowFlight and $source->getCause() === EntityDamageEvent::CAUSE_FALL){ $source->setCancelled(); } @@ -3385,11 +3359,11 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade /** * @param Vector3|Position|Location $pos - * @param float $yaw - * @param float $pitch + * @param float $yaw + * @param float $pitch * * @return bool - */ + */ public function teleport(Vector3 $pos, $yaw = null, $pitch = null){ if(!$this->isOnline()){ return false; diff --git a/src/pocketmine/PocketMine.php b/src/pocketmine/PocketMine.php index b1a35bab5..67040f078 100644 --- a/src/pocketmine/PocketMine.php +++ b/src/pocketmine/PocketMine.php @@ -73,10 +73,10 @@ namespace pocketmine { use pocketmine\wizard\Installer; const VERSION = "1.6dev"; - const API_VERSION = "1.13.1"; + const API_VERSION = "2.0.0"; const CODENAME = "[REDACTED]"; - const MINECRAFT_VERSION = "v0.13.2 alpha"; - const MINECRAFT_VERSION_NETWORK = "0.13.2"; + const MINECRAFT_VERSION = "v0.14.0.0 alpha"; + const MINECRAFT_VERSION_NETWORK = "0.14.0.0"; /* * Startup code. Do not look at it, it may harm you. @@ -86,9 +86,15 @@ namespace pocketmine { */ if(\Phar::running(true) !== ""){ - @define("pocketmine\\PATH", \Phar::running(true) . "/"); + @define('pocketmine\PATH', \Phar::running(true) . "/"); }else{ - @define("pocketmine\\PATH", \getcwd() . DIRECTORY_SEPARATOR); + @define('pocketmine\PATH', \getcwd() . DIRECTORY_SEPARATOR); + } + + if(version_compare("7.0", PHP_VERSION) > 0){ + echo "[CRITICAL] You must use PHP >= 7.0" . PHP_EOL; + echo "[CRITICAL] Please use the installer provided on the homepage." . PHP_EOL; + exit(1); } if(!extension_loaded("pthreads")){ @@ -98,7 +104,6 @@ namespace pocketmine { } if(!class_exists("ClassLoader", false)){ - require_once(\pocketmine\PATH . "src/spl/ThreadedFactory.php"); require_once(\pocketmine\PATH . "src/spl/ClassLoader.php"); require_once(\pocketmine\PATH . "src/spl/BaseClassLoader.php"); require_once(\pocketmine\PATH . "src/pocketmine/CompatibleClassLoader.php"); @@ -120,16 +125,16 @@ namespace pocketmine { ini_set("default_charset", "utf-8"); ini_set("memory_limit", -1); - define("pocketmine\\START_TIME", microtime(true)); + define('pocketmine\START_TIME', microtime(true)); $opts = getopt("", ["data:", "plugins:", "no-wizard", "enable-profiler"]); - define("pocketmine\\DATA", isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); - define("pocketmine\\PLUGIN_PATH", isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); + define('pocketmine\DATA', isset($opts["data"]) ? $opts["data"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR); + define('pocketmine\PLUGIN_PATH', isset($opts["plugins"]) ? $opts["plugins"] . DIRECTORY_SEPARATOR : \getcwd() . DIRECTORY_SEPARATOR . "plugins" . DIRECTORY_SEPARATOR); Terminal::init(); - define("pocketmine\\ANSI", Terminal::hasFormattingCodes()); + define('pocketmine\ANSI', Terminal::hasFormattingCodes()); if(!file_exists(\pocketmine\DATA)){ mkdir(\pocketmine\DATA, 0777, true); @@ -137,6 +142,7 @@ namespace pocketmine { //Logger has a dependency on timezone, so we'll set it to UTC until we can get the actual timezone. date_default_timezone_set("UTC"); + $logger = new MainLogger(\pocketmine\DATA . "server.log", \pocketmine\ANSI); if(!ini_get("date.timezone")){ @@ -314,7 +320,11 @@ namespace pocketmine { case "mac": case "linux": default: - exec("kill -9 " . ((int) $pid) . " > /dev/null 2>&1"); + if(function_exists("posix_kill")){ + posix_kill($pid, SIGKILL); + }else{ + exec("kill -9 " . ((int)$pid) . " > /dev/null 2>&1"); + } } } @@ -370,15 +380,8 @@ namespace pocketmine { return rtrim(str_replace(["\\", ".php", "phar://", rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PATH), "/"), rtrim(str_replace(["\\", "phar://"], ["/", ""], \pocketmine\PLUGIN_PATH), "/")], ["/", "", "", "", ""], $path), "/"); } - set_error_handler([\ExceptionHandler::class, "handler"], -1); - $errors = 0; - if(version_compare("5.6.0", PHP_VERSION) > 0){ - $logger->critical("You must use PHP >= 5.6"); - ++$errors; - } - if(php_sapi_name() !== "cli"){ $logger->critical("You must run PocketMine-MP using the CLI."); ++$errors; @@ -393,8 +396,8 @@ namespace pocketmine { if(substr_count($pthreads_version, ".") < 2){ $pthreads_version = "0.$pthreads_version"; } - if(version_compare($pthreads_version, "2.0.9") < 0){ - $logger->critical("pthreads >= 2.0.9 is required, while you have $pthreads_version."); + if(version_compare($pthreads_version, "3.1.5") < 0){ + $logger->critical("pthreads >= 3.1.5 is required, while you have $pthreads_version."); ++$errors; } @@ -412,23 +415,18 @@ namespace pocketmine { } } - if(!extension_loaded("Weakref") and !extension_loaded("weakref")){ - $logger->critical("Unable to find the Weakref extension."); - ++$errors; - } - if(!extension_loaded("curl")){ $logger->critical("Unable to find the cURL extension."); ++$errors; } - if(!extension_loaded("sqlite3")){ - $logger->critical("Unable to find the SQLite3 extension."); + if(!extension_loaded("yaml")){ + $logger->critical("Unable to find the YAML extension."); ++$errors; } - if(!extension_loaded("yaml")){ - $logger->critical("Unable to find the YAML extension."); + if(!extension_loaded("sqlite3")){ + $logger->critical("Unable to find the SQLite3 extension."); ++$errors; } @@ -445,9 +443,9 @@ namespace pocketmine { } if(file_exists(\pocketmine\PATH . ".git/refs/heads/master")){ //Found Git information! - define("pocketmine\\GIT_COMMIT", strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master")))); + define('pocketmine\GIT_COMMIT', strtolower(trim(file_get_contents(\pocketmine\PATH . ".git/refs/heads/master")))); }else{ //Unknown :( - define("pocketmine\\GIT_COMMIT", str_repeat("00", 20)); + define('pocketmine\GIT_COMMIT', str_repeat("00", 20)); } @define("ENDIANNESS", (pack("d", 1) === "\77\360\0\0\0\0\0\0" ? Binary::BIG_ENDIAN : Binary::LITTLE_ENDIAN)); @@ -474,7 +472,6 @@ namespace pocketmine { $killer = new ServerKiller(8); $killer->start(); - $killer->detach(); $logger->shutdown(); $logger->join(); diff --git a/src/pocketmine/Server.php b/src/pocketmine/Server.php index 175f66296..12c83dcea 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; @@ -117,7 +117,6 @@ use pocketmine\utils\ServerException; use pocketmine\utils\ServerKiller; use pocketmine\utils\Terminal; use pocketmine\utils\TextFormat; -use pocketmine\utils\TextWrapper; use pocketmine\utils\Utils; use pocketmine\utils\UUID; use pocketmine\utils\VersionString; @@ -132,6 +131,9 @@ class Server{ /** @var Server */ private static $instance = null; + /** @var \Threaded */ + private static $sleeper = null; + /** @var BanList */ private $banByName = null; @@ -360,13 +362,6 @@ class Server{ return $this->getConfigString("server-ip", "0.0.0.0"); } - /** - * @deprecated - */ - public function getServerName(){ - return $this->getConfigString("motd", "Minecraft: PE Server"); - } - public function getServerUniqueId(){ return $this->serverID; } @@ -656,56 +651,6 @@ class Server{ return round((array_sum($this->useAverage) / count($this->useAverage)) * 100, 2); } - - /** - * @deprecated - * - * @param $address - * @param int $timeout - */ - public function blockAddress($address, $timeout = 300){ - $this->network->blockAddress($address, $timeout); - } - - /** - * @deprecated - * - * @param $address - * @param $port - * @param $payload - */ - public function sendPacket($address, $port, $payload){ - $this->network->sendPacket($address, $port, $payload); - } - - /** - * @deprecated - * - * @return SourceInterface[] - */ - public function getInterfaces(){ - return $this->network->getInterfaces(); - } - - /** - * @deprecated - * - * @param SourceInterface $interface - */ - public function addInterface(SourceInterface $interface){ - $this->network->registerInterface($interface); - } - - /** - * @deprecated - * - * @param SourceInterface $interface - */ - public function removeInterface(SourceInterface $interface){ - $interface->shutdown(); - $this->network->unregisterInterface($interface); - } - /** * @return SimpleCommandMap */ @@ -743,7 +688,7 @@ class Server{ /** * @param string $name * - * @return Compound + * @return CompoundTag */ public function getOfflinePlayerData($name){ $name = strtolower($name); @@ -754,7 +699,7 @@ class Server{ $nbt->readCompressed(file_get_contents($path . "$name.dat")); return $nbt->getData(); - }catch(\Exception $e){ //zlib decode error / corrupt data + }catch(\Throwable $e){ //zlib decode error / corrupt data rename($path . "$name.dat", $path . "$name.dat.bak"); $this->logger->notice($this->getLanguage()->translateString("pocketmine.data.playerCorrupted", [$name])); } @@ -762,38 +707,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 +759,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 +803,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); @@ -871,11 +816,9 @@ class Server{ }else{ file_put_contents($this->getDataPath() . "players/" . strtolower($name) . ".dat", $nbt->writeCompressed()); } - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->logger->critical($this->getLanguage()->translateString("pocketmine.data.saveError", [$name, $e->getMessage()])); - if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){ - $this->logger->logException($e); - } + $this->logger->logException($e); } } @@ -1082,12 +1025,10 @@ class Server{ try{ $level = new Level($this, $name, $path, $provider); - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->logger->error($this->getLanguage()->translateString("pocketmine.level.loadError", [$name, $e->getMessage()])); - if($this->logger instanceof MainLogger){ - $this->logger->logException($e); - } + $this->logger->logException($e); return false; } @@ -1142,11 +1083,9 @@ class Server{ $level->initLevel(); $level->setTickRate($this->baseTickRate); - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->logger->error($this->getLanguage()->translateString("pocketmine.level.generateError", [$name, $e->getMessage()])); - if($this->logger instanceof MainLogger){ - $this->logger->logException($e); - } + $this->logger->logException($e); return false; } @@ -1438,10 +1377,16 @@ class Server{ /** * @return Server */ - public static function getInstance(){ + public static function getInstance() : Server{ return self::$instance; } + public static function microSleep(int $microseconds){ + Server::$sleeper->synchronized(function(int $ms){ + Server::$sleeper->wait($ms); + }, $microseconds); + } + /** * @param \ClassLoader $autoloader * @param \ThreadedLogger $logger @@ -1451,256 +1396,261 @@ class Server{ */ public function __construct(\ClassLoader $autoloader, \ThreadedLogger $logger, $filePath, $dataPath, $pluginPath){ self::$instance = $this; - + self::$sleeper = new \Threaded; $this->autoloader = $autoloader; $this->logger = $logger; - $this->filePath = $filePath; - if(!file_exists($dataPath . "worlds/")){ - mkdir($dataPath . "worlds/", 0777); - } - if(!file_exists($dataPath . "players/")){ - mkdir($dataPath . "players/", 0777); - } + try{ - if(!file_exists($pluginPath)){ - mkdir($pluginPath, 0777); - } - - $this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR; - $this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR; - - $this->console = new CommandReader(); - - $version = new VersionString($this->getPocketMineVersion()); - - $this->logger->info("Loading pocketmine.yml..."); - if(!file_exists($this->dataPath . "pocketmine.yml")){ - $content = file_get_contents($this->filePath . "src/pocketmine/resources/pocketmine.yml"); - if($version->isDev()){ - $content = str_replace("preferred-channel: stable", "preferred-channel: beta", $content); + $this->filePath = $filePath; + if(!file_exists($dataPath . "worlds/")){ + mkdir($dataPath . "worlds/", 0777); } - @file_put_contents($this->dataPath . "pocketmine.yml", $content); - } - $this->config = new Config($this->dataPath . "pocketmine.yml", Config::YAML, []); - $this->logger->info("Loading server properties..."); - $this->properties = new Config($this->dataPath . "server.properties", Config::PROPERTIES, [ - "motd" => "Minecraft: PE Server", - "server-port" => 19132, - "white-list" => false, - "announce-player-achievements" => true, - "spawn-protection" => 16, - "max-players" => 20, - "allow-flight" => false, - "spawn-animals" => true, - "spawn-mobs" => true, - "gamemode" => 0, - "force-gamemode" => false, - "hardcore" => false, - "pvp" => true, - "difficulty" => 1, - "generator-settings" => "", - "level-name" => "world", - "level-seed" => "", - "level-type" => "DEFAULT", - "enable-query" => true, - "enable-rcon" => false, - "rcon.password" => substr(base64_encode(@Utils::getRandomBytes(20, false)), 3, 10), - "auto-save" => true, - ]); - - $this->forceLanguage = $this->getProperty("settings.force-language", false); - $this->baseLang = new BaseLang($this->getProperty("settings.language", BaseLang::FALLBACK_LANGUAGE)); - $this->logger->info($this->getLanguage()->translateString("language.selected", [$this->getLanguage()->getName(), $this->getLanguage()->getLang()])); - - $this->memoryManager = new MemoryManager($this); - - $this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion()])); - - if(($poolSize = $this->getProperty("settings.async-workers", "auto")) === "auto"){ - $poolSize = ServerScheduler::$WORKERS; - $processors = Utils::getCoreCount() - 2; - - if($processors > 0){ - $poolSize = max(1, $processors); + if(!file_exists($dataPath . "players/")){ + mkdir($dataPath . "players/", 0777); } - } - ServerScheduler::$WORKERS = $poolSize; + if(!file_exists($pluginPath)){ + mkdir($pluginPath, 0777); + } - if($this->getProperty("network.batch-threshold", 256) >= 0){ - Network::$BATCH_THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256); - }else{ - Network::$BATCH_THRESHOLD = -1; - } - $this->networkCompressionLevel = $this->getProperty("network.compression-level", 7); - $this->networkCompressionAsync = $this->getProperty("network.async-compression", true); + $this->dataPath = realpath($dataPath) . DIRECTORY_SEPARATOR; + $this->pluginPath = realpath($pluginPath) . DIRECTORY_SEPARATOR; - $this->autoTickRate = (bool) $this->getProperty("level-settings.auto-tick-rate", true); - $this->autoTickRateLimit = (int) $this->getProperty("level-settings.auto-tick-rate-limit", 20); - $this->alwaysTickPlayers = (int) $this->getProperty("level-settings.always-tick-players", false); - $this->baseTickRate = (int) $this->getProperty("level-settings.base-tick-rate", 1); + $this->console = new CommandReader(); - $this->scheduler = new ServerScheduler(); + $version = new VersionString($this->getPocketMineVersion()); - if($this->getConfigBoolean("enable-rcon", false) === true){ - $this->rcon = new RCON($this, $this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50)); - } + $this->logger->info("Loading pocketmine.yml..."); + if(!file_exists($this->dataPath . "pocketmine.yml")){ + $content = file_get_contents($this->filePath . "src/pocketmine/resources/pocketmine.yml"); + if($version->isDev()){ + $content = str_replace("preferred-channel: stable", "preferred-channel: beta", $content); + } + @file_put_contents($this->dataPath . "pocketmine.yml", $content); + } + $this->config = new Config($this->dataPath . "pocketmine.yml", Config::YAML, []); - $this->entityMetadata = new EntityMetadataStore(); - $this->playerMetadata = new PlayerMetadataStore(); - $this->levelMetadata = new LevelMetadataStore(); + $this->logger->info("Loading server properties..."); + $this->properties = new Config($this->dataPath . "server.properties", Config::PROPERTIES, [ + "motd" => "Minecraft: PE Server", + "server-port" => 19132, + "white-list" => false, + "announce-player-achievements" => true, + "spawn-protection" => 16, + "max-players" => 20, + "allow-flight" => false, + "spawn-animals" => true, + "spawn-mobs" => true, + "gamemode" => 0, + "force-gamemode" => false, + "hardcore" => false, + "pvp" => true, + "difficulty" => 1, + "generator-settings" => "", + "level-name" => "world", + "level-seed" => "", + "level-type" => "DEFAULT", + "enable-query" => true, + "enable-rcon" => false, + "rcon.password" => substr(base64_encode(@Utils::getRandomBytes(20, false)), 3, 10), + "auto-save" => true, + ]); - $this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM); - $this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM); - if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){ - @rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt"); - } - @touch($this->dataPath . "banned-players.txt"); - $this->banByName = new BanList($this->dataPath . "banned-players.txt"); - $this->banByName->load(); - @touch($this->dataPath . "banned-ips.txt"); - $this->banByIP = new BanList($this->dataPath . "banned-ips.txt"); - $this->banByIP->load(); + $this->forceLanguage = $this->getProperty("settings.force-language", false); + $this->baseLang = new BaseLang($this->getProperty("settings.language", BaseLang::FALLBACK_LANGUAGE)); + $this->logger->info($this->getLanguage()->translateString("language.selected", [$this->getLanguage()->getName(), $this->getLanguage()->getLang()])); - $this->maxPlayers = $this->getConfigInt("max-players", 20); - $this->setAutoSave($this->getConfigBoolean("auto-save", true)); + $this->memoryManager = new MemoryManager($this); - if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){ - $this->setConfigInt("difficulty", 3); - } + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.start", [TextFormat::AQUA . $this->getVersion()])); - define("pocketmine\\DEBUG", (int) $this->getProperty("debug.level", 1)); - if($this->logger instanceof MainLogger){ - $this->logger->setLogDebug(\pocketmine\DEBUG > 1); - } + if(($poolSize = $this->getProperty("settings.async-workers", "auto")) === "auto"){ + $poolSize = ServerScheduler::$WORKERS; + $processors = Utils::getCoreCount() - 2; - if(\pocketmine\DEBUG >= 0){ - @cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion()); - } + if($processors > 0){ + $poolSize = max(1, $processors); + } + } - $this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()])); - define("BOOTUP_RANDOM", @Utils::getRandomBytes(16)); - $this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort()); + ServerScheduler::$WORKERS = $poolSize; - $this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId()); - $this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId()); + if($this->getProperty("network.batch-threshold", 256) >= 0){ + Network::$BATCH_THRESHOLD = (int) $this->getProperty("network.batch-threshold", 256); + }else{ + Network::$BATCH_THRESHOLD = -1; + } + $this->networkCompressionLevel = $this->getProperty("network.compression-level", 7); + $this->networkCompressionAsync = $this->getProperty("network.async-compression", true); - $this->network = new Network($this); - $this->network->setName($this->getMotd()); + $this->autoTickRate = (bool) $this->getProperty("level-settings.auto-tick-rate", true); + $this->autoTickRateLimit = (int) $this->getProperty("level-settings.auto-tick-rate-limit", 20); + $this->alwaysTickPlayers = (int) $this->getProperty("level-settings.always-tick-players", false); + $this->baseTickRate = (int) $this->getProperty("level-settings.base-tick-rate", 1); + + $this->scheduler = new ServerScheduler(); + + if($this->getConfigBoolean("enable-rcon", false) === true){ + $this->rcon = new RCON($this, $this->getConfigString("rcon.password", ""), $this->getConfigInt("rcon.port", $this->getPort()), ($ip = $this->getIp()) != "" ? $ip : "0.0.0.0", $this->getConfigInt("rcon.threads", 1), $this->getConfigInt("rcon.clients-per-thread", 50)); + } + + $this->entityMetadata = new EntityMetadataStore(); + $this->playerMetadata = new PlayerMetadataStore(); + $this->levelMetadata = new LevelMetadataStore(); + + $this->operators = new Config($this->dataPath . "ops.txt", Config::ENUM); + $this->whitelist = new Config($this->dataPath . "white-list.txt", Config::ENUM); + if(file_exists($this->dataPath . "banned.txt") and !file_exists($this->dataPath . "banned-players.txt")){ + @rename($this->dataPath . "banned.txt", $this->dataPath . "banned-players.txt"); + } + @touch($this->dataPath . "banned-players.txt"); + $this->banByName = new BanList($this->dataPath . "banned-players.txt"); + $this->banByName->load(); + @touch($this->dataPath . "banned-ips.txt"); + $this->banByIP = new BanList($this->dataPath . "banned-ips.txt"); + $this->banByIP->load(); + + $this->maxPlayers = $this->getConfigInt("max-players", 20); + $this->setAutoSave($this->getConfigBoolean("auto-save", true)); + + if($this->getConfigBoolean("hardcore", false) === true and $this->getDifficulty() < 3){ + $this->setConfigInt("difficulty", 3); + } + + define('pocketmine\DEBUG', (int) $this->getProperty("debug.level", 1)); + + ini_set('assert.exception', 1); + + if($this->logger instanceof MainLogger){ + $this->logger->setLogDebug(\pocketmine\DEBUG > 1); + } + + if(\pocketmine\DEBUG >= 0){ + @cli_set_process_title($this->getName() . " " . $this->getPocketMineVersion()); + } + + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.networkStart", [$this->getIp() === "" ? "*" : $this->getIp(), $this->getPort()])); + define("BOOTUP_RANDOM", @Utils::getRandomBytes(16)); + $this->serverID = Utils::getMachineUniqueId($this->getIp() . $this->getPort()); + + $this->getLogger()->debug("Server unique id: " . $this->getServerUniqueId()); + $this->getLogger()->debug("Machine unique id: " . Utils::getMachineUniqueId()); + + $this->network = new Network($this); + $this->network->setName($this->getMotd()); - $this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [ - $this->getName(), - ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE, - $this->getCodename(), - $this->getApiVersion() - ])); - $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()])); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.info", [ + $this->getName(), + ($version->isDev() ? TextFormat::YELLOW : "") . $version->get(true) . TextFormat::WHITE, + $this->getCodename(), + $this->getApiVersion() + ])); + $this->logger->info($this->getLanguage()->translateString("pocketmine.server.license", [$this->getName()])); - Timings::init(); + Timings::init(); - $this->consoleSender = new ConsoleCommandSender(); - $this->commandMap = new SimpleCommandMap($this); + $this->consoleSender = new ConsoleCommandSender(); + $this->commandMap = new SimpleCommandMap($this); - $this->registerEntities(); - $this->registerTiles(); + $this->registerEntities(); + $this->registerTiles(); - InventoryType::init(); - Block::init(); - Item::init(); - Biome::init(); - Effect::init(); - Enchantment::init(); - Attribute::init(); - /** TODO: @deprecated */ - TextWrapper::init(); - $this->craftingManager = new CraftingManager(); + InventoryType::init(); + Block::init(); + Item::init(); + Biome::init(); + Effect::init(); + Enchantment::init(); + Attribute::init(); + $this->craftingManager = new CraftingManager(); - $this->pluginManager = new PluginManager($this, $this->commandMap); - $this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender); - $this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false)); - $this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20); - $this->pluginManager->registerInterface(PharPluginLoader::class); - $this->pluginManager->registerInterface(ScriptPluginLoader::class); + $this->pluginManager = new PluginManager($this, $this->commandMap); + $this->pluginManager->subscribeToPermission(Server::BROADCAST_CHANNEL_ADMINISTRATIVE, $this->consoleSender); + $this->pluginManager->setUseTimings($this->getProperty("settings.enable-profiling", false)); + $this->profilingTickRate = (float) $this->getProperty("settings.profile-report-trigger", 20); + $this->pluginManager->registerInterface(PharPluginLoader::class); + $this->pluginManager->registerInterface(ScriptPluginLoader::class); - set_exception_handler([$this, "exceptionHandler"]); - register_shutdown_function([$this, "crashDump"]); + register_shutdown_function([$this, "crashDump"]); - $this->queryRegenerateTask = new QueryRegenerateEvent($this, 5); + $this->queryRegenerateTask = new QueryRegenerateEvent($this, 5); + $this->network->registerInterface(new RakLibInterface($this)); - $this->network->registerInterface(new RakLibInterface($this)); + $this->pluginManager->loadPlugins($this->pluginPath); - $this->pluginManager->loadPlugins($this->pluginPath); + $this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net")); - $this->updater = new AutoUpdater($this, $this->getProperty("auto-updater.host", "www.pocketmine.net")); + $this->enablePlugins(PluginLoadOrder::STARTUP); - $this->enablePlugins(PluginLoadOrder::STARTUP); - - LevelProviderManager::addProvider($this, Anvil::class); - LevelProviderManager::addProvider($this, McRegion::class); - if(extension_loaded("leveldb")){ - $this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable")); - LevelProviderManager::addProvider($this, LevelDB::class); - } + LevelProviderManager::addProvider($this, Anvil::class); + LevelProviderManager::addProvider($this, McRegion::class); + if(extension_loaded("leveldb")){ + $this->logger->debug($this->getLanguage()->translateString("pocketmine.debug.enable")); + LevelProviderManager::addProvider($this, LevelDB::class); + } - Generator::addGenerator(Flat::class, "flat"); - Generator::addGenerator(Normal::class, "normal"); - Generator::addGenerator(Normal::class, "default"); - Generator::addGenerator(Nether::class, "hell"); - Generator::addGenerator(Nether::class, "nether"); + Generator::addGenerator(Flat::class, "flat"); + Generator::addGenerator(Normal::class, "normal"); + Generator::addGenerator(Normal::class, "default"); + Generator::addGenerator(Nether::class, "hell"); + Generator::addGenerator(Nether::class, "nether"); - foreach((array) $this->getProperty("worlds", []) as $name => $worldSetting){ - if($this->loadLevel($name) === false){ - $seed = $this->getProperty("worlds.$name.seed", time()); - $options = explode(":", $this->getProperty("worlds.$name.generator", Generator::getGenerator("default"))); - $generator = Generator::getGenerator(array_shift($options)); - if(count($options) > 0){ - $options = [ - "preset" => implode(":", $options), - ]; - }else{ - $options = []; + foreach((array) $this->getProperty("worlds", []) as $name => $worldSetting){ + if($this->loadLevel($name) === false){ + $seed = $this->getProperty("worlds.$name.seed", time()); + $options = explode(":", $this->getProperty("worlds.$name.generator", Generator::getGenerator("default"))); + $generator = Generator::getGenerator(array_shift($options)); + if(count($options) > 0){ + $options = [ + "preset" => implode(":", $options), + ]; + }else{ + $options = []; + } + + $this->generateLevel($name, $seed, $generator, $options); + } + } + + if($this->getDefaultLevel() === null){ + $default = $this->getConfigString("level-name", "world"); + if(trim($default) == ""){ + $this->getLogger()->warning("level-name cannot be null, using default"); + $default = "world"; + $this->setConfigString("level-name", "world"); + } + if($this->loadLevel($default) === false){ + $seed = $this->getConfigInt("level-seed", time()); + $this->generateLevel($default, $seed === 0 ? time() : $seed); } - $this->generateLevel($name, $seed, $generator, $options); - } - } - - if($this->getDefaultLevel() === null){ - $default = $this->getConfigString("level-name", "world"); - if(trim($default) == ""){ - $this->getLogger()->warning("level-name cannot be null, using default"); - $default = "world"; - $this->setConfigString("level-name", "world"); - } - if($this->loadLevel($default) === false){ - $seed = $this->getConfigInt("level-seed", time()); - $this->generateLevel($default, $seed === 0 ? time() : $seed); + $this->setDefaultLevel($this->getLevelByName($default)); } - $this->setDefaultLevel($this->getLevelByName($default)); + + $this->properties->save(true); + + if(!($this->getDefaultLevel() instanceof Level)){ + $this->getLogger()->emergency($this->getLanguage()->translateString("pocketmine.level.defaultError")); + $this->forceShutdown(); + + return; + } + + if($this->getProperty("ticks-per.autosave", 6000) > 0){ + $this->autoSaveTicks = (int) $this->getProperty("ticks-per.autosave", 6000); + } + + $this->enablePlugins(PluginLoadOrder::POSTWORLD); + + $this->start(); + }catch(\Throwable $e){ + $this->exceptionHandler($e); } - - - $this->properties->save(true); - - if(!($this->getDefaultLevel() instanceof Level)){ - $this->getLogger()->emergency($this->getLanguage()->translateString("pocketmine.level.defaultError")); - $this->forceShutdown(); - - return; - } - - if($this->getProperty("ticks-per.autosave", 6000) > 0){ - $this->autoSaveTicks = (int) $this->getProperty("ticks-per.autosave", 6000); - } - - $this->enablePlugins(PluginLoadOrder::POSTWORLD); - - $this->start(); } /** @@ -1808,7 +1758,7 @@ class Server{ $packet->encode(); $packet->isEncoded = true; if(Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){ - Server::getInstance()->batchPackets($players, [$packet->buffer], false, $packet->getChannel()); + Server::getInstance()->batchPackets($players, [$packet->buffer], false); return; } @@ -1826,9 +1776,8 @@ class Server{ * @param Player[] $players * @param DataPacket[]|string $packets * @param bool $forceSync - * @param int $channel */ - public function batchPackets(array $players, array $packets, $forceSync = false, $channel = 0){ + public function batchPackets(array $players, array $packets, $forceSync = false){ Timings::$playerNetworkTimer->startTiming(); $str = ""; @@ -1851,7 +1800,7 @@ class Server{ } if(!$forceSync and $this->networkCompressionAsync){ - $task = new CompressBatchedTask($str, $targets, $this->networkCompressionLevel, $channel); + $task = new CompressBatchedTask($str, $targets, $this->networkCompressionLevel); $this->getScheduler()->scheduleAsyncTask($task); }else{ $this->broadcastPacketsCallback(zlib_encode($str, ZLIB_ENCODING_DEFLATE, $this->networkCompressionLevel), $targets); @@ -1897,15 +1846,6 @@ class Server{ $this->pluginManager->enablePlugin($plugin); } - /** - * @param Plugin $plugin - * - * @deprecated - */ - public function loadPlugin(Plugin $plugin){ - $this->enablePlugin($plugin); - } - public function disablePlugins(){ $this->pluginManager->disablePlugins(); } @@ -1932,10 +1872,6 @@ class Server{ * @throws \Exception */ public function dispatchCommand(CommandSender $sender, $commandLine){ - if(!($sender instanceof CommandSender)){ - throw new ServerException("CommandSender is not valid"); - } - if($this->commandMap->dispatch($sender, $commandLine)){ return true; } @@ -1970,8 +1906,6 @@ class Server{ $this->reloadWhitelist(); $this->operators->reload(); - $this->memoryManager->doObjectCleanup(); - foreach($this->getIPBans()->getEntries() as $entry){ $this->getNetwork()->blockAddress($entry->getName(), -1); } @@ -1988,11 +1922,6 @@ class Server{ * Shutdowns the server correctly */ public function shutdown(){ - if($this->isRunning){ - $killer = new ServerKiller(90); - $killer->start(); - $killer->detach(); - } $this->isRunning = false; } @@ -2041,7 +1970,8 @@ class Server{ $this->properties->save(); $this->getLogger()->debug("Closing console"); - $this->console->kill(); + $this->console->shutdown(); + $this->console->notify(); $this->getLogger()->debug("Stopping network interfaces"); foreach($this->network->getInterfaces() as $interface){ @@ -2049,11 +1979,10 @@ class Server{ $this->network->unregisterInterface($interface); } - $this->memoryManager->doObjectCleanup(); - gc_collect_cycles(); - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->logger->emergency("Crashed while crashing, killing process"); + $this->logger->emergency(get_class($e) . ": ". $e->getMessage()); @kill(getmypid()); } @@ -2111,7 +2040,7 @@ class Server{ } } - public function exceptionHandler(\Exception $e, $trace = null){ + public function exceptionHandler(\Throwable $e, $trace = null){ if($e === null){ return; } @@ -2134,9 +2063,7 @@ class Server{ $errfile = cleanPath($errfile); - if($this->logger instanceof MainLogger){ - $this->logger->logException($e, $trace); - } + $this->logger->logException($e, $trace); $lastError = [ "type" => $type, @@ -2166,7 +2093,7 @@ class Server{ $this->logger->emergency($this->getLanguage()->translateString("pocketmine.crash.create")); try{ $dump = new CrashDump($this); - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->logger->critical($this->getLanguage()->translateString("pocketmine.crash.error", $e->getMessage())); return; } @@ -2226,7 +2153,7 @@ class Server{ if($next > microtime(true)){ try{ time_sleep_until($next); - }catch(\Exception $e){ + }catch(\Throwable $e){ //Sometimes $next is less than the current time. High load? } } @@ -2345,11 +2272,9 @@ class Server{ $level->tickRateCounter = $level->getTickRate(); } } - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->logger->critical($this->getLanguage()->translateString("pocketmine.level.tickError", [$level->getName(), $e->getMessage()])); - if(\pocketmine\DEBUG > 1 and $this->logger instanceof MainLogger){ - $this->logger->logException($e); - } + $this->logger->logException($e); } } } @@ -2440,11 +2365,9 @@ class Server{ if(strlen($payload) > 2 and substr($payload, 0, 2) === "\xfe\xfd" and $this->queryHandler instanceof QueryHandler){ $this->queryHandler->handle($address, $port, $payload); } - }catch(\Exception $e){ + }catch(\Throwable $e){ if(\pocketmine\DEBUG > 1){ - if($this->logger instanceof MainLogger){ - $this->logger->logException($e); - } + $this->logger->logException($e); } $this->getNetwork()->blockAddress($address, 600); @@ -2498,10 +2421,8 @@ class Server{ if($this->queryHandler !== null){ $this->queryHandler->regenerateInfo(); } - }catch(\Exception $e){ - if($this->logger instanceof MainLogger){ - $this->logger->logException($e); - } + }catch(\Throwable $e){ + $this->logger->logException($e); } } diff --git a/src/pocketmine/Thread.php b/src/pocketmine/Thread.php index ce05d37b2..57e7726d9 100644 --- a/src/pocketmine/Thread.php +++ b/src/pocketmine/Thread.php @@ -28,6 +28,7 @@ abstract class Thread extends \Thread{ /** @var \ClassLoader */ protected $classLoader; + protected $isKilled = false; public function getClassLoader(){ return $this->classLoader; @@ -51,7 +52,7 @@ abstract class Thread extends \Thread{ } } - public function start($options = PTHREADS_INHERIT_ALL){ + public function start(int $options = PTHREADS_INHERIT_ALL){ ThreadManager::getInstance()->add($this); if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){ @@ -68,18 +69,14 @@ abstract class Thread extends \Thread{ * Stops the thread using the best way possible. Try to stop it yourself before calling this. */ public function quit(){ - if($this->isRunning()){ - $this->kill(); - $this->detach(); - }elseif(!$this->isJoined()){ + $this->isKilled = true; + + $this->notify(); + + if(!$this->isJoined()){ if(!$this->isTerminated()){ $this->join(); - }else{ - $this->kill(); - $this->detach(); } - }else{ - $this->detach(); } ThreadManager::getInstance()->remove($this); @@ -88,4 +85,4 @@ abstract class Thread extends \Thread{ public function getThreadName(){ return (new \ReflectionClass($this))->getShortName(); } -} \ No newline at end of file +} diff --git a/src/pocketmine/ThreadManager.php b/src/pocketmine/ThreadManager.php index fbe49a036..27851a098 100644 --- a/src/pocketmine/ThreadManager.php +++ b/src/pocketmine/ThreadManager.php @@ -21,7 +21,7 @@ namespace pocketmine; -class ThreadManager extends \Threaded{ +class ThreadManager extends \Volatile{ /** @var ThreadManager */ private static $instance = null; diff --git a/src/pocketmine/Worker.php b/src/pocketmine/Worker.php index 2b54171ec..0d2f2c098 100644 --- a/src/pocketmine/Worker.php +++ b/src/pocketmine/Worker.php @@ -28,6 +28,8 @@ abstract class Worker extends \Worker{ /** @var \ClassLoader */ protected $classLoader; + + protected $isKilled = false; public function getClassLoader(){ return $this->classLoader; @@ -51,7 +53,7 @@ abstract class Worker extends \Worker{ } } - public function start($options = PTHREADS_INHERIT_ALL){ + public function start(int $options = PTHREADS_INHERIT_ALL){ ThreadManager::getInstance()->add($this); if(!$this->isRunning() and !$this->isJoined() and !$this->isTerminated()){ @@ -68,19 +70,18 @@ abstract class Worker extends \Worker{ * Stops the thread using the best way possible. Try to stop it yourself before calling this. */ public function quit(){ + $this->isKilled = true; + + $this->notify(); + if($this->isRunning()){ + $this->shutdown(); + $this->notify(); $this->unstack(); - $this->kill(); - $this->detach(); }elseif(!$this->isJoined()){ if(!$this->isTerminated()){ $this->join(); - }else{ - $this->kill(); - $this->detach(); } - }else{ - $this->detach(); } ThreadManager::getInstance()->remove($this); @@ -89,4 +90,4 @@ abstract class Worker extends \Worker{ public function getThreadName(){ return (new \ReflectionClass($this))->getShortName(); } -} \ No newline at end of file +} diff --git a/src/pocketmine/block/ActivatorRail.php b/src/pocketmine/block/ActivatorRail.php new file mode 100644 index 000000000..9507a01ef --- /dev/null +++ b/src/pocketmine/block/ActivatorRail.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Activator Rail"; + } +} diff --git a/src/pocketmine/block/Block.php b/src/pocketmine/block/Block.php index 2bfc61b7d..ea53daada 100644 --- a/src/pocketmine/block/Block.php +++ b/src/pocketmine/block/Block.php @@ -63,9 +63,9 @@ class Block extends Position implements Metadatable{ const GOLD_ORE = 14; const IRON_ORE = 15; const COAL_ORE = 16; + const LOG = 17; const WOOD = 17; const TRUNK = 17; - const LOG = 17; const LEAVES = 18; const LEAVE = 18; const SPONGE = 19; @@ -74,18 +74,18 @@ class Block extends Position implements Metadatable{ const LAPIS_BLOCK = 22; const SANDSTONE = 24; - + const NOTE_BLOCK = 25; const BED_BLOCK = 26; - - + const POWERED_RAIL = 27; + const DETECTOR_RAIL = 28; const COBWEB = 30; const TALL_GRASS = 31; const BUSH = 32; const DEAD_BUSH = 32; const WOOL = 35; const DANDELION = 37; - const ROSE = 38; const POPPY = 38; + const ROSE = 38; const RED_FLOWER = 38; const BROWN_MUSHROOM = 39; const RED_MUSHROOM = 40; @@ -110,7 +110,7 @@ class Block extends Position implements Metadatable{ const OAK_WOOD_STAIRS = 53; const OAK_WOODEN_STAIRS = 53; const CHEST = 54; - + const REDSTONE_WIRE = 55; const DIAMOND_ORE = 56; const DIAMOND_BLOCK = 57; const CRAFTING_TABLE = 58; @@ -125,17 +125,20 @@ class Block extends Position implements Metadatable{ const WOODEN_DOOR_BLOCK = 64; const WOOD_DOOR_BLOCK = 64; const LADDER = 65; - + const RAIL = 66; const COBBLE_STAIRS = 67; const COBBLESTONE_STAIRS = 67; const WALL_SIGN = 68; - + const LEVER = 69; + const STONE_PRESSURE_PLATE = 70; const IRON_DOOR_BLOCK = 71; - + const WOODEN_PRESSURE_PLATE = 72; const REDSTONE_ORE = 73; const GLOWING_REDSTONE_ORE = 74; const LIT_REDSTONE_ORE = 74; - + const REDSTONE_TORCH = 75; + const LIT_REDSTONE_TORCH = 76; + const STONE_BUTTON = 77; const SNOW = 78; const SNOW_LAYER = 78; const ICE = 79; @@ -152,18 +155,17 @@ class Block extends Position implements Metadatable{ const GLOWSTONE = 89; const GLOWSTONE_BLOCK = 89; - + const PORTAL_BLOCK = 90; const LIT_PUMPKIN = 91; const JACK_O_LANTERN = 91; const CAKE_BLOCK = 92; const TRAPDOOR = 96; - const WOODEN_TRAPDOOR = 96; - const WOOD_TRAPDOOR = 96; - + const MONSTER_EGG_BLOCK = 97; const STONE_BRICKS = 98; const STONE_BRICK = 98; - + const BROWN_MUSHROOM_BLOCK = 99; + const RED_MUSHROOM_BLOCK = 100; const IRON_BAR = 101; const IRON_BARS = 101; const GLASS_PANE = 102; @@ -183,17 +185,24 @@ class Block extends Position implements Metadatable{ const NETHER_BRICK_BLOCK = 112; const NETHER_BRICK_FENCE = 113; const NETHER_BRICKS_STAIRS = 114; - + const NETHER_WART_BLOCK = 115; const ENCHANTING_TABLE = 116; const ENCHANT_TABLE = 116; const ENCHANTMENT_TABLE = 116; const BREWING_STAND = 117; + const END_PORTAL_FRAME = 120; const END_STONE = 121; + const REDSTONE_LAMP = 122; + const LIT_REDSTONE_LAMP = 123; + const ACTIVATOR_RAIL = 126; + const COCOA_BLOCK = 127; const SANDSTONE_STAIRS = 128; const EMERALD_ORE = 129; + const TRIPWIRE_HOOK = 131; + const TRIPWIRE = 132; const EMERALD_BLOCK = 133; const SPRUCE_WOOD_STAIRS = 134; const SPRUCE_WOODEN_STAIRS = 134; @@ -208,11 +217,16 @@ class Block extends Position implements Metadatable{ const FLOWER_POT_BLOCK = 140; const CARROT_BLOCK = 141; const POTATO_BLOCK = 142; - + const WOODEN_BUTTON = 143; + const MOB_HEAD_BLOCK = 144; const ANVIL = 145; const TRAPPED_CHEST = 146; + const WEIGHTED_PRESSURE_PLATE_LIGHT = 147; + const WEIGHTED_PRESSURE_PLATE_HEAVY = 148; + const DAYLIGHT_SENSOR = 151; const REDSTONE_BLOCK = 152; + const NETHER_QUARTZ_ORE = 153; const QUARTZ_BLOCK = 155; const QUARTZ_STAIRS = 156; @@ -238,6 +252,7 @@ class Block extends Position implements Metadatable{ const DARK_OAK_WOODEN_STAIRS = 164; const IRON_TRAPDOOR = 167; + const HAY_BALE = 170; const CARPET = 171; const HARDENED_CLAY = 172; @@ -245,6 +260,8 @@ class Block extends Position implements Metadatable{ const PACKED_ICE = 174; const DOUBLE_PLANT = 175; + const INVERTED_DAYLIGHT_SENSOR = 178; + const FENCE_GATE_SPRUCE = 183; const FENCE_GATE_BIRCH = 184; const FENCE_GATE_JUNGLE = 185; @@ -280,32 +297,6 @@ class Block extends Position implements Metadatable{ /** @var AxisAlignedBB */ public $boundingBox = null; - /** - * Backwards-compatibility with old way to define block properties - * - * @deprecated - * - * @param string $key - * - * @return mixed - */ - public function __get($key){ - static $map = [ - "hardness" => "getHardness", - "lightLevel" => "getLightLevel", - "frictionFactor" => "getFrictionFactor", - "name" => "getName", - "isPlaceable" => "canBePlaced", - "isReplaceable" => "canBeReplaced", - "isTransparent" => "isTransparent", - "isSolid" => "isSolid", - "isFlowable" => "canBeFlowedInto", - "isActivable" => "canBeActivated", - "hasEntityCollision" => "hasEntityCollision" - ]; - return isset($map[$key]) ? $this->{$map[$key]}() : null; - } - public static function init(){ if(self::$list === null){ self::$list = new \SplFixedArray(256); @@ -338,8 +329,13 @@ class Block extends Position implements Metadatable{ self::$list[self::GLASS] = Glass::class; self::$list[self::LAPIS_ORE] = LapisOre::class; self::$list[self::LAPIS_BLOCK] = Lapis::class; + self::$list[self::ACTIVATOR_RAIL] = ActivatorRail::class; + self::$list[self::COCOA_BLOCK] = CocoaBlock::class; self::$list[self::SANDSTONE] = Sandstone::class; + self::$list[self::NOTE_BLOCK] = NoteBlock::class; self::$list[self::BED_BLOCK] = Bed::class; + self::$list[self::POWERED_RAIL] = PoweredRail::class; + self::$list[self::DETECTOR_RAIL] = DetectorRail::class; self::$list[self::COBWEB] = Cobweb::class; self::$list[self::TALL_GRASS] = TallGrass::class; self::$list[self::DEAD_BUSH] = DeadBush::class; @@ -373,14 +369,20 @@ class Block extends Position implements Metadatable{ self::$list[self::SIGN_POST] = SignPost::class; self::$list[self::WOOD_DOOR_BLOCK] = WoodDoor::class; self::$list[self::LADDER] = Ladder::class; + self::$list[self::RAIL] = Rail::class; self::$list[self::COBBLESTONE_STAIRS] = CobblestoneStairs::class; self::$list[self::WALL_SIGN] = WallSign::class; - + self::$list[self::LEVER] = Lever::class; + self::$list[self::STONE_PRESSURE_PLATE] = StonePressurePlate::class; self::$list[self::IRON_DOOR_BLOCK] = IronDoor::class; + self::$list[self::WOODEN_PRESSURE_PLATE] = WoodenPressurePlate::class; self::$list[self::REDSTONE_ORE] = RedstoneOre::class; self::$list[self::GLOWING_REDSTONE_ORE] = GlowingRedstoneOre::class; + self::$list[self::REDSTONE_TORCH] = RedstoneTorch::class; + self::$list[self::LIT_REDSTONE_TORCH] = LitRedstoneTorch::class; + self::$list[self::STONE_BUTTON] = StoneButton::class; self::$list[self::SNOW_LAYER] = SnowLayer::class; self::$list[self::ICE] = Ice::class; self::$list[self::SNOW_BLOCK] = Snow::class; @@ -421,9 +423,12 @@ class Block extends Position implements Metadatable{ self::$list[self::BREWING_STAND] = BrewingStand::class; self::$list[self::END_PORTAL_FRAME] = EndPortalFrame::class; self::$list[self::END_STONE] = EndStone::class; + self::$list[self::REDSTONE_LAMP] = RedstoneLamp::class; + self::$list[self::LIT_REDSTONE_LAMP] = LitRedstoneLamp::class; self::$list[self::SANDSTONE_STAIRS] = SandstoneStairs::class; self::$list[self::EMERALD_ORE] = EmeraldOre::class; - + self::$list[self::TRIPWIRE_HOOK] = TripwireHook::class; + self::$list[self::TRIPWIRE] = Tripwire::class; self::$list[self::EMERALD_BLOCK] = Emerald::class; self::$list[self::SPRUCE_WOOD_STAIRS] = SpruceWoodStairs::class; self::$list[self::BIRCH_WOOD_STAIRS] = BirchWoodStairs::class; @@ -432,8 +437,13 @@ class Block extends Position implements Metadatable{ self::$list[self::FLOWER_POT_BLOCK] = FlowerPot::class; self::$list[self::CARROT_BLOCK] = Carrot::class; self::$list[self::POTATO_BLOCK] = Potato::class; + self::$list[self::WOODEN_BUTTON] = WoodenButton::class; self::$list[self::ANVIL] = Anvil::class; self::$list[self::TRAPPED_CHEST] = TrappedChest::class; + self::$list[self::WEIGHTED_PRESSURE_PLATE_LIGHT] = WeightedPressurePlateLight::class; + self::$list[self::WEIGHTED_PRESSURE_PLATE_HEAVY] = WeightedPressurePlateHeavy::class; + + self::$list[self::DAYLIGHT_SENSOR] = DaylightSensor::class; self::$list[self::REDSTONE_BLOCK] = Redstone::class; self::$list[self::QUARTZ_BLOCK] = Quartz::class; diff --git a/src/pocketmine/block/BurningFurnace.php b/src/pocketmine/block/BurningFurnace.php index ed12a40b6..84de41121 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/CocoaBlock.php b/src/pocketmine/block/CocoaBlock.php new file mode 100644 index 000000000..391ba9463 --- /dev/null +++ b/src/pocketmine/block/CocoaBlock.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Cocoa Block"; + } +} diff --git a/src/pocketmine/block/DaylightSensor.php b/src/pocketmine/block/DaylightSensor.php new file mode 100644 index 000000000..590952b42 --- /dev/null +++ b/src/pocketmine/block/DaylightSensor.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Daylight Sensor"; + } +} diff --git a/src/pocketmine/block/DetectorRail.php b/src/pocketmine/block/DetectorRail.php new file mode 100644 index 000000000..7a573bd3b --- /dev/null +++ b/src/pocketmine/block/DetectorRail.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Detector Rail"; + } +} diff --git a/src/pocketmine/block/DoubleSlab.php b/src/pocketmine/block/DoubleSlab.php index 3ccdcf84b..e8b58511a 100644 --- a/src/pocketmine/block/DoubleSlab.php +++ b/src/pocketmine/block/DoubleSlab.php @@ -51,7 +51,7 @@ class DoubleSlab extends Solid{ 6 => "Quartz", 7 => "Nether Brick", ]; - 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 4a207f917..1fc768cab 100644 --- a/src/pocketmine/block/DoubleWoodSlab.php +++ b/src/pocketmine/block/DoubleWoodSlab.php @@ -51,7 +51,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 5890367ab..59539906b 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/Lever.php b/src/pocketmine/block/Lever.php new file mode 100644 index 000000000..993cd52b8 --- /dev/null +++ b/src/pocketmine/block/Lever.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Lever"; + } +} diff --git a/src/pocketmine/block/LitRedstoneLamp.php b/src/pocketmine/block/LitRedstoneLamp.php new file mode 100644 index 000000000..fe989d45f --- /dev/null +++ b/src/pocketmine/block/LitRedstoneLamp.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Lit Redstone Lamp"; + } +} diff --git a/src/pocketmine/block/LitRedstoneTorch.php b/src/pocketmine/block/LitRedstoneTorch.php new file mode 100644 index 000000000..3ae7410c1 --- /dev/null +++ b/src/pocketmine/block/LitRedstoneTorch.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Lit Redstone Torch"; + } +} diff --git a/src/pocketmine/block/NoteBlock.php b/src/pocketmine/block/NoteBlock.php new file mode 100644 index 000000000..d44a92263 --- /dev/null +++ b/src/pocketmine/block/NoteBlock.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Note Block"; + } +} diff --git a/src/pocketmine/block/Planks.php b/src/pocketmine/block/Planks.php index e0452a657..2889f0056 100644 --- a/src/pocketmine/block/Planks.php +++ b/src/pocketmine/block/Planks.php @@ -53,11 +53,11 @@ class Planks extends Solid{ self::BIRCH => "Birch Wood Planks", self::JUNGLE => "Jungle Wood Planks", self::ACACIA => "Acacia Wood Planks", - self::DARK_OAK => "Jungle Wood Planks", + self::DARK_OAK => "Dark Oak Wood Planks", "", "" ]; return $names[$this->meta & 0x07]; } -} \ No newline at end of file +} diff --git a/src/pocketmine/block/PoweredRail.php b/src/pocketmine/block/PoweredRail.php new file mode 100644 index 000000000..ec8eb9238 --- /dev/null +++ b/src/pocketmine/block/PoweredRail.php @@ -0,0 +1,34 @@ +meta = $meta; + } + + public function getName(){ + return "Powered Rail"; + } +} diff --git a/src/pocketmine/block/Rail.php b/src/pocketmine/block/Rail.php new file mode 100644 index 000000000..3712bffcf --- /dev/null +++ b/src/pocketmine/block/Rail.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Rail"; + } +} diff --git a/src/pocketmine/block/RedstoneLamp.php b/src/pocketmine/block/RedstoneLamp.php new file mode 100644 index 000000000..e3e3f16ca --- /dev/null +++ b/src/pocketmine/block/RedstoneLamp.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Redstone Lamp"; + } +} diff --git a/src/pocketmine/block/RedstoneTorch.php b/src/pocketmine/block/RedstoneTorch.php new file mode 100644 index 000000000..1c752a56e --- /dev/null +++ b/src/pocketmine/block/RedstoneTorch.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Redstone Torch"; + } +} diff --git a/src/pocketmine/block/StoneButton.php b/src/pocketmine/block/StoneButton.php new file mode 100644 index 000000000..e17a30bbb --- /dev/null +++ b/src/pocketmine/block/StoneButton.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Stone Button"; + } +} diff --git a/src/pocketmine/block/StonePressurePlate.php b/src/pocketmine/block/StonePressurePlate.php new file mode 100644 index 000000000..4d10165e8 --- /dev/null +++ b/src/pocketmine/block/StonePressurePlate.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Stone Pressure Plate"; + } +} 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/block/TrappedChest.php b/src/pocketmine/block/TrappedChest.php index d1848db1d..3e189c252 100644 --- a/src/pocketmine/block/TrappedChest.php +++ b/src/pocketmine/block/TrappedChest.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\CompoundTag; use pocketmine\nbt\tag\Enum; -use pocketmine\nbt\tag\Int; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\Int as IntTag; +use pocketmine\nbt\tag\String as StringTag; use pocketmine\Player; use pocketmine\tile\Chest as TileChest; use pocketmine\tile\Tile; @@ -96,17 +96,17 @@ class TrappedChest extends Transparent{ } $this->getLevel()->setBlock($block, $this, true, true); - $nbt = new Compound("", [ + $nbt = new CompoundTag("", [ new Enum("Items", []), - new String("id", Tile::CHEST), - new Int("x", $this->x), - new Int("y", $this->y), - new Int("z", $this->z) + 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,12 +147,12 @@ class TrappedChest extends Transparent{ if($t instanceof TileChest){ $chest = $t; }else{ - $nbt = new Compound("", [ + $nbt = new CompoundTag("", [ new Enum("Items", []), - new String("id", Tile::CHEST), - new Int("x", $this->x), - new Int("y", $this->y), - new Int("z", $this->z) + 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); @@ -178,4 +178,4 @@ class TrappedChest extends Transparent{ [$this->id, 0, 1], ]; } -} \ No newline at end of file +} diff --git a/src/pocketmine/block/Tripwire.php b/src/pocketmine/block/Tripwire.php new file mode 100644 index 000000000..7dd33fd8a --- /dev/null +++ b/src/pocketmine/block/Tripwire.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Tripwire"; + } +} diff --git a/src/pocketmine/block/TripwireHook.php b/src/pocketmine/block/TripwireHook.php new file mode 100644 index 000000000..38365d376 --- /dev/null +++ b/src/pocketmine/block/TripwireHook.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Tripwire Hook"; + } +} diff --git a/src/pocketmine/block/WeightedPressurePlateHeavy.php b/src/pocketmine/block/WeightedPressurePlateHeavy.php new file mode 100644 index 000000000..64a4650ac --- /dev/null +++ b/src/pocketmine/block/WeightedPressurePlateHeavy.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Weighted Pressure Plate Heavy"; + } +} diff --git a/src/pocketmine/block/WeightedPressurePlateLight.php b/src/pocketmine/block/WeightedPressurePlateLight.php new file mode 100644 index 000000000..93b73feb9 --- /dev/null +++ b/src/pocketmine/block/WeightedPressurePlateLight.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Weighted Pressure Plate Light"; + } +} diff --git a/src/pocketmine/block/WoodenButton.php b/src/pocketmine/block/WoodenButton.php new file mode 100644 index 000000000..63d625646 --- /dev/null +++ b/src/pocketmine/block/WoodenButton.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Wooden Button"; + } +} diff --git a/src/pocketmine/block/WoodenPressurePlate.php b/src/pocketmine/block/WoodenPressurePlate.php new file mode 100644 index 000000000..792a0e86e --- /dev/null +++ b/src/pocketmine/block/WoodenPressurePlate.php @@ -0,0 +1,35 @@ +meta = $meta; + } + + public function getName(){ + return "Wooden Pressure Plate"; + } +} diff --git a/src/pocketmine/command/CommandReader.php b/src/pocketmine/command/CommandReader.php index 15287692e..f02583a42 100644 --- a/src/pocketmine/command/CommandReader.php +++ b/src/pocketmine/command/CommandReader.php @@ -25,26 +25,36 @@ use pocketmine\Thread; class CommandReader extends Thread{ private $readline; - /** @var \Threaded */ protected $buffer; + private $shutdown = false; public function __construct(){ - $this->buffer = \ThreadedFactory::create(); + $this->buffer = new \Threaded; $this->start(); } + public function shutdown(){ + $this->shutdown = true; + } + private function readLine(){ if(!$this->readline){ - $line = trim(fgets(fopen("php://stdin", "r"))); + global $stdin; + + if(!is_resource($stdin)){ + return ""; + } + + return trim(fgets($stdin)); }else{ $line = trim(readline("> ")); if($line != ""){ readline_add_history($line); } - } - return $line; + return $line; + } } /** @@ -65,15 +75,20 @@ class CommandReader extends Thread{ if(extension_loaded("readline") and !isset($opts["disable-readline"])){ $this->readline = true; }else{ + global $stdin; + $stdin = fopen("php://stdin", "r"); + stream_set_blocking($stdin, 0); $this->readline = false; } $lastLine = microtime(true); - while(true){ + while(!$this->shutdown){ if(($line = $this->readLine()) !== ""){ $this->buffer[] = preg_replace("#\\x1b\\x5b([^\\x1b]*\\x7e|[\\x40-\\x50])#", "", $line); - }elseif((microtime(true) - $lastLine) <= 0.1){ //Non blocking! Sleep to save CPU - usleep(40000); + }elseif(!$this->shutdown and (microtime(true) - $lastLine) <= 0.1){ //Non blocking! Sleep to save CPU + $this->synchronized(function(){ + $this->wait(10000); + }); } $lastLine = microtime(true); diff --git a/src/pocketmine/command/FormattedCommandAlias.php b/src/pocketmine/command/FormattedCommandAlias.php index fb5829deb..42bbd5608 100644 --- a/src/pocketmine/command/FormattedCommandAlias.php +++ b/src/pocketmine/command/FormattedCommandAlias.php @@ -46,15 +46,12 @@ class FormattedCommandAlias extends Command{ foreach($this->formatStrings as $formatString){ try{ $commands[] = $this->buildCommand($formatString, $args); - }catch(\Exception $e){ + }catch(\Throwable $e){ if($e instanceof \InvalidArgumentException){ $sender->sendMessage(TextFormat::RED . $e->getMessage()); }else{ $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception")); - $logger = $sender->getServer()->getLogger(); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + $sender->getServer()->getLogger()->logException($e); } return false; diff --git a/src/pocketmine/command/SimpleCommandMap.php b/src/pocketmine/command/SimpleCommandMap.php index 243354131..44a2e0030 100644 --- a/src/pocketmine/command/SimpleCommandMap.php +++ b/src/pocketmine/command/SimpleCommandMap.php @@ -193,13 +193,10 @@ class SimpleCommandMap implements CommandMap{ $target->timings->startTiming(); try{ $target->execute($sender, $sentCommandLabel, $args); - }catch(\Exception $e){ + }catch(\Throwable $e){ $sender->sendMessage(new TranslationContainer(TextFormat::RED . "%commands.generic.exception")); $this->server->getLogger()->critical($this->server->getLanguage()->translateString("pocketmine.command.exception", [$commandLine, (string) $target, $e->getMessage()])); - $logger = $sender->getServer()->getLogger(); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + $sender->getServer()->getLogger()->logException($e); } $target->timings->stopTiming(); diff --git a/src/pocketmine/command/defaults/GiveCommand.php b/src/pocketmine/command/defaults/GiveCommand.php index b8cd20e39..b01d7edc5 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; @@ -66,11 +66,11 @@ class GiveCommand extends VanillaCommand{ $data = implode(" ", array_slice($args, 3)); try{ $tags = NBT::parseJSON($data); - }catch (\Exception $ex){ + }catch (\Throwable $ex){ $exception = $ex; } - if(!($tags instanceof Compound) or $exception !== null){ + if(!($tags instanceof CompoundTag) or $exception !== null){ $sender->sendMessage(new TranslationContainer("commands.give.tagError", [$exception !== null ? $exception->getMessage() : "Invalid tag conversion"])); return true; } diff --git a/src/pocketmine/command/defaults/TeleportCommand.php b/src/pocketmine/command/defaults/TeleportCommand.php index c599f9590..b7e21e7ef 100644 --- a/src/pocketmine/command/defaults/TeleportCommand.php +++ b/src/pocketmine/command/defaults/TeleportCommand.php @@ -44,6 +44,7 @@ class TeleportCommand extends VanillaCommand{ return true; } + $args = array_filter($args); if(count($args) < 1 or count($args) > 6){ $sender->sendMessage(new TranslationContainer("commands.generic.usage", [$this->usageMessage])); 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 8eb99bc6f..eabb01077 100644 --- a/src/pocketmine/entity/Entity.php +++ b/src/pocketmine/entity/Entity.php @@ -45,14 +45,15 @@ 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; use pocketmine\network\protocol\SetEntityDataPacket; @@ -203,10 +204,9 @@ abstract class Entity extends Location implements Metadatable{ protected $isPlayer = false; - public function __construct(FullChunk $chunk, Compound $nbt){ - if($chunk === null or $chunk->getProvider() === null){ - throw new ChunkException("Invalid garbage Chunk given to Entity"); - } + public function __construct(FullChunk $chunk, CompoundTag $nbt){ + + assert($chunk !== null and $chunk->getProvider() !== null); $this->timings = Timings::getEntityTimings($this); @@ -238,28 +238,30 @@ abstract class Entity extends Location implements Metadatable{ ); $this->setMotion($this->temporalVector->setComponents($this->namedtag["Motion"][0], $this->namedtag["Motion"][1], $this->namedtag["Motion"][2])); + assert(!is_nan($this->x) and !is_infinite($this->x) and !is_nan($this->y) and !is_infinite($this->y) and !is_nan($this->z) and !is_infinite($this->z)); + 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; @@ -405,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); @@ -447,58 +449,60 @@ 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); } } protected function initEntity(){ + assert($this->namedtag instanceof CompoundTag); + if(isset($this->namedtag->ActiveEffects)){ foreach($this->namedtag->ActiveEffects->getValue() as $e){ $effect = Effect::getEffect($e["Id"]); @@ -553,13 +557,6 @@ abstract class Entity extends Location implements Metadatable{ } } - /** - * @deprecated - */ - public function sendMetadata($player){ - $this->sendData($player); - } - /** * @param Player[]|Player $player * @param array $data Properly formatted entity data, defaults to everything 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 08ccaba28..170e8f0d6 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["Name"]); } $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()), - "Name" => new String("Name", $this->getSkinName()) + $this->namedtag->Skin = new CompoundTag("Skin", [ + "Data" => new StringTag("Data", $this->getSkinData()), + "Name" => new StringTag("Name", $this->getSkinName()) ]); } } diff --git a/src/pocketmine/entity/Item.php b/src/pocketmine/entity/Item.php index 686a6ed4a..76269d569 100644 --- a/src/pocketmine/entity/Item.php +++ b/src/pocketmine/entity/Item.php @@ -30,8 +30,9 @@ use pocketmine\item\Item as ItemItem; use pocketmine\nbt\NBT; -use pocketmine\nbt\tag\Short; -use pocketmine\nbt\tag\String; +use pocketmine\nbt\tag\CompoundTag; +use pocketmine\nbt\tag\ShortTag; +use pocketmine\nbt\tag\StringTag; use pocketmine\network\Network; use pocketmine\network\protocol\AddItemEntityPacket; use pocketmine\Player; @@ -70,6 +71,9 @@ class Item extends Entity{ if(isset($this->namedtag->Thrower)){ $this->thrower = $this->namedtag["Thrower"]; } + + assert($this->namedtag->Item instanceof CompoundTag); + if(!isset($this->namedtag->Item)){ $this->close(); return; @@ -160,14 +164,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/event/entity/EntityMoveEvent.php b/src/pocketmine/event/entity/EntityMoveEvent.php deleted file mode 100644 index 099c9a7a4..000000000 --- a/src/pocketmine/event/entity/EntityMoveEvent.php +++ /dev/null @@ -1,48 +0,0 @@ -entity = $entity; - $this->pos = $pos; - } - - public function getVector(){ - return $this->pos; - } - - -} \ No newline at end of file diff --git a/src/pocketmine/event/player/PlayerChatEvent.php b/src/pocketmine/event/player/PlayerChatEvent.php index c04cd5e66..4121a025d 100644 --- a/src/pocketmine/event/player/PlayerChatEvent.php +++ b/src/pocketmine/event/player/PlayerChatEvent.php @@ -46,13 +46,6 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ $this->player = $player; $this->message = $message; - //TODO: @deprecated (backwards-compativility) - $i = 0; - while(($pos = strpos($format, "%s")) !== false){ - $format = substr($format, 0, $pos) . "{%$i}" . substr($format, $pos + 2); - ++$i; - } - $this->format = $format; if($recipients === null){ @@ -84,13 +77,6 @@ class PlayerChatEvent extends PlayerEvent implements Cancellable{ } public function setFormat($format){ - //TODO: @deprecated (backwards-compativility) - $i = 0; - while(($pos = strpos($format, "%s")) !== false){ - $format = substr($format, 0, $pos) . "{%$i}" . substr($format, $pos + 2); - ++$i; - } - $this->format = $format; } diff --git a/src/pocketmine/event/server/QueryRegenerateEvent.php b/src/pocketmine/event/server/QueryRegenerateEvent.php index 1f3028b35..9f8ac3b2c 100644 --- a/src/pocketmine/event/server/QueryRegenerateEvent.php +++ b/src/pocketmine/event/server/QueryRegenerateEvent.php @@ -53,7 +53,7 @@ class QueryRegenerateEvent extends ServerEvent{ public function __construct(Server $server, $timeout = 5){ $this->timeout = $timeout; - $this->serverName = $server->getServerName(); + $this->serverName = $server->getMotd(); $this->listPlugins = $server->getProperty("settings.query-plugins", true); $this->plugins = $server->getPluginManager()->getPlugins(); $this->players = []; diff --git a/src/pocketmine/inventory/CraftingManager.php b/src/pocketmine/inventory/CraftingManager.php index aac0d350d..6ff6f1e0b 100644 --- a/src/pocketmine/inventory/CraftingManager.php +++ b/src/pocketmine/inventory/CraftingManager.php @@ -22,17 +22,10 @@ namespace pocketmine\inventory; -use pocketmine\block\Planks; -use pocketmine\block\Quartz; -use pocketmine\block\Sandstone; -use pocketmine\block\Slab; -use pocketmine\block\Fence; -use pocketmine\block\Stone; -use pocketmine\block\StoneBricks; -use pocketmine\block\StoneWall; -use pocketmine\block\Wood; -use pocketmine\block\Wood2; use pocketmine\item\Item; +use pocketmine\Server; +use pocketmine\utils\Config; +use pocketmine\utils\MainLogger; use pocketmine\utils\UUID; class CraftingManager{ @@ -49,663 +42,55 @@ class CraftingManager{ private static $RECIPE_COUNT = 0; public function __construct(){ - - $this->registerStonecutter(); - $this->registerFurnace(); - - - $this->registerDyes(); - $this->registerIngots(); - $this->registerTools(); - $this->registerWeapons(); - $this->registerArmor(); - $this->registerFood(); - - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::CLAY_BLOCK, 0, 1)))->addIngredient(Item::get(Item::CLAY, 0, 4))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WORKBENCH, 0, 1), - "XX", - "XX" - ))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null))); - - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::GLOWSTONE_BLOCK, 0, 1)))->addIngredient(Item::get(Item::GLOWSTONE_DUST, 0, 4))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::LIT_PUMPKIN, 0, 1)))->addIngredient(Item::get(Item::PUMPKIN, 0, 1))->addIngredient(Item::get(Item::TORCH, 0, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::SNOW_BLOCK, 0, 1), - "XX", - "XX" - ))->setIngredient("X", Item::get(Item::SNOWBALL))); - - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::SNOW_LAYER, 0, 6)))->addIngredient(Item::get(Item::SNOW_BLOCK, 0, 3))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::STICK, 0, 4), - "X ", - "X " - ))->setIngredient("X", Item::get(Item::WOODEN_PLANK, null))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::STONECUTTER, 0, 1), - "XX", - "XX" - ))->setIngredient("X", Item::get(Item::COBBLESTONE))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::OAK, 4), - "X" - ))->setIngredient("X", Item::get(Item::WOOD, Wood::OAK, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4), - "X" - ))->setIngredient("X", Item::get(Item::WOOD, Wood::SPRUCE, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4), - "X" - ))->setIngredient("X", Item::get(Item::WOOD, Wood::BIRCH, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4), - "X" - ))->setIngredient("X", Item::get(Item::WOOD, Wood::JUNGLE, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4), - "X" - ))->setIngredient("X", Item::get(Item::WOOD2, Wood2::ACACIA, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4), - "X" - ))->setIngredient("X", Item::get(Item::WOOD2, Wood2::DARK_OAK, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::WOOL, 0, 1), - "XX", - "XX" - ))->setIngredient("X", Item::get(Item::STRING, 0, 4))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::TORCH, 0, 4), - "C ", - "S" - ))->setIngredient("C", Item::get(Item::COAL,0,1))->setIngredient("S", Item::get(Item::STICK,0,1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::TORCH, 0, 4), - "C ", - "S" - ))->setIngredient("C", Item::get(Item::COAL, 1, 1))->setIngredient("S", Item::get(Item::STICK, 0, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::SUGAR, 0, 1), - "S" - ))->setIngredient("S", Item::get(Item::SUGARCANE, 0, 1))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BED, 0, 1), - "WWW", - "PPP" - ))->setIngredient("W", Item::get(Item::WOOL, null, 3))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::CHEST, 0, 1), - "PPP", - "P P", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 8))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, 0, 3), - "PSP", - "PSP" - ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 4))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::SPRUCE, 3), - "PSP", - "PSP" - ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 4))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::BIRCH, 3), - "PSP", - "PSP" - ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 4))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::JUNGLE, 3), - "PSP", - "PSP" - ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 4))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::ACACIA, 3), - "PSP", - "PSP" - ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 4))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE, Planks::DARK_OAK, 3), - "PSP", - "PSP" - ))->setIngredient("S", Item::get(Item::STICK, 0, 2))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 4))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE, 0, 1), - "SPS", - "SPS" - ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 2))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_SPRUCE, 0, 1), - "SPS", - "SPS" - ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 2))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_BIRCH, 0, 1), - "SPS", - "SPS" - ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 2))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_JUNGLE, 0, 1), - "SPS", - "SPS" - ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 2))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_DARK_OAK, 0, 1), - "SPS", - "SPS" - ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 2))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FENCE_GATE_ACACIA, 0, 1), - "SPS", - "SPS" - ))->setIngredient("S", Item::get(Item::STICK, 0, 4))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 2))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::FURNACE, 0, 1), - "CCC", - "C C", - "CCC" - ))->setIngredient("C", Item::get(Item::COBBLESTONE, 0, 8))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::GLASS_PANE, 0, 16), - "GGG", - "GGG" - ))->setIngredient("G", Item::get(Item::GLASS, 0, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::LADDER, 0, 2), - "S S", - "SSS", - "S S" - ))->setIngredient("S", Item::get(Item::STICK, 0, 7))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::TRAPDOOR, 0, 2), - "PPP", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_DOOR, 0, 1), - "PP", - "PP", - "PP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOODEN_STAIRS, 0, 4), - " P", - " PP", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::OAK, 6), - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::OAK, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SPRUCE_WOOD_STAIRS, 0, 4), - " P", - " PP", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::SPRUCE, 6), - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::SPRUCE, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BIRCH_WOOD_STAIRS, 0, 4), - " P", - " PP", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::BIRCH, 6), - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::BIRCH, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::JUNGLE_WOOD_STAIRS, 0, 4), - "P", - "PP", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::JUNGLE, 6), - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::JUNGLE, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::ACACIA_WOOD_STAIRS, 0, 4), - " P", - " PP", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::ACACIA, 6), - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::ACACIA, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::DARK_OAK_WOOD_STAIRS, 0, 4), - " P", - " PP", - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 6))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::WOOD_SLAB, Planks::DARK_OAK, 6), - "PPP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, Planks::DARK_OAK, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BUCKET, 0, 1), - "I I", - " I" - ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::CLOCK, 0, 1), - " G", - "GR", - " G" - ))->setIngredient("G", Item::get(Item::GOLD_INGOT, 0, 4))->setIngredient("R", Item::get(Item::REDSTONE_DUST, 0, 1))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::COMPASS, 0, 1), - " I ", - "IRI", - " I" - ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 4))->setIngredient("R", Item::get(Item::REDSTONE_DUST, 0, 1))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::TNT, 0, 1), - "GSG", - "SGS", - "GSG" - ))->setIngredient("G", Item::get(Item::GUNPOWDER, 0, 5))->setIngredient("S", Item::get(Item::SAND, null, 4))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOWL, 0, 4), - "P P", - " P" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANKS, null, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::MINECART, 0, 1), - "I I", - "III" - ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 5))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOOK, 0, 1), - "P P", - " P " - ))->setIngredient("P", Item::get(Item::PAPER, 0, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOOKSHELF, 0, 1), - "PBP", - "PBP", - "PBP" - ))->setIngredient("P", Item::get(Item::WOODEN_PLANK, null, 6))->setIngredient("B", Item::get(Item::BOOK, 0, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::PAINTING, 0, 1), - "SSS", - "SWS", - "SSS" - ))->setIngredient("S", Item::get(Item::STICK, 0, 8))->setIngredient("W", Item::get(Item::WOOL, null, 1))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::PAPER, 0, 3), - "SS", - "S" - ))->setIngredient("S", Item::get(Item::SUGARCANE, 0, 3))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::SIGN, 0, 3), - "PPP", - "PPP", - " S" - ))->setIngredient("S", Item::get(Item::STICK, 0, 1))->setIngredient("P", Item::get(Item::WOODEN_PLANKS, null, 6))); //TODO: check if it gives one sign or three - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::IRON_BARS, 0, 16), - "III", - "III", - "III" - ))->setIngredient("I", Item::get(Item::IRON_INGOT, 0, 9))); - } - - protected function registerFurnace(){ - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::STONE, 0, 1), Item::get(Item::COBBLESTONE, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::STONE_BRICK, 2, 1), Item::get(Item::STONE_BRICK, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::GLASS, 0, 1), Item::get(Item::SAND, null, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::COAL, 1, 1), Item::get(Item::TRUNK, null, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::GOLD_INGOT, 0, 1), Item::get(Item::GOLD_ORE, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::IRON_INGOT, 0, 1), Item::get(Item::IRON_ORE, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::EMERALD, 0, 1), Item::get(Item::EMERALD_ORE, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::DIAMOND, 0, 1), Item::get(Item::DIAMOND_ORE, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::NETHER_BRICK, 0, 1), Item::get(Item::NETHERRACK, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_PORKCHOP, 0, 1), Item::get(Item::RAW_PORKCHOP, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::BRICK, 0, 1), Item::get(Item::CLAY, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_FISH, 0, 1), Item::get(Item::RAW_FISH, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_FISH, 1, 1), Item::get(Item::RAW_FISH, 1, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::DYE, 2, 1), Item::get(Item::CACTUS, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::DYE, 1, 1), Item::get(Item::RED_MUSHROOM, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::STEAK, 0, 1), Item::get(Item::RAW_BEEF, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::COOKED_CHICKEN, 0, 1), Item::get(Item::RAW_CHICKEN, 0, 1))); - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::BAKED_POTATO, 0, 1), Item::get(Item::POTATO, 0, 1))); - - $this->registerRecipe(new FurnaceRecipe(Item::get(Item::HARDENED_CLAY, 0, 1), Item::get(Item::CLAY_BLOCK, 0, 1))); - } - - protected function registerStonecutter(){ - $shapes = [ - "slab" => [ - " ", - "XXX", - " " - ], - "stairs" => [ - "X ", - "XX ", - "XXX" - ], - "wall/fence" => [ - "XXX", - "XXX", - " " - ], - "blockrecipe1" => [ - "XX", - "XX" - ], - "blockrecipe2X1" => [ - " ", - " X ", - " X " - ], - "blockrecipe2X2" => [ - "AB", - "BA" - ], - "blockrecipe1X2" => [ - " ", - "AB" - ] - ]; - - $buildRecipes = []; - - // Single ingedient stone cutter recipes: - $RESULT_ITEMID = 0; $RESULT_META = 1; $INGREDIENT_ITEMID = 2; $INGREDIENT_META = 3; $RECIPE_SHAPE = 4;$RESULT_AMOUNT = 5; - $recipes = [ - //RESULT_ITEM_ID RESULT_META INGREDIENT_ITEMID INGREDIENT_META RECIPE_SHAPE RESULT_AMOUNT - [Item::SLAB, Slab::STONE, Item::STONE, Stone::NORMAL, "slab", 6], - [Item::SLAB, Slab::COBBLESTONE, Item::COBBLESTONE, 0, "slab", 6], - [Item::SLAB, Slab::SANDSTONE, Item::SANDSTONE, 0, "slab", 6], - [Item::SLAB, Slab::BRICK, Item::BRICK, 0, "slab", 6], - [Item::SLAB, Slab::STONE_BRICK, Item::STONE_BRICK, StoneBricks::NORMAL,"slab", 6], - [Item::SLAB, Slab::NETHER_BRICK, Item::NETHER_BRICK_BLOCK, 0, "slab", 6], - [Item::SLAB, Slab::QUARTZ, Item::QUARTZ_BLOCK, 0, "slab", 6], - [Item::COBBLESTONE_STAIRS, 0, Item::COBBLESTONE, 0, "stairs", 4], - [Item::SANDSTONE_STAIRS, 0, Item::SANDSTONE, 0, "stairs", 4], - [Item::STONE_BRICK_STAIRS, 0, Item::STONE_BRICK, StoneBricks::NORMAL,"stairs", 4], - [Item::BRICK_STAIRS, 0, Item::BRICKS_BLOCK, 0, "stairs", 4], - [Item::NETHER_BRICKS_STAIRS,0, Item::NETHER_BRICK_BLOCK, 0, "stairs", 4], - [Item::COBBLESTONE_WALL, StoneWall::NONE_MOSSY_WALL, Item::COBBLESTONE, 0, "wall/fence", 6], - [Item::COBBLESTONE_WALL, StoneWall::MOSSY_WALL, Item::MOSSY_STONE, 0, "wall/fence", 6], - [Item::NETHER_BRICK_FENCE, 0, Item::NETHER_BRICK_BLOCK, 0, "wall/fence", 6], - [Item::NETHER_BRICKS, 0, Item::NETHER_BRICK, 0, "blockrecipe1", 1], - [Item::SANDSTONE, SandStone::NORMAL, Item::SAND, 0, "blockrecipe1", 1], - [Item::SANDSTONE, Sandstone::CHISELED, Item::SANDSTONE, SandStone::NORMAL, "blockrecipe1", 4], - [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::NORMAL, "blockrecipe1", 4], - [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::POLISHED_GRANITE,"blockrecipe1", 4], - [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::POLISHED_DIORITE,"blockrecipe1", 4], - [Item::STONE_BRICK, StoneBricks::NORMAL, Item::STONE, Stone::POLISHED_ANDESITE,"blockrecipe1",4], - [Item::STONE, Stone::POLISHED_GRANITE, Item::STONE, Stone::GRANITE, "blockrecipe1", 4], - [Item::STONE, Stone::POLISHED_DIORITE, Item::STONE, Stone::DIORITE, "blockrecipe1", 4], - [Item::STONE, Stone::POLISHED_ANDESITE, Item::STONE, Stone::ANDESITE, "blockrecipe1", 4], - [Item::QUARTZ_BLOCK, Quartz::QUARTZ_NORMAL, Item::QUARTZ, Stone::ANDESITE, "blockrecipe1", 4], - [Item::QUARTZ_BLOCK, Quartz::QUARTZ_CHISELED, Item::SLAB, Slab::QUARTZ, "blockrecipe2X1", 1], - [Item::SANDSTONE, SandStone::CHISELED, Item::SLAB, Slab::SANDSTONE, "blockrecipe2X1", 1], - [Item::STONE_BRICK, StoneBricks::CHISELED, Item::SLAB, Slab::STONE_BRICK, "blockrecipe2X1", 1], - ]; - foreach ($recipes as $recipe){ - $buildRecipes[] = $this->createOneIngedientRecipe($shapes[$recipe[$RECIPE_SHAPE]], $recipe[$RESULT_ITEMID], $recipe[$RESULT_META], $recipe[$RESULT_AMOUNT], $recipe[$INGREDIENT_ITEMID], $recipe[$INGREDIENT_META], "X", "Stonecutter"); - } - - // Multi-ingredient stone recipes: - $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE, Stone::GRANITE, 1), - ...$shapes["blockrecipe1X2"] - ))->setIngredient("A", Item::get(Item::STONE, Stone::DIORITE, 1))->setIngredient("B", Item::get(Item::QUARTZ, Quartz::QUARTZ_NORMAL, 1))); - $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE, Stone::DIORITE, 2), - ...$shapes["blockrecipe2X2"] - ))->setIngredient("A", Item::get(Item::COBBLESTONE, 0, 2))->setIngredient("B", Item::get(Item::QUARTZ, 0, 2))); - $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE, Stone::ANDESITE, 2), - ...$shapes["blockrecipe1X2"] - ))->setIngredient("A", Item::get(Item::COBBLESTONE, 0, 1))->setIngredient("B", Item::get(Item::STONE, Stone::DIORITE, 1))); - $buildRecipes[] = ((new StonecutterShapedRecipe(Item::get(Item::STONE_BRICK, StoneBricks::MOSSY, 1), - ...$shapes["blockrecipe1X2"] - ))->setIngredient("A", Item::get(Item::STONE_BRICK, StoneBricks::NORMAL, 1))->setIngredient("B", Item::get(Item::VINES, 0, 1))); - - $this->sortAndAddRecipesArray($buildRecipes); - } - - private function sortAndAddRecipesArray(&$recipes){ - // Sort the recipes based on the result item name with the bubblesort algoritm. - for ($i = 0; $i < count($recipes); ++$i){ - $current = $recipes[$i]; - $result = $current->getResult(); - for ($j = count($recipes)-1; $j > $i; --$j) - { - if ($this->sort($result, $recipes[$j]->getResult())>0){ - $swap = $current; - $current = $recipes[$j]; - $recipes[$j] = $swap; - $result = $current->getResult(); + // load recipes from src/pocketmine/recipes.json + $recipes = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/recipes.json", Config::JSON, []); + + MainLogger::getLogger()->info("Loading recipes..."); + foreach($recipes->getAll() as $recipe){ + switch($recipe["Type"]){ + case 0: + // TODO: handle multiple result items + if(count($recipe["Result"]) == 1){ + $first = $recipe["Result"][0]; + $result = new ShapelessRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"])); + + foreach($recipe["Ingredients"] as $ingredient){ + $result->addIngredient(Item::get($ingredient["ID"], $ingredient["Damage"], $ingredient["Count"])); + } + $this->registerRecipe($result); } - } - $this->registerRecipe($current); - } - } + break; + case 1: + // TODO: handle multiple result items + if(count($recipe["Result"]) == 1){ + $first = $recipe["Result"][0]; + $result = new ShapedRecipe(Item::get($first["ID"], $first["Damage"], $first["Count"]), $recipe["Height"], $recipe["Width"]); - private function createOneIngedientRecipe($recipeshape, $resultitem, $resultitemmeta, $resultitemamound, $ingedienttype, $ingredientmeta, $ingredientname, $inventoryType = ""){ - $ingredientamount = 0; - $height = 0; - // count how many of the ingredient are in the recipe and check height for big or small recipe. - foreach ($recipeshape as $line){ - $height += 1; - $width = strlen($line); - $ingredientamount += substr_count($line, $ingredientname); - } - $recipe = null; - if ($height < 3){ - // Process small recipe - $fullClassName = "pocketmine\\inventory\\".$inventoryType."ShapedRecipe";// $ShapeClass."ShapedRecipe"; - $recipe = ((new $fullClassName(Item::get($resultitem, $resultitemmeta, $resultitemamound), - ...$recipeshape - ))->setIngredient($ingredientname, Item::get($ingedienttype, $ingredientmeta, $ingredientamount))); - } - else{ - // Process big recipe - $fullClassName = "pocketmine\\inventory\\".$inventoryType."BigShapedRecipe"; - $recipe = ((new $fullClassName(Item::get($resultitem, $resultitemmeta, $resultitemamound), - ...$recipeshape - ))->setIngredient($ingredientname, Item::get($ingedienttype, $ingredientmeta, $ingredientamount))); - } - return $recipe; - } - - protected function registerFood(){ - //TODO: check COOKIES - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::MELON_SEEDS, 0, 1)))->addIngredient(Item::get(Item::MELON_SLICE, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::PUMPKIN_SEEDS, 0, 4)))->addIngredient(Item::get(Item::PUMPKIN, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::PUMPKIN_PIE, 0, 1)))->addIngredient(Item::get(Item::PUMPKIN, 0, 1))->addIngredient(Item::get(Item::EGG, 0, 1))->addIngredient(Item::get(Item::SUGAR, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::MUSHROOM_STEW, 0, 1)))->addIngredient(Item::get(Item::BOWL, 0, 1))->addIngredient(Item::get(Item::BROWN_MUSHROOM, 0, 1))->addIngredient(Item::get(Item::RED_MUSHROOM, 0, 1))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::MELON_BLOCK, 0, 1)))->addIngredient(Item::get(Item::MELON_SLICE, 0, 9))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::BEETROOT_SOUP, 0, 1)))->addIngredient(Item::get(Item::BEETROOT, 0, 4))->addIngredient(Item::get(Item::BOWL, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::BREAD, 0, 1)))->addIngredient(Item::get(Item::WHEAT, 0, 3))); - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::CAKE, 0, 1)))->addIngredient(Item::get(Item::WHEAT, 0, 3))->addIngredient(Item::get(Item::BUCKET, 1, 3))->addIngredient(Item::get(Item::EGG, 0, 1))->addIngredient(Item::get(Item::SUGAR, 0, 2))); - } - - protected function registerArmor(){ - $types = [ - [Item::LEATHER, Item::FIRE, Item::IRON_INGOT, Item::DIAMOND, Item::GOLD_INGOT], - [Item::LEATHER_CAP, Item::CHAIN_HELMET, Item::IRON_HELMET, Item::DIAMOND_HELMET, Item::GOLD_HELMET], - [Item::LEATHER_TUNIC, Item::CHAIN_CHESTPLATE, Item::IRON_CHESTPLATE, Item::DIAMOND_CHESTPLATE, Item::GOLD_CHESTPLATE], - [Item::LEATHER_PANTS, Item::CHAIN_LEGGINGS, Item::IRON_LEGGINGS, Item::DIAMOND_LEGGINGS, Item::GOLD_LEGGINGS], - [Item::LEATHER_BOOTS, Item::CHAIN_BOOTS, Item::IRON_BOOTS, Item::DIAMOND_BOOTS, Item::GOLD_BOOTS], - ]; - - $shapes = [ - [ - "XXX", - "X X", - " " - ], - [ - "X X", - "XXX", - "XXX" - ], - [ - "XXX", - "X X", - "X X" - ], - [ - " ", - "X X", - "X X" - ] - ]; - - for($i = 1; $i < 5; ++$i){ - foreach($types[$i] as $j => $type){ - $this->registerRecipe((new BigShapedRecipe(Item::get($type, 0, 1), ...$shapes[$i - 1]))->setIngredient("X", Item::get($types[0][$j], 0, 1))); + $shape = array_chunk($recipe["Ingredients"], $recipe["Width"]); + foreach($shape as $y => $row){ + foreach($row as $x => $ingredient){ + $result->addIngredient($x, $y, Item::get($ingredient["ID"], ($ingredient["Damage"] < 0 ? null : $ingredient["Damage"]), $ingredient["Count"])); + } + } + $this->registerRecipe($result); + } + break; + case 2: + $result = $recipe["Result"]; + $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]); + $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"], 0, 1))); + break; + case 3: + $result = $recipe["Result"]; + $resultItem = Item::get($result["ID"], $result["Damage"], $result["Count"]); + $this->registerRecipe(new FurnaceRecipe($resultItem, Item::get($recipe["Ingredients"]["ID"], $recipe["Ingredients"]["Damage"], 1))); + break; + default: + break; } } } - protected function registerWeapons(){ - $types = [ - [Item::WOODEN_PLANK, Item::COBBLESTONE, Item::IRON_INGOT, Item::DIAMOND, Item::GOLD_INGOT], - [Item::WOODEN_SWORD, Item::STONE_SWORD, Item::IRON_SWORD, Item::DIAMOND_SWORD, Item::GOLD_SWORD], - ]; - - - for($i = 1; $i < 2; ++$i){ - foreach($types[$i] as $j => $type){ - $this->registerRecipe((new BigShapedRecipe(Item::get($type, 0, 1), - " X ", - " X ", - " I " - ))->setIngredient("X", Item::get($types[0][$j], null))->setIngredient("I", Item::get(Item::STICK))); - } - } - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::ARROW, 0, 1), - " F ", - " S ", - " P " - ))->setIngredient("S", Item::get(Item::STICK))->setIngredient("F", Item::get(Item::FLINT))->setIngredient("P", Item::get(Item::FEATHER))); - - $this->registerRecipe((new BigShapedRecipe(Item::get(Item::BOW, 0, 1), - " X~", - "X ~", - " X~" - ))->setIngredient("~", Item::get(Item::STRING))->setIngredient("X", Item::get(Item::STICK))); - } - - protected function registerTools(){ - $types = [ - [Item::WOODEN_PLANK, Item::COBBLESTONE, Item::IRON_INGOT, Item::DIAMOND, Item::GOLD_INGOT], - [Item::WOODEN_PICKAXE, Item::STONE_PICKAXE, Item::IRON_PICKAXE, Item::DIAMOND_PICKAXE, Item::GOLD_PICKAXE], - [Item::WOODEN_SHOVEL, Item::STONE_SHOVEL, Item::IRON_SHOVEL, Item::DIAMOND_SHOVEL, Item::GOLD_SHOVEL], - [Item::WOODEN_AXE, Item::STONE_AXE, Item::IRON_AXE, Item::DIAMOND_AXE, Item::GOLD_AXE], - [Item::WOODEN_HOE, Item::STONE_HOE, Item::IRON_HOE, Item::DIAMOND_HOE, Item::GOLD_HOE], - ]; - $shapes = [ - [ - "XXX", - " I ", - " I " - ], - [ - " X ", - " I ", - " I " - ], - [ - "XX ", - "XI ", - " I " - ], - [ - "XX ", - " I ", - " I " - ] - ]; - - for($i = 1; $i < 5; ++$i){ - foreach($types[$i] as $j => $type){ - $this->registerRecipe((new BigShapedRecipe(Item::get($type, 0, 1), ...$shapes[$i - 1]))->setIngredient("X", Item::get($types[0][$j], null))->setIngredient("I", Item::get(Item::STICK))); - } - } - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::FLINT_AND_STEEL, 0, 1), - " S", - "F " - ))->setIngredient("F", Item::get(Item::FLINT))->setIngredient("S", Item::get(Item::IRON_INGOT))); - - $this->registerRecipe((new ShapedRecipe(Item::get(Item::SHEARS, 0, 1), - " X", - "X " - ))->setIngredient("X", Item::get(Item::IRON_INGOT))); - } - - protected function registerDyes(){ - for($i = 0; $i < 16; ++$i){ - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOOL, 15 - $i, 1)))->addIngredient(Item::get(Item::DYE, $i, 1))->addIngredient(Item::get(Item::WOOL, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::STAINED_CLAY, 15 - $i, 8)))->addIngredient(Item::get(Item::DYE, $i, 1))->addIngredient(Item::get(Item::HARDENED_CLAY, 0, 8))); - //TODO: add glass things? - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOOL, 15 - $i, 1)))->addIngredient(Item::get(Item::DYE, $i, 1))->addIngredient(Item::get(Item::WOOL, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOOL, 15 - $i, 1)))->addIngredient(Item::get(Item::DYE, $i, 1))->addIngredient(Item::get(Item::WOOL, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::WOOL, 15 - $i, 1)))->addIngredient(Item::get(Item::DYE, $i, 1))->addIngredient(Item::get(Item::WOOL, 0, 1))); - - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::CARPET, $i, 3)))->addIngredient(Item::get(Item::WOOL, $i, 2))); - } - - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 11, 2)))->addIngredient(Item::get(Item::DANDELION, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 15, 3)))->addIngredient(Item::get(Item::BONE, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 3, 2)))->addIngredient(Item::get(Item::DYE, 14, 1))->addIngredient(Item::get(Item::DYE, 0, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 3, 3)))->addIngredient(Item::get(Item::DYE, 1, 1))->addIngredient(Item::get(Item::DYE, 0, 1))->addIngredient(Item::get(Item::DYE, 11, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 9, 2)))->addIngredient(Item::get(Item::DYE, 15, 1))->addIngredient(Item::get(Item::DYE, 1, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 14, 2)))->addIngredient(Item::get(Item::DYE, 11, 1))->addIngredient(Item::get(Item::DYE, 1, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 10, 2)))->addIngredient(Item::get(Item::DYE, 2, 1))->addIngredient(Item::get(Item::DYE, 15, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 12, 2)))->addIngredient(Item::get(Item::DYE, 4, 1))->addIngredient(Item::get(Item::DYE, 15, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 6, 2)))->addIngredient(Item::get(Item::DYE, 4, 1))->addIngredient(Item::get(Item::DYE, 2, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 5, 2)))->addIngredient(Item::get(Item::DYE, 4, 1))->addIngredient(Item::get(Item::DYE, 1, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 13, 3)))->addIngredient(Item::get(Item::DYE, 4, 1))->addIngredient(Item::get(Item::DYE, 1, 1))->addIngredient(Item::get(Item::DYE, 15, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 1, 1)))->addIngredient(Item::get(Item::BEETROOT, 0, 1))); - - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 13, 4)))->addIngredient(Item::get(Item::DYE, 15, 1))->addIngredient(Item::get(Item::DYE, 1, 2))->addIngredient(Item::get(Item::DYE, 4, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 13, 2)))->addIngredient(Item::get(Item::DYE, 5, 1))->addIngredient(Item::get(Item::DYE, 9, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 8, 2)))->addIngredient(Item::get(Item::DYE, 0, 1))->addIngredient(Item::get(Item::DYE, 15, 1))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 7, 3)))->addIngredient(Item::get(Item::DYE, 0, 1))->addIngredient(Item::get(Item::DYE, 15, 2))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 7, 2)))->addIngredient(Item::get(Item::DYE, 0, 1))->addIngredient(Item::get(Item::DYE, 8, 1))); - - } - - protected function registerIngots(){ - $ingots = [ - Item::GOLD_BLOCK => Item::GOLD_INGOT, - Item::IRON_BLOCK => Item::IRON_INGOT, - Item::DIAMOND_BLOCK => Item::DIAMOND, - Item::EMERALD_BLOCK => Item::EMERALD, - Item::REDSTONE_BLOCK => Item::REDSTONE_DUST, - Item::COAL_BLOCK => Item::COAL, - Item::HAY_BALE => Item::WHEAT, - ]; - - foreach($ingots as $block => $ingot){ - $this->registerRecipe((new BigShapelessRecipe(Item::get($block, 0, 1)))->addIngredient(Item::get($ingot, 0, 9))); - $this->registerRecipe((new ShapelessRecipe(Item::get($ingot, 0, 9)))->addIngredient(Item::get($block, 0, 1))); - } - - - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::LAPIS_BLOCK, 0, 1)))->addIngredient(Item::get(Item::DYE, 4, 9))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::DYE, 4, 9)))->addIngredient(Item::get(Item::LAPIS_BLOCK, 0, 1))); - - $this->registerRecipe((new BigShapelessRecipe(Item::get(Item::GOLD_INGOT, 0, 1)))->addIngredient(Item::get(Item::GOLD_NUGGET, 0, 9))); - $this->registerRecipe((new ShapelessRecipe(Item::get(Item::GOLD_NUGGET, 0, 9)))->addIngredient(Item::get(Item::GOLD_INGOT, 0, 1))); - - } - public function sort(Item $i1, Item $i2){ if($i1->getId() > $i2->getId()){ return 1; 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/inventory/ShapedRecipe.php b/src/pocketmine/inventory/ShapedRecipe.php index 95773d03a..823e6c453 100644 --- a/src/pocketmine/inventory/ShapedRecipe.php +++ b/src/pocketmine/inventory/ShapedRecipe.php @@ -22,9 +22,9 @@ namespace pocketmine\inventory; use pocketmine\item\Item; +use pocketmine\math\Vector2; use pocketmine\Server; use pocketmine\utils\UUID; -use pocketmine\math\Vector2; class ShapedRecipe implements Recipe{ /** @var Item */ @@ -41,33 +41,18 @@ class ShapedRecipe implements Recipe{ private $shapeItems = []; /** - * @param Item $result - * @param string[] $shape + * @param Item $result + * @param int $height + * @param int $width * * @throws \Exception */ - public function __construct(Item $result, ...$shape){ - if(count($shape) === 0){ - throw new \InvalidArgumentException("Must provide a shape"); - } - if(count($shape) > 3){ - throw new \InvalidStateException("Crafting recipes should be 1, 2, 3 rows, not " . count($shape)); - } - foreach($shape as $y => $row){ - if(strlen($row) === 0 or strlen($row) > 3){ - throw new \InvalidStateException("Crafting rows should be 1, 2, 3 characters, not " . count($row)); - } - $this->ingredients[] = array_fill(0, strlen($row), null); - $len = strlen($row); - for($i = 0; $i < $len; ++$i){ - $this->shape[$row{$i}] = null; - - if(!isset($this->shapeItems[$row{$i}])){ - $this->shapeItems[$row{$i}] = [new Vector2($i, $y)]; - }else{ - $this->shapeItems[$row{$i}][] = new Vector2($i, $y); - } + public function __construct(Item $result, $height, $width){ + for($h = 0; $h < $height; $h++){ + if($width === 0 or $width > 3){ + throw new \InvalidStateException("Crafting rows should be 1, 2, 3 wide, not $width"); } + $this->ingredients[] = array_fill(0, $width, null); } $this->output = clone $result; @@ -97,6 +82,11 @@ class ShapedRecipe implements Recipe{ $this->id = $id; } + public function addIngredient($x, $y, Item $item){ + $this->ingredients[$y][$x] = clone $item; + return $this; + } + /** * @param string $key * @param Item $item @@ -158,4 +148,4 @@ class ShapedRecipe implements Recipe{ public function registerToCraftingManager(){ Server::getInstance()->getCraftingManager()->registerShapedRecipe($this); } -} \ No newline at end of file +} diff --git a/src/pocketmine/item/BlazePowder.php b/src/pocketmine/item/BlazePowder.php new file mode 100644 index 000000000..ce4d771cd --- /dev/null +++ b/src/pocketmine/item/BlazePowder.php @@ -0,0 +1,28 @@ +getData(); } - /** - * @param Compound $tag - * @return string - */ - private static function writeCompoundTag(Compound $tag){ + private static function writeCompoundTag(CompoundTag $tag) : string{ if(self::$cachedParser === null){ self::$cachedParser = new NBT(NBT::LITTLE_ENDIAN); } @@ -105,10 +100,10 @@ class Item{ const LAPIS_BLOCK = 22; const SANDSTONE = 24; - + const NOTEBLOCK = 25; const BED_BLOCK = 26; - - + const POWERED_RAIL = 27; + const DETECTOR_RAIL = 28; const COBWEB = 30; const TALL_GRASS = 31; const BUSH = 32; @@ -141,7 +136,7 @@ class Item{ const OAK_WOOD_STAIRS = 53; const OAK_WOODEN_STAIRS = 53; const CHEST = 54; - + const REDSTONE_WIRE = 55; const DIAMOND_ORE = 56; const DIAMOND_BLOCK = 57; const CRAFTING_TABLE = 58; @@ -156,17 +151,20 @@ class Item{ const WOODEN_DOOR_BLOCK = 64; const WOOD_DOOR_BLOCK = 64; const LADDER = 65; - + const RAIL = 66; const COBBLE_STAIRS = 67; const COBBLESTONE_STAIRS = 67; const WALL_SIGN = 68; - + const LEVER = 69; + const STONE_PRESSURE_PLATE = 70; const IRON_DOOR_BLOCK = 71; - + const WOODEN_PRESSURE_PLATE = 72; const REDSTONE_ORE = 73; const GLOWING_REDSTONE_ORE = 74; const LIT_REDSTONE_ORE = 74; - + const REDSTONE_TORCH = 75; + const LIT_REDSTONE_TORCH = 76; + const STONE_BUTTON = 77; const SNOW = 78; const SNOW_LAYER = 78; const ICE = 79; @@ -183,16 +181,17 @@ class Item{ const GLOWSTONE = 89; const GLOWSTONE_BLOCK = 89; - + const PORTAL_BLOCK = 90; const LIT_PUMPKIN = 91; const JACK_O_LANTERN = 91; const CAKE_BLOCK = 92; const TRAPDOOR = 96; - + const MONSTER_EGG_BLOCK = 97; const STONE_BRICKS = 98; const STONE_BRICK = 98; - + const BROWN_MUSHROOM_BLOCK = 99; + const RED_MUSHROOM_BLOCK = 100; const IRON_BAR = 101; const IRON_BARS = 101; const GLASS_PANE = 102; @@ -212,17 +211,24 @@ class Item{ const NETHER_BRICK_BLOCK = 112; const NETHER_BRICK_FENCE = 113; const NETHER_BRICKS_STAIRS = 114; - + const NETHER_WART_BLOCK = 115; const ENCHANTING_TABLE = 116; const ENCHANT_TABLE = 116; const ENCHANTMENT_TABLE = 116; - const BREWING_STAND = 117; + const BREWING_STAND_BLOCK = 117; + const END_PORTAL = 120; const END_STONE = 121; + const REDSTONE_LAMP = 122; + const LIT_REDSTONE_LAMP = 123; + const ACTIVATOR_RAIL = 126; + const COCOA_BLOCK = 127; const SANDSTONE_STAIRS = 128; const EMERALD_ORE = 129; + const TRIPWIRE_HOOK = 131; + const TRIPWIRE = 132; const EMERALD_BLOCK = 133; const SPRUCE_WOOD_STAIRS = 134; const SPRUCE_WOODEN_STAIRS = 134; @@ -237,11 +243,16 @@ class Item{ const FLOWER_POT_BLOCK = 140; const CARROT_BLOCK = 141; const POTATO_BLOCK = 142; - + const WOODEN_BUTTON = 143; + const MOB_HEAD_BLOCK = 144; const ANVIL = 145; const TRAPPED_CHEST = 146; + const WEIGHTED_PRESSURE_PLATE_LIGHT = 147; + const WEIGHTED_PRESSURE_PLATE_HEAVY = 148; + const DAYLIGHT_SENSOR = 151; const REDSTONE_BLOCK = 152; + const NETHER_QUARTZ_ORE = 153; const QUARTZ_BLOCK = 155; const QUARTZ_STAIRS = 156; @@ -267,6 +278,7 @@ class Item{ const DARK_OAK_WOODEN_STAIRS = 164; const IRON_TRAPDOOR = 167; + const HAY_BALE = 170; const CARPET = 171; const HARDENED_CLAY = 172; @@ -274,6 +286,8 @@ class Item{ const PACKED_ICE = 174; const DOUBLE_PLANT = 175; + const INVERTED_DAYLIGHT_SENSOR = 178; + const FENCE_GATE_SPRUCE = 183; const FENCE_GATE_BIRCH = 184; const FENCE_GATE_JUNGLE = 185; @@ -289,24 +303,23 @@ class Item{ //Normal Item IDs - - const IRON_SHOVEL = 256; // - const IRON_PICKAXE = 257; // - const IRON_AXE = 258; // - const FLINT_STEEL = 259; // - const FLINT_AND_STEEL = 259; // - const APPLE = 260; // + const IRON_SHOVEL = 256; + const IRON_PICKAXE = 257; + const IRON_AXE = 258; + const FLINT_STEEL = 259; + const FLINT_AND_STEEL = 259; + const APPLE = 260; const BOW = 261; const ARROW = 262; - const COAL = 263; // - const DIAMOND = 264; // - const IRON_INGOT = 265; // - const GOLD_INGOT = 266; // + const COAL = 263; + const DIAMOND = 264; + const IRON_INGOT = 265; + const GOLD_INGOT = 266; const IRON_SWORD = 267; - const WOODEN_SWORD = 268; // - const WOODEN_SHOVEL = 269; // - const WOODEN_PICKAXE = 270; // - const WOODEN_AXE = 271; // + const WOODEN_SWORD = 268; + const WOODEN_SHOVEL = 269; + const WOODEN_PICKAXE = 270; + const WOODEN_AXE = 271; const STONE_SWORD = 272; const STONE_SHOVEL = 273; const STONE_PICKAXE = 274; @@ -315,9 +328,9 @@ class Item{ const DIAMOND_SHOVEL = 277; const DIAMOND_PICKAXE = 278; const DIAMOND_AXE = 279; - const STICK = 280; // + const STICK = 280; const STICKS = 280; - const BOWL = 281; // + const BOWL = 281; const MUSHROOM_STEW = 282; const GOLD_SWORD = 283; const GOLD_SHOVEL = 284; @@ -328,11 +341,11 @@ class Item{ const GOLDEN_PICKAXE = 285; const GOLDEN_AXE = 286; const STRING = 287; - const FEATHER = 288; // + const FEATHER = 288; const GUNPOWDER = 289; const WOODEN_HOE = 290; const STONE_HOE = 291; - const IRON_HOE = 292; // + const IRON_HOE = 292; const DIAMOND_HOE = 293; const GOLD_HOE = 294; const GOLDEN_HOE = 294; @@ -370,12 +383,12 @@ class Item{ const BUCKET = 325; const MINECART = 328; - + const SADDLE = 329; const IRON_DOOR = 330; const REDSTONE = 331; const REDSTONE_DUST = 331; const SNOWBALL = 332; - + const BOAT = 333; const LEATHER = 334; const BRICK = 336; @@ -403,7 +416,6 @@ class Item{ const COOKIE = 357; - const SHEARS = 359; const MELON = 360; const MELON_SLICE = 360; @@ -412,14 +424,25 @@ class Item{ const RAW_BEEF = 363; const STEAK = 364; const COOKED_BEEF = 364; - const RAW_CHICKEN = 365; const COOKED_CHICKEN = 366; + const ROTTEN_FLESH = 367; + const BLAZE_ROD = 369; + const GHAST_TEAR = 370; const GOLD_NUGGET = 371; const GOLDEN_NUGGET = 371; - + const NETHER_WART = 372; + const POTION = 373; + const GLASS_BOTTLE = 374; + const SPIDER_EYE = 375; + const FERMENTED_SPIDER_EYE = 376; + const BLAZE_POWDER = 377; + const MAGMA_CREAM = 378; + const BREWING_STAND = 379; + const GLISTERING_MELON = 382; const SPAWN_EGG = 383; + const BOTTLE_O_ENCHANTING = 384; const EMERALD = 388; @@ -430,13 +453,24 @@ class Item{ const POTATOES = 392; const BAKED_POTATO = 393; const BAKED_POTATOES = 393; - + const POISONOUS_POTATO = 394; + const GOLDEN_CARROT = 396; + const MOB_HEAD = 397; const PUMPKIN_PIE = 400; + const ENCHANTED_BOOK = 403; + const NETHER_BRICK = 405; const QUARTZ = 406; const NETHER_QUARTZ = 406; + const RAW_RABBIT = 411; + const COOKED_RABBIT = 412; + const RABBIT_STEW = 413; + const RABIT_FOOT = 414; + const RABBIT_HIDE = 415; + const SPLASH_POTION = 438; + const CAMERA = 456; const BEETROOT = 457; const BEETROOT_SEEDS = 458; @@ -536,6 +570,7 @@ class Item{ self::$list[self::IRON_DOOR] = IronDoor::class; self::$list[self::REDSTONE] = Redstone::class; self::$list[self::SNOWBALL] = Snowball::class; + self::$list[self::BOAT] = Boat::class; self::$list[self::LEATHER] = Leather::class; self::$list[self::BRICK] = Brick::class; self::$list[self::CLAY] = Clay::class; @@ -545,6 +580,7 @@ class Item{ self::$list[self::SLIMEBALL] = Slimeball::class; self::$list[self::EGG] = Egg::class; self::$list[self::COMPASS] = Compass::class; + self::$list[self::FISHING_ROD] = FishingRod::class; self::$list[self::CLOCK] = Clock::class; self::$list[self::GLOWSTONE_DUST] = GlowstoneDust::class; self::$list[self::RAW_FISH] = Fish::class; @@ -564,16 +600,27 @@ class Item{ self::$list[self::RAW_CHICKEN] = RawChicken::class; self::$list[self::COOKED_CHICKEN] = CookedChicken::class; self::$list[self::GOLD_NUGGET] = GoldNugget::class; + self::$list[self::NETHER_WART] = NetherWart::class; + self::$list[self::POTION] = Potion::class; + self::$list[self::GLASS_BOTTLE] = GlassBottle::class; + self::$list[self::SPIDER_EYE] = SpiderEye::class; + self::$list[self::FERMENTED_SPIDER_EYE] = FermentedSpiderEye::class; + self::$list[self::BLAZE_POWDER] = BlazePowder::class; + self::$list[self::MAGMA_CREAM] = MagmaCream::class; + self::$list[self::BREWING_STAND] = BrewingStand::class; + self::$list[self::GLISTERING_MELON] = GlisteringMelon::class; self::$list[self::SPAWN_EGG] = SpawnEgg::class; self::$list[self::EMERALD] = Emerald::class; self::$list[self::FLOWER_POT] = FlowerPot::class; self::$list[self::CARROT] = Carrot::class; self::$list[self::POTATO] = Potato::class; self::$list[self::BAKED_POTATO] = BakedPotato::class; + self::$list[self::GOLDEN_CARROT] = GoldenCarrot::class; self::$list[self::PUMPKIN_PIE] = PumpkinPie::class; self::$list[self::NETHER_BRICK] = NetherBrick::class; self::$list[self::QUARTZ] = Quartz::class; self::$list[self::QUARTZ] = NetherQuartz::class; + self::$list[self::COOKED_RABBIT] = CookedRabbit::class; // self::$list[self::CAMERA] = Camera::class; self::$list[self::BEETROOT] = Beetroot::class; self::$list[self::BEETROOT_SEEDS] = BeetrootSeeds::class; @@ -594,451 +641,18 @@ class Item{ private static function initCreativeItems(){ self::clearCreativeItems(); - //Building - self::addCreativeItem(Item::get(Item::COBBLESTONE, 0)); - self::addCreativeItem(Item::get(Item::STONE_BRICKS, 0)); - self::addCreativeItem(Item::get(Item::STONE_BRICKS, 1)); - self::addCreativeItem(Item::get(Item::STONE_BRICKS, 2)); - self::addCreativeItem(Item::get(Item::STONE_BRICKS, 3)); - self::addCreativeItem(Item::get(Item::MOSS_STONE, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 1)); - self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 2)); - self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 3)); - self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 4)); - self::addCreativeItem(Item::get(Item::WOODEN_PLANKS, 5)); - self::addCreativeItem(Item::get(Item::BRICKS, 0)); - self::addCreativeItem(Item::get(Item::STONE, 0)); - self::addCreativeItem(Item::get(Item::STONE, 1)); - self::addCreativeItem(Item::get(Item::STONE, 2)); - self::addCreativeItem(Item::get(Item::STONE, 3)); - self::addCreativeItem(Item::get(Item::STONE, 4)); - self::addCreativeItem(Item::get(Item::STONE, 5)); - self::addCreativeItem(Item::get(Item::STONE, 6)); - self::addCreativeItem(Item::get(Item::DIRT, 0)); - self::addCreativeItem(Item::get(Item::PODZOL, 0)); - self::addCreativeItem(Item::get(Item::GRASS, 0)); - self::addCreativeItem(Item::get(Item::MYCELIUM, 0)); - self::addCreativeItem(Item::get(Item::CLAY_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::HARDENED_CLAY, 0)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 0)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 7)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 6)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 5)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 4)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 3)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 2)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 1)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 15)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 14)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 13)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 12)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 11)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 10)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 9)); - self::addCreativeItem(Item::get(Item::STAINED_CLAY, 8)); - self::addCreativeItem(Item::get(Item::SANDSTONE, 0)); - self::addCreativeItem(Item::get(Item::SANDSTONE, 1)); - self::addCreativeItem(Item::get(Item::SANDSTONE, 2)); - self::addCreativeItem(Item::get(Item::SAND, 0)); - self::addCreativeItem(Item::get(Item::SAND, 1)); - self::addCreativeItem(Item::get(Item::GRAVEL, 0)); - self::addCreativeItem(Item::get(Item::TRUNK, 0)); - self::addCreativeItem(Item::get(Item::TRUNK, 1)); - self::addCreativeItem(Item::get(Item::TRUNK, 2)); - self::addCreativeItem(Item::get(Item::TRUNK, 3)); - self::addCreativeItem(Item::get(Item::TRUNK2, 0)); - self::addCreativeItem(Item::get(Item::TRUNK2, 1)); - self::addCreativeItem(Item::get(Item::NETHER_BRICKS, 0)); - self::addCreativeItem(Item::get(Item::NETHERRACK, 0)); - self::addCreativeItem(Item::get(Item::SOUL_SAND, 0)); - self::addCreativeItem(Item::get(Item::BEDROCK, 0)); - self::addCreativeItem(Item::get(Item::COBBLESTONE_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::OAK_WOODEN_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::SPRUCE_WOODEN_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::BIRCH_WOODEN_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::JUNGLE_WOODEN_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::ACACIA_WOODEN_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::DARK_OAK_WOODEN_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::BRICK_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::SANDSTONE_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::STONE_BRICK_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::NETHER_BRICKS_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::QUARTZ_STAIRS, 0)); - self::addCreativeItem(Item::get(Item::SLAB, 0)); - self::addCreativeItem(Item::get(Item::SLAB, 1)); - self::addCreativeItem(Item::get(Item::WOODEN_SLAB, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_SLAB, 1)); - self::addCreativeItem(Item::get(Item::WOODEN_SLAB, 2)); - self::addCreativeItem(Item::get(Item::WOODEN_SLAB, 3)); - self::addCreativeItem(Item::get(Item::WOODEN_SLAB, 4)); - self::addCreativeItem(Item::get(Item::WOODEN_SLAB, 5)); - self::addCreativeItem(Item::get(Item::SLAB, 3)); - self::addCreativeItem(Item::get(Item::SLAB, 4)); - self::addCreativeItem(Item::get(Item::SLAB, 5)); - self::addCreativeItem(Item::get(Item::SLAB, 6)); - self::addCreativeItem(Item::get(Item::SLAB, 7)); - self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 1)); - self::addCreativeItem(Item::get(Item::QUARTZ_BLOCK, 2)); - self::addCreativeItem(Item::get(Item::COAL_ORE, 0)); - self::addCreativeItem(Item::get(Item::IRON_ORE, 0)); - self::addCreativeItem(Item::get(Item::GOLD_ORE, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_ORE, 0)); - self::addCreativeItem(Item::get(Item::LAPIS_ORE, 0)); - self::addCreativeItem(Item::get(Item::REDSTONE_ORE, 0)); - self::addCreativeItem(Item::get(Item::EMERALD_ORE, 0)); - self::addCreativeItem(Item::get(Item::OBSIDIAN, 0)); - self::addCreativeItem(Item::get(Item::ICE, 0)); - self::addCreativeItem(Item::get(Item::PACKED_ICE, 0)); - self::addCreativeItem(Item::get(Item::SNOW_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::END_STONE, 0)); + $creativeItems = new Config(Server::getInstance()->getFilePath() . "src/pocketmine/resources/creativeitems.json", Config::JSON, []); - //Decoration - self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 0)); - self::addCreativeItem(Item::get(Item::COBBLESTONE_WALL, 1)); - self::addCreativeItem(Item::get(Item::WATER_LILY, 0)); - self::addCreativeItem(Item::get(Item::GOLD_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::IRON_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::LAPIS_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::COAL_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::EMERALD_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::REDSTONE_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::SNOW_LAYER, 0)); - self::addCreativeItem(Item::get(Item::GLASS, 0)); - self::addCreativeItem(Item::get(Item::GLOWSTONE_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::VINES, 0)); - self::addCreativeItem(Item::get(Item::LADDER, 0)); - self::addCreativeItem(Item::get(Item::SPONGE, 0)); - self::addCreativeItem(Item::get(Item::GLASS_PANE, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 0)); // Oak - self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 1)); // Spruce - self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 2)); // Birch - self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 3)); // Jungle - self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 4)); // Acacia - self::addCreativeItem(Item::get(Item::WOODEN_DOOR, 5)); // Dark oak - self::addCreativeItem(Item::get(Item::IRON_DOOR, 0)); - self::addCreativeItem(Item::get(Item::TRAPDOOR, 0)); - self::addCreativeItem(Item::get(Item::IRON_TRAPDOOR, 0)); - self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_OAK)); - self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_SPRUCE)); - self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_BIRCH)); - self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_JUNGLE)); - self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_ACACIA)); - self::addCreativeItem(Item::get(Item::FENCE, Fence::FENCE_DARKOAK)); - self::addCreativeItem(Item::get(Item::NETHER_BRICK_FENCE, 0)); - self::addCreativeItem(Item::get(Item::FENCE_GATE, 0)); - self::addCreativeItem(Item::get(Item::FENCE_GATE_SPRUCE, 0)); - self::addCreativeItem(Item::get(Item::FENCE_GATE_BIRCH, 0)); - self::addCreativeItem(Item::get(Item::FENCE_GATE_JUNGLE, 0)); - self::addCreativeItem(Item::get(Item::FENCE_GATE_ACACIA, 0)); - self::addCreativeItem(Item::get(Item::FENCE_GATE_DARK_OAK, 0)); - self::addCreativeItem(Item::get(Item::IRON_BARS, 0)); - self::addCreativeItem(Item::get(Item::BED, 0)); - self::addCreativeItem(Item::get(Item::BOOKSHELF, 0)); - self::addCreativeItem(Item::get(Item::PAINTING, 0)); - self::addCreativeItem(Item::get(Item::WORKBENCH, 0)); - self::addCreativeItem(Item::get(Item::STONECUTTER, 0)); - self::addCreativeItem(Item::get(Item::CHEST, 0)); - self::addCreativeItem(Item::get(Item::TRAPPED_CHEST, 0)); - self::addCreativeItem(Item::get(Item::FURNACE, 0)); - self::addCreativeItem(Item::get(Item::BREWING_STAND, 0)); - // TODO: Note Block - self::addCreativeItem(Item::get(Item::END_PORTAL, 0)); - self::addCreativeItem(Item::get(Item::ANVIL, 0)); - self::addCreativeItem(Item::get(Item::ANVIL, 4)); - self::addCreativeItem(Item::get(Item::ANVIL, 8)); - self::addCreativeItem(Item::get(Item::DANDELION, 0)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_POPPY)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_BLUE_ORCHID)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_ALLIUM)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_AZURE_BLUET)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_RED_TULIP)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_ORANGE_TULIP)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_WHITE_TULIP)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_PINK_TULIP)); - self::addCreativeItem(Item::get(Item::RED_FLOWER, Flower::TYPE_OXEYE_DAISY)); - // TODO: Sunflower - // TODO: Lilac - // TODO: Double Tallgrass - // TODO: Large Fern - // TODO: Rose Bush - // TODO: Peony - self::addCreativeItem(Item::get(Item::BROWN_MUSHROOM, 0)); - self::addCreativeItem(Item::get(Item::RED_MUSHROOM, 0)); - // TODO: Mushroom block (brown, cover) - // TODO: Mushroom block (red, cover) - // TODO: Mushroom block (brown, stem) - // TODO: Mushroom block (red, stem) - self::addCreativeItem(Item::get(Item::CACTUS, 0)); - self::addCreativeItem(Item::get(Item::MELON_BLOCK, 0)); - self::addCreativeItem(Item::get(Item::PUMPKIN, 0)); - self::addCreativeItem(Item::get(Item::LIT_PUMPKIN, 0)); - self::addCreativeItem(Item::get(Item::COBWEB, 0)); - self::addCreativeItem(Item::get(Item::HAY_BALE, 0)); - self::addCreativeItem(Item::get(Item::TALL_GRASS, 1)); - self::addCreativeItem(Item::get(Item::TALL_GRASS, 2)); - self::addCreativeItem(Item::get(Item::DEAD_BUSH, 0)); - self::addCreativeItem(Item::get(Item::SAPLING, 0)); - self::addCreativeItem(Item::get(Item::SAPLING, 1)); - self::addCreativeItem(Item::get(Item::SAPLING, 2)); - self::addCreativeItem(Item::get(Item::SAPLING, 3)); - self::addCreativeItem(Item::get(Item::SAPLING, 4)); - self::addCreativeItem(Item::get(Item::SAPLING, 5)); - self::addCreativeItem(Item::get(Item::LEAVES, 0)); - self::addCreativeItem(Item::get(Item::LEAVES, 1)); - self::addCreativeItem(Item::get(Item::LEAVES, 2)); - self::addCreativeItem(Item::get(Item::LEAVES, 3)); - self::addCreativeItem(Item::get(Item::LEAVES2, 0)); - self::addCreativeItem(Item::get(Item::LEAVES2, 1)); - self::addCreativeItem(Item::get(Item::CAKE, 0)); - // TODO: Skeleton skull - // TODO: Wither skeleton skull - // TODO: Zombie head - // TODO: Head - // TODO: Creeper head - self::addCreativeItem(Item::get(Item::SIGN, 0)); - self::addCreativeItem(Item::get(Item::FLOWER_POT, 0)); - self::addCreativeItem(Item::get(Item::MONSTER_SPAWNER, 0)); - self::addCreativeItem(Item::get(Item::ENCHANTMENT_TABLE, 0)); - self::addCreativeItem(Item::get(Item::WOOL, 0)); - self::addCreativeItem(Item::get(Item::WOOL, 7)); - self::addCreativeItem(Item::get(Item::WOOL, 6)); - self::addCreativeItem(Item::get(Item::WOOL, 5)); - self::addCreativeItem(Item::get(Item::WOOL, 4)); - self::addCreativeItem(Item::get(Item::WOOL, 3)); - self::addCreativeItem(Item::get(Item::WOOL, 2)); - self::addCreativeItem(Item::get(Item::WOOL, 1)); - self::addCreativeItem(Item::get(Item::WOOL, 15)); - self::addCreativeItem(Item::get(Item::WOOL, 14)); - self::addCreativeItem(Item::get(Item::WOOL, 13)); - self::addCreativeItem(Item::get(Item::WOOL, 12)); - self::addCreativeItem(Item::get(Item::WOOL, 11)); - self::addCreativeItem(Item::get(Item::WOOL, 10)); - self::addCreativeItem(Item::get(Item::WOOL, 9)); - self::addCreativeItem(Item::get(Item::WOOL, 8)); - self::addCreativeItem(Item::get(Item::CARPET, 0)); - self::addCreativeItem(Item::get(Item::CARPET, 7)); - self::addCreativeItem(Item::get(Item::CARPET, 6)); - self::addCreativeItem(Item::get(Item::CARPET, 5)); - self::addCreativeItem(Item::get(Item::CARPET, 4)); - self::addCreativeItem(Item::get(Item::CARPET, 3)); - self::addCreativeItem(Item::get(Item::CARPET, 2)); - self::addCreativeItem(Item::get(Item::CARPET, 1)); - self::addCreativeItem(Item::get(Item::CARPET, 15)); - self::addCreativeItem(Item::get(Item::CARPET, 14)); - self::addCreativeItem(Item::get(Item::CARPET, 13)); - self::addCreativeItem(Item::get(Item::CARPET, 12)); - self::addCreativeItem(Item::get(Item::CARPET, 11)); - self::addCreativeItem(Item::get(Item::CARPET, 10)); - self::addCreativeItem(Item::get(Item::CARPET, 9)); - self::addCreativeItem(Item::get(Item::CARPET, 8)); - - //Tools - // TODO: self::addCreativeItem(Item::get(Item::RAILS, 0)); - // TODO: self::addCreativeItem(Item::get(Item::POWERED_RAILS, 0)); - // TODO: Detector rail - // TODO: Activator rail - self::addCreativeItem(Item::get(Item::TORCH, 0)); - self::addCreativeItem(Item::get(Item::BUCKET, 0)); - self::addCreativeItem(Item::get(Item::BUCKET, 1)); - self::addCreativeItem(Item::get(Item::BUCKET, 8)); - self::addCreativeItem(Item::get(Item::BUCKET, 10)); - self::addCreativeItem(Item::get(Item::TNT, 0)); - self::addCreativeItem(Item::get(Item::REDSTONE, 0)); - self::addCreativeItem(Item::get(Item::BOW, 0)); - self::addCreativeItem(Item::get(Item::FISHING_ROD, 0)); - self::addCreativeItem(Item::get(Item::FLINT_AND_STEEL, 0)); - self::addCreativeItem(Item::get(Item::SHEARS, 0)); - self::addCreativeItem(Item::get(Item::CLOCK, 0)); - self::addCreativeItem(Item::get(Item::COMPASS, 0)); - self::addCreativeItem(Item::get(Item::MINECART, 0)); - // TODO: Oak boat - // TODO: Spruce boat - // TODO: Birch boat - // TODO: Jungle boat - // TODO: Acacia boat - // TODO: Dark Oak boat - self::addCreativeItem(Item::get(Item::SPAWN_EGG, Villager::NETWORK_ID)); - //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 10)); //Chicken - //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 11)); //Cow - //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 12)); //Pig - //self::addCreativeItem(Item::get(Item::SPAWN_EGG, 13)); //Sheep - // TODO: Wolf - // TODO: Ocelot - // TODO: Mooshroom - // TODO: Bat - // TODO: Rabbit - // TODO: Creeper - // TODO: Enderman - // TODO: Silverfish - // TODO: Skeleton - // TODO: Slime - // TODO: Spider - self::addCreativeItem(Item::get(Item::SPAWN_EGG, Zombie::NETWORK_ID)); - //TODO: PigZombie - self::addCreativeItem(Item::get(Item::SPAWN_EGG, Squid::NETWORK_ID)); - // TODO: Cave spider - // TODO: Magma cube - // TODO: Ghast - // TODO: Blaze - self::addCreativeItem(Item::get(Item::WOODEN_SWORD, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_HOE, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_SHOVEL, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_PICKAXE, 0)); - self::addCreativeItem(Item::get(Item::WOODEN_AXE, 0)); - self::addCreativeItem(Item::get(Item::STONE_SWORD, 0)); - self::addCreativeItem(Item::get(Item::STONE_HOE, 0)); - self::addCreativeItem(Item::get(Item::STONE_SHOVEL, 0)); - self::addCreativeItem(Item::get(Item::STONE_PICKAXE, 0)); - self::addCreativeItem(Item::get(Item::STONE_AXE, 0)); - self::addCreativeItem(Item::get(Item::IRON_SWORD, 0)); - self::addCreativeItem(Item::get(Item::IRON_HOE, 0)); - self::addCreativeItem(Item::get(Item::IRON_SHOVEL, 0)); - self::addCreativeItem(Item::get(Item::IRON_PICKAXE, 0)); - self::addCreativeItem(Item::get(Item::IRON_AXE, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_SWORD, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_HOE, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_SHOVEL, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_PICKAXE, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_AXE, 0)); - self::addCreativeItem(Item::get(Item::GOLD_SWORD, 0)); - self::addCreativeItem(Item::get(Item::GOLD_HOE, 0)); - self::addCreativeItem(Item::get(Item::GOLD_SHOVEL, 0)); - self::addCreativeItem(Item::get(Item::GOLD_PICKAXE, 0)); - self::addCreativeItem(Item::get(Item::GOLD_AXE, 0)); - self::addCreativeItem(Item::get(Item::LEATHER_CAP, 0)); - self::addCreativeItem(Item::get(Item::LEATHER_TUNIC, 0)); - self::addCreativeItem(Item::get(Item::LEATHER_PANTS, 0)); - self::addCreativeItem(Item::get(Item::LEATHER_BOOTS, 0)); - self::addCreativeItem(Item::get(Item::CHAIN_HELMET, 0)); - self::addCreativeItem(Item::get(Item::CHAIN_CHESTPLATE, 0)); - self::addCreativeItem(Item::get(Item::CHAIN_LEGGINGS, 0)); - self::addCreativeItem(Item::get(Item::CHAIN_BOOTS, 0)); - self::addCreativeItem(Item::get(Item::IRON_HELMET, 0)); - self::addCreativeItem(Item::get(Item::IRON_CHESTPLATE, 0)); - self::addCreativeItem(Item::get(Item::IRON_LEGGINGS, 0)); - self::addCreativeItem(Item::get(Item::IRON_BOOTS, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_HELMET, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_CHESTPLATE, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_LEGGINGS, 0)); - self::addCreativeItem(Item::get(Item::DIAMOND_BOOTS, 0)); - self::addCreativeItem(Item::get(Item::GOLD_HELMET, 0)); - self::addCreativeItem(Item::get(Item::GOLD_CHESTPLATE, 0)); - self::addCreativeItem(Item::get(Item::GOLD_LEGGINGS, 0)); - self::addCreativeItem(Item::get(Item::GOLD_BOOTS, 0)); - // TODO: Lever - // TODO: Redstone lamp - // TODO: Redstone torch - // TODO: Wood pressure plate - // TODO: Stone pressure plate - // TODO: Weighted pressure plate light - // TODO: Weighted pressure plate heavy - // TODO: Wood button - // TODO: Stone button - // TODO: Daylight sensor - // TODO: Tripwire hook - self::addCreativeItem(Item::get(Item::SNOWBALL)); - - //Seeds - self::addCreativeItem(Item::get(Item::COAL, 0)); - self::addCreativeItem(Item::get(Item::COAL, 1)); - self::addCreativeItem(Item::get(Item::DIAMOND, 0)); - self::addCreativeItem(Item::get(Item::IRON_INGOT, 0)); - self::addCreativeItem(Item::get(Item::GOLD_INGOT, 0)); - self::addCreativeItem(Item::get(Item::EMERALD, 0)); - self::addCreativeItem(Item::get(Item::STICK, 0)); - self::addCreativeItem(Item::get(Item::BOWL, 0)); - self::addCreativeItem(Item::get(Item::STRING, 0)); - self::addCreativeItem(Item::get(Item::FEATHER, 0)); - self::addCreativeItem(Item::get(Item::FLINT, 0)); - self::addCreativeItem(Item::get(Item::LEATHER, 0)); - // TODO: Rabbit hide - self::addCreativeItem(Item::get(Item::CLAY, 0)); - self::addCreativeItem(Item::get(Item::SUGAR, 0)); - self::addCreativeItem(Item::get(Item::NETHER_QUARTZ, 0)); - self::addCreativeItem(Item::get(Item::PAPER, 0)); - self::addCreativeItem(Item::get(Item::BOOK, 0)); - self::addCreativeItem(Item::get(Item::ARROW, 0)); - self::addCreativeItem(Item::get(Item::BONE, 0)); - self::addCreativeItem(Item::get(Item::SUGARCANE, 0)); - self::addCreativeItem(Item::get(Item::WHEAT, 0)); - self::addCreativeItem(Item::get(Item::SEEDS, 0)); - self::addCreativeItem(Item::get(Item::PUMPKIN_SEEDS, 0)); - self::addCreativeItem(Item::get(Item::MELON_SEEDS, 0)); - self::addCreativeItem(Item::get(Item::BEETROOT_SEEDS, 0)); - self::addCreativeItem(Item::get(Item::EGG, 0)); - self::addCreativeItem(Item::get(Item::APPLE, 0)); - self::addCreativeItem(Item::get(Item::GOLDEN_APPLE, 0)); - // TODO: Golden apple enchanted - self::addCreativeItem(Item::get(Item::RAW_FISH, 0)); - self::addCreativeItem(Item::get(Item::RAW_FISH, 1)); // TODO: Raw salmon - self::addCreativeItem(Item::get(Item::RAW_FISH, 2)); // TODO: Clownfish - self::addCreativeItem(Item::get(Item::RAW_FISH, 3)); // TODO: Pufferfish - self::addCreativeItem(Item::get(Item::COOKED_FISH, 0)); - self::addCreativeItem(Item::get(Item::COOKED_FISH, 1)); //salmon - // TODO: Rotten flesh - // TODO: Mushroom stew - self::addCreativeItem(Item::get(Item::BREAD, 0)); - self::addCreativeItem(Item::get(Item::RAW_PORKCHOP, 0)); - self::addCreativeItem(Item::get(Item::COOKED_PORKCHOP, 0)); - self::addCreativeItem(Item::get(Item::RAW_CHICKEN, 0)); - self::addCreativeItem(Item::get(Item::COOKED_CHICKEN, 0)); - self::addCreativeItem(Item::get(Item::RAW_BEEF, 0)); - self::addCreativeItem(Item::get(Item::STEAK, 0)); - self::addCreativeItem(Item::get(Item::MELON, 0)); - self::addCreativeItem(Item::get(Item::CARROT, 0)); - self::addCreativeItem(Item::get(Item::POTATO, 0)); - self::addCreativeItem(Item::get(Item::BAKED_POTATO, 0)); - // TODO: Poisonous potato - self::addCreativeItem(Item::get(Item::COOKIE, 0)); - self::addCreativeItem(Item::get(Item::PUMPKIN_PIE, 0)); - // TODO: Raw rabbit - // TODO: Cooked rabbit - // TODO: Rabbit stew - // TODO: Magma cream - // TODO: Blaze rod - self::addCreativeItem(Item::get(Item::GOLD_NUGGET, 0)); - // TODO: Golden carrot - // TODO: Glistering melon - // TODO: Rabbit's foot - // TODO: Ghast tear - self::addCreativeItem(Item::get(Item::SLIMEBALL, 0)); - // TODO: Blaze powder - // TODO: Nether wart - self::addCreativeItem(Item::get(Item::GUNPOWDER, 0)); - self::addCreativeItem(Item::get(Item::GLOWSTONE_DUST, 0)); - // TODO: Spider eye - // TODO: Fermented spider eye - // TODO: Bottle o' enchanting - // TODO: Enchanted books - self::addCreativeItem(Item::get(Item::DYE, 0)); - self::addCreativeItem(Item::get(Item::DYE, 7)); - self::addCreativeItem(Item::get(Item::DYE, 6)); - self::addCreativeItem(Item::get(Item::DYE, 5)); - self::addCreativeItem(Item::get(Item::DYE, 4)); - self::addCreativeItem(Item::get(Item::DYE, 3)); - self::addCreativeItem(Item::get(Item::DYE, 2)); - self::addCreativeItem(Item::get(Item::DYE, 1)); - self::addCreativeItem(Item::get(Item::DYE, 15)); - self::addCreativeItem(Item::get(Item::DYE, 14)); - self::addCreativeItem(Item::get(Item::DYE, 13)); - self::addCreativeItem(Item::get(Item::DYE, 12)); - self::addCreativeItem(Item::get(Item::DYE, 11)); - self::addCreativeItem(Item::get(Item::DYE, 10)); - self::addCreativeItem(Item::get(Item::DYE, 9)); - self::addCreativeItem(Item::get(Item::DYE, 8)); - // TODO: Glass bottle - // TODO: Water bottle - // TODO: Potions + foreach($creativeItems->getAll() as $item) { + self::addCreativeItem(Item::get($item["ID"], $item["Damage"])); + } } public static function clearCreativeItems(){ Item::$creative = []; } - public static function getCreativeItems(){ + public static function getCreativeItems() : array{ return Item::$creative; } @@ -1053,7 +667,7 @@ class Item{ } } - public static function isCreativeItem(Item $item){ + public static function isCreativeItem(Item $item) : bool{ foreach(Item::$creative as $i => $d){ if($item->equals($d, !$item->isTool())){ return true; @@ -1067,15 +681,11 @@ class Item{ * @param $index * @return Item */ - public static function getCreativeItem($index){ + public static function getCreativeItem(int $index){ return isset(Item::$creative[$index]) ? Item::$creative[$index] : null; } - /** - * @param Item $item - * @return int - */ - public static function getCreativeItemIndex(Item $item){ + public static function getCreativeItemIndex(Item $item) : int{ foreach(Item::$creative as $i => $d){ if($item->equals($d, !$item->isTool())){ return $i; @@ -1085,7 +695,7 @@ class Item{ return -1; } - public static function get($id, $meta = 0, $count = 1, $tags = ""){ + public static function get(int $id, $meta = 0, int $count = 1, $tags = "") : Item{ try{ $class = self::$list[$id]; if($class === null){ @@ -1100,7 +710,12 @@ class Item{ } } - public static function fromString($str, $multiple = false){ + /** + * @param string $str + * @param bool $multiple + * @return Item[]|Item + */ + public static function fromString(string $str, bool $multiple = false){ if($multiple === true){ $blocks = []; foreach(explode(",", $str) as $b){ @@ -1129,10 +744,10 @@ class Item{ } } - public function __construct($id, $meta = 0, $count = 1, $name = "Unknown"){ + public function __construct(int $id, $meta = 0, int $count = 1, string $name = "Unknown"){ $this->id = $id & 0xffff; $this->meta = $meta !== null ? $meta & 0xffff : null; - $this->count = (int) $count; + $this->count = $count; $this->name = $name; if(!isset($this->block) and $this->id <= 0xff and isset(Block::$list[$this->id])){ $this->block = Block::get($this->id, $this->meta); @@ -1141,7 +756,7 @@ class Item{ } public function setCompoundTag($tags){ - if($tags instanceof Compound){ + if($tags instanceof CompoundTag){ $this->setNamedTag($tags); }else{ $this->tags = $tags; @@ -1157,18 +772,18 @@ class Item{ public function getCompoundTag(){ return $this->tags; } - - public function hasCompoundTag(){ + + public function hasCompoundTag() : bool{ return $this->tags !== "" and $this->tags !== null; } - public function hasCustomBlockData(){ + public function hasCustomBlockData() : bool{ if(!$this->hasCompoundTag()){ return false; } $tag = $this->getNamedTag(); - if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof Compound){ + if(isset($tag->BlockEntityTag) and $tag->BlockEntityTag instanceof CompoundTag){ return true; } @@ -1181,7 +796,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); } @@ -1189,12 +804,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(); } @@ -1211,14 +826,14 @@ 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; } return null; } - public function hasEnchantments(){ + public function hasEnchantments() : bool{ if(!$this->hasCompoundTag()){ return false; } @@ -1226,7 +841,7 @@ class Item{ $tag = $this->getNamedTag(); if(isset($tag->ench)){ $tag = $tag->ench; - if($tag instanceof Enum){ + if($tag instanceof ListTag){ return true; } } @@ -1238,7 +853,7 @@ class Item{ * @param $id * @return Enchantment|null */ - public function getEnchantment($id){ + public function getEnchantment(int $id){ if(!$this->hasEnchantments()){ return null; } @@ -1259,13 +874,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); } @@ -1273,9 +888,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; @@ -1283,9 +898,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()) ]); } @@ -1295,7 +910,7 @@ class Item{ /** * @return Enchantment[] */ - public function getEnchantments(){ + public function getEnchantments() : array{ if(!$this->hasEnchantments()){ return []; } @@ -1311,7 +926,7 @@ class Item{ return $enchantments; } - public function hasCustomName(){ + public function hasCustomName() : bool{ if(!$this->hasCompoundTag()){ return false; } @@ -1319,7 +934,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; } } @@ -1327,7 +942,7 @@ class Item{ return false; } - public function getCustomName(){ + public function getCustomName() : string{ if(!$this->hasCompoundTag()){ return ""; } @@ -1335,7 +950,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(); } } @@ -1343,22 +958,22 @@ class Item{ return ""; } - public function setCustomName($name){ - if((string) $name === ""){ + public function setCustomName(string $name){ + if($name === ""){ $this->clearCustomName(); } 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) ]); } @@ -1371,7 +986,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); @@ -1401,7 +1016,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(); } @@ -1416,23 +1031,23 @@ class Item{ return $this->setCompoundTag(""); } - public function getCount(){ + public function getCount() : int{ return $this->count; } - public function setCount($count){ - $this->count = (int) $count; + public function setCount(int $count){ + $this->count = $count; } - final public function getName(){ + final public function getName() : string{ return $this->hasCustomName() ? $this->getCustomName() : $this->name; } - final public function canBePlaced(){ + final public function canBePlaced() : bool{ return $this->block !== null and $this->block->canBePlaced(); } - public function getBlock(){ + public function getBlock() : Block{ if($this->block instanceof Block){ return clone $this->block; }else{ @@ -1440,7 +1055,7 @@ class Item{ } } - final public function getId(){ + final public function getId() : int{ return $this->id; } @@ -1514,7 +1129,7 @@ class Item{ return false; } - final public function __toString(){ + final public function __toString() : string{ return "Item " . $this->name . " (" . $this->id . ":" . ($this->meta === null ? "?" : $this->meta) . ")x" . $this->count . ($this->hasCompoundTag() ? " tags:0x".bin2hex($this->getCompoundTag()) : ""); } @@ -1526,12 +1141,12 @@ class Item{ return false; } - public final function equals(Item $item, $checkDamage = true, $checkCompound = true){ + public final function equals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{ return $this->id === $item->getId() and ($checkDamage === false or $this->getDamage() === $item->getDamage()) and ($checkCompound === false or $this->getCompoundTag() === $item->getCompoundTag()); } - public final function deepEquals(Item $item, $checkDamage = true, $checkCompound = true){ - if($item->equals($item, $checkDamage, $checkCompound)){ + public final function deepEquals(Item $item, bool $checkDamage = true, bool $checkCompound = true) : bool{ + if($this->equals($item, $checkDamage, $checkCompound)){ return true; }elseif($item->hasCompoundTag() or $this->hasCompoundTag()){ return NBT::matchTree($this->getNamedTag(), $item->getNamedTag()); diff --git a/src/pocketmine/item/ItemBlock.php b/src/pocketmine/item/ItemBlock.php index fcbc18ea5..e7e827512 100644 --- a/src/pocketmine/item/ItemBlock.php +++ b/src/pocketmine/item/ItemBlock.php @@ -27,7 +27,7 @@ use pocketmine\block\Block; * Class used for Items that can be Blocks */ class ItemBlock extends Item{ - public function __construct(Block $block, $meta = 0, $count = 1){ + public function __construct(Block $block, $meta = 0, int $count = 1){ $this->block = $block; parent::__construct($block->getId(), $block->getDamage(), $count, $block->getName()); } @@ -41,7 +41,7 @@ class ItemBlock extends Item{ $this->block = clone $this->block; } - public function getBlock(){ + public function getBlock() : Block{ return $this->block; } diff --git a/src/pocketmine/item/MagmaCream.php b/src/pocketmine/item/MagmaCream.php new file mode 100644 index 000000000..37e97be92 --- /dev/null +++ b/src/pocketmine/item/MagmaCream.php @@ -0,0 +1,28 @@ + 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/SpiderEye.php b/src/pocketmine/item/SpiderEye.php new file mode 100644 index 000000000..b33d7c72a --- /dev/null +++ b/src/pocketmine/item/SpiderEye.php @@ -0,0 +1,28 @@ +what = $what; } - /** - * @deprecated - * @return bool - */ - public function explode(){ - if($this->explodeA()){ - return $this->explodeB(); - } - - return false; - } - /** * @return bool */ @@ -186,22 +174,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 282cdafc7..d482faba8 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -19,6 +19,8 @@ * */ +declare(strict_types=1); + /** * All Level related classes are here, like Generators, Populators, Noise, ... */ @@ -81,13 +83,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; @@ -266,23 +268,15 @@ class Level implements ChunkManager, Metadatable{ /** @var Generator */ private $generatorInstance; - /** - * Returns the chunk unique hash/key - * - * @param int $x - * @param int $z - * - * @return string - */ - public static function chunkHash($x, $z){ + public static function chunkHash(int $x, int $z){ return PHP_INT_SIZE === 8 ? (($x & 0xFFFFFFFF) << 32) | ($z & 0xFFFFFFFF) : $x . ":" . $z; } - public static function blockHash($x, $y, $z){ + public static function blockHash(int $x, int $y, int $z){ return PHP_INT_SIZE === 8 ? (($x & 0xFFFFFFF) << 35) | (($y & 0x7f) << 28) | ($z & 0xFFFFFFF) : $x . ":" . $y .":". $z; } - public static function chunkBlockHash($x, $y, $z){ + public static function chunkBlockHash(int $x, int $y, int $z) : int{ return ($x << 11) | ($z << 7) | $y; } @@ -310,7 +304,7 @@ class Level implements ChunkManager, Metadatable{ } } - public static function generateChunkLoaderId(ChunkLoader $loader){ + public static function generateChunkLoaderId(ChunkLoader $loader) : int{ if($loader->getLoaderId() === 0 or $loader->getLoaderId() === null or $loader->getLoaderId() === null){ return self::$chunkLoaderCounter++; }else{ @@ -328,7 +322,7 @@ class Level implements ChunkManager, Metadatable{ * * @throws \Exception */ - public function __construct(Server $server, $name, $path, $provider){ + public function __construct(Server $server, string $name, string $path, string $provider){ $this->blockStates = Block::$fullList; $this->levelId = static::$levelIdCounter++; $this->blockMetadata = new BlockMetadataStore($this); @@ -367,16 +361,16 @@ class Level implements ChunkManager, Metadatable{ $this->tickRate = 1; } - public function getTickRate(){ + public function getTickRate() : int{ return $this->tickRate; } - public function getTickRateTime(){ + public function getTickRateTime() : float{ return $this->tickRateTime; } - public function setTickRate($tickRate){ - $this->tickRate = (int) $tickRate; + public function setTickRate(int $tickRate){ + $this->tickRate = $tickRate; } public function initLevel(){ @@ -401,33 +395,22 @@ class Level implements ChunkManager, Metadatable{ } } - /** - * @return BlockMetadataStore - */ - public function getBlockMetadata(){ + public function getBlockMetadata() : BlockMetadataStore{ return $this->blockMetadata; } - /** - * @return Server - */ - public function getServer(){ + public function getServer() : Server{ return $this->server; } - /** - * @return LevelProvider - */ - final public function getProvider(){ + final public function getProvider() : LevelProvider{ return $this->provider; } /** * Returns the unique level identifier - * - * @return int */ - final public function getId(){ + final public function getId() : int{ return $this->levelId; } @@ -498,17 +481,11 @@ class Level implements ChunkManager, Metadatable{ } } - /** - * @return bool - */ - public function getAutoSave(){ + public function getAutoSave() : bool{ return $this->autoSave; } - /** - * @param bool $value - */ - public function setAutoSave($value){ + public function setAutoSave(bool $value){ $this->autoSave = $value; } @@ -519,7 +496,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function unload($force = false){ + public function unload(bool $force = false) : bool{ $ev = new LevelUnloadEvent($this); @@ -552,13 +529,6 @@ class Level implements ChunkManager, Metadatable{ return true; } - /** - * @deprecated Use Level->getChunkPlayers($chunkX, $chunkZ) - */ - public function getUsingChunk($chunkX, $chunkZ){ - return $this->getChunkPlayers($chunkX, $chunkZ); - } - /** * Gets the players being used in a specific chunk * @@ -567,7 +537,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Player[] */ - public function getChunkPlayers($chunkX, $chunkZ){ + public function getChunkPlayers(int $chunkX, int $chunkZ) : array{ return isset($this->playerLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->playerLoaders[$index] : []; } @@ -579,11 +549,11 @@ class Level implements ChunkManager, Metadatable{ * * @return ChunkLoader[] */ - public function getChunkLoaders($chunkX, $chunkZ){ + public function getChunkLoaders(int $chunkX, int $chunkZ) : array{ return isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunkLoaders[$index] : []; } - public function addChunkPacket($chunkX, $chunkZ, DataPacket $packet){ + public function addChunkPacket(int $chunkX, int $chunkZ, DataPacket $packet){ if(!isset($this->chunkPackets[$index = Level::chunkHash($chunkX, $chunkZ)])){ $this->chunkPackets[$index] = [$packet]; }else{ @@ -591,7 +561,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function registerChunkLoader(ChunkLoader $loader, $chunkX, $chunkZ, $autoLoad = true){ + public function registerChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ, bool $autoLoad = true){ $hash = $loader->getLoaderId(); if(!isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)])){ @@ -620,7 +590,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function unregisterChunkLoader(ChunkLoader $loader, $chunkX, $chunkZ){ + public function unregisterChunkLoader(ChunkLoader $loader, int $chunkX, int $chunkZ){ if(isset($this->chunkLoaders[$index = Level::chunkHash($chunkX, $chunkZ)][$hash = $loader->getLoaderId()])){ unset($this->chunkLoaders[$index][$hash]); unset($this->playerLoaders[$index][$hash]); @@ -667,9 +637,8 @@ class Level implements ChunkManager, Metadatable{ * * @param int $currentTick * - * @return bool */ - public function doTick($currentTick){ + public function doTick(int $currentTick){ $this->timings->doTick->startTiming(); @@ -804,7 +773,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function sendBlockExtraData($x, $y, $z, $id, $data, array $targets = null){ + public function sendBlockExtraData(int $x, int $y, int $z, int $id, int $data, array $targets = null){ $pk = new LevelEventPacket; $pk->evid = LevelEventPacket::EVENT_SET_DATA; $pk->x = $x + 0.5; @@ -821,7 +790,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $flags * @param bool $optimizeRebuilds */ - public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPacket::FLAG_NONE, $optimizeRebuilds = false){ + public function sendBlocks(array $target, array $blocks, $flags = UpdateBlockPacket::FLAG_NONE, bool $optimizeRebuilds = false){ $pk = new UpdateBlockPacket(); if($optimizeRebuilds){ @@ -862,7 +831,7 @@ class Level implements ChunkManager, Metadatable{ Server::broadcastPacket($target, $pk); } - public function clearCache($full = false){ + public function clearCache(bool $full = false){ if($full){ $this->chunkCache = []; $this->blockCache = []; @@ -879,7 +848,7 @@ class Level implements ChunkManager, Metadatable{ } - public function clearChunkCache($chunkX, $chunkZ){ + public function clearChunkCache(int $chunkX, int $chunkZ){ unset($this->chunkCache[Level::chunkHash($chunkX, $chunkZ)]); } @@ -983,7 +952,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function __debugInfo(){ + public function __debugInfo() : array{ return []; } @@ -992,7 +961,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function save($force = false){ + public function save(bool $force = false){ if(!$this->getAutoSave() and !$force){ return false; @@ -1058,7 +1027,7 @@ class Level implements ChunkManager, Metadatable{ * @param Vector3 $pos * @param int $delay */ - public function scheduleUpdate(Vector3 $pos, $delay){ + public function scheduleUpdate(Vector3 $pos, int $delay){ if(isset($this->updateQueueIndex[$index = Level::blockHash($pos->x, $pos->y, $pos->z)]) and $this->updateQueueIndex[$index] <= $delay){ return; } @@ -1072,7 +1041,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Block[] */ - public function getCollisionBlocks(AxisAlignedBB $bb, $targetFirst = false){ + public function getCollisionBlocks(AxisAlignedBB $bb, bool $targetFirst = false) : array{ $minX = Math::floorFloat($bb->minX); $minY = Math::floorFloat($bb->minY); $minZ = Math::floorFloat($bb->minZ); @@ -1115,7 +1084,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isFullBlock(Vector3 $pos){ + public function isFullBlock(Vector3 $pos) : bool{ if($pos instanceof Block){ if($pos->isSolid()){ return true; @@ -1135,7 +1104,7 @@ class Level implements ChunkManager, Metadatable{ * * @return AxisAlignedBB[] */ - public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb, $entities = true){ + public function getCollisionCubes(Entity $entity, AxisAlignedBB $bb, bool $entities = true) : array{ $minX = Math::floorFloat($bb->minX); $minY = Math::floorFloat($bb->minY); $minZ = Math::floorFloat($bb->minZ); @@ -1237,10 +1206,10 @@ class Level implements ChunkManager, Metadatable{ } */ - public function getFullLight(Vector3 $pos){ + public function getFullLight(Vector3 $pos) : int{ $chunk = $this->getChunk($pos->x >> 4, $pos->z >> 4, false); $level = 0; - if($chunk instanceof FullChunk){ + if($chunk !== null){ $level = $chunk->getBlockSkyLight($pos->x & 0x0f, $pos->y & 0x7f, $pos->z & 0x0f); //TODO: decrease light level by time of day if($level < 15){ @@ -1258,7 +1227,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int bitmap, (id << 4) | data */ - public function getFullBlock($x, $y, $z){ + public function getFullBlock(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, false)->getFullBlock($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -1270,7 +1239,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Block */ - public function getBlock(Vector3 $pos, $cached = true){ + public function getBlock(Vector3 $pos, $cached = true) : Block{ $index = Level::blockHash($pos->x, $pos->y, $pos->z); if($cached and isset($this->blockCache[$index])){ return $this->blockCache[$index]; @@ -1295,11 +1264,11 @@ class Level implements ChunkManager, Metadatable{ $this->updateBlockLight($pos->x, $pos->y, $pos->z); } - public function updateBlockSkyLight($x, $y, $z){ + public function updateBlockSkyLight(int $x, int $y, int $z){ //TODO } - public function updateBlockLight($x, $y, $z){ + public function updateBlockLight(int $x, int $y, int $z){ $lightPropagationQueue = new \SplQueue(); $lightRemovalQueue = new \SplQueue(); $visited = []; @@ -1351,7 +1320,7 @@ class Level implements ChunkManager, Metadatable{ } } - private function computeRemoveBlockLight($x, $y, $z, $currentLight, \SplQueue $queue, \SplQueue $spreadQueue, array &$visited, array &$spreadVisited){ + private function computeRemoveBlockLight(int $x, int $y, int $z, int $currentLight, \SplQueue $queue, \SplQueue $spreadQueue, array &$visited, array &$spreadVisited){ $current = $this->getBlockLightAt($x, $y, $z); if($current !== 0 and $current < $currentLight){ @@ -1371,7 +1340,7 @@ class Level implements ChunkManager, Metadatable{ } } - private function computeSpreadBlockLight($x, $y, $z, $currentLight, \SplQueue $queue, array &$visited){ + private function computeSpreadBlockLight(int $x, int $y, int $z, int $currentLight, \SplQueue $queue, array &$visited){ $current = $this->getBlockLightAt($x, $y, $z); if($current < $currentLight){ @@ -1404,7 +1373,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool Whether the block has been updated or not */ - public function setBlock(Vector3 $pos, Block $block, $direct = false, $update = true){ + public function setBlock(Vector3 $pos, Block $block, bool $direct = false, bool $update = true) : bool{ if($pos->y < 0 or $pos->y >= 128){ return false; } @@ -1460,31 +1429,31 @@ class Level implements ChunkManager, Metadatable{ * @param Vector3 $motion * @param int $delay */ - public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, $delay = 10){ + public function dropItem(Vector3 $source, Item $item, Vector3 $motion = null, int $delay = 10){ $motion = $motion === null ? new Vector3(lcg_value() * 0.2 - 0.1, 0.2, lcg_value() * 0.2 - 0.1) : $motion; $itemTag = NBT::putItemHelper($item); $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(); @@ -1500,9 +1469,9 @@ class Level implements ChunkManager, Metadatable{ * @param Player $player * @param bool $createParticles * - * @return boolean + * @return boole */ - public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null, $createParticles = false){ + public function useBreakOn(Vector3 $vector, Item &$item = null, Player $player = null, bool $createParticles = false) : bool{ $target = $this->getBlock($vector); //TODO: Adventure mode checks @@ -1568,10 +1537,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; @@ -1640,9 +1609,9 @@ class Level implements ChunkManager, Metadatable{ * @param float $fz default 0.0 * @param Player $player default null * - * @return boolean + * @return bool */ - public function useItemOn(Vector3 $vector, Item &$item, $face, $fx = 0.0, $fy = 0.0, $fz = 0.0, Player $player = null){ + public function useItemOn(Vector3 $vector, Item &$item, int $face, float $fx = 0.0, float $fy = 0.0, float $fz = 0.0, Player $player = null) : bool{ $target = $this->getBlock($vector); $block = $target->getSide($face); @@ -1730,10 +1699,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 +1738,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()){ @@ -1805,7 +1774,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity */ - public function getEntity($entityId){ + public function getEntity(int $entityId){ return isset($this->entities[$entityId]) ? $this->entities[$entityId] : null; } @@ -1814,7 +1783,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getEntities(){ + public function getEntities() : array{ return $this->entities; } @@ -1826,7 +1795,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null){ + public function getCollidingEntities(AxisAlignedBB $bb, Entity $entity = null) : array{ $nearby = []; if($entity === null or $entity->canCollide){ @@ -1857,7 +1826,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getNearbyEntities(AxisAlignedBB $bb, Entity $entity = null){ + public function getNearbyEntities(AxisAlignedBB $bb, Entity $entity = null) : array{ $nearby = []; $minX = Math::floorFloat(($bb->minX - 2) / 16); @@ -1883,7 +1852,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Tile[] */ - public function getTiles(){ + public function getTiles() : array{ return $this->tiles; } @@ -1892,7 +1861,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Tile */ - public function getTileById($tileId){ + public function getTileById(int $tileId){ return isset($this->tiles[$tileId]) ? $this->tiles[$tileId] : null; } @@ -1901,14 +1870,14 @@ class Level implements ChunkManager, Metadatable{ * * @return Player[] */ - public function getPlayers(){ + public function getPlayers() : array{ return $this->players; } /** * @return ChunkLoader[] */ - public function getLoaders(){ + public function getLoaders() : array{ return $this->loaders; } @@ -1937,7 +1906,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Entity[] */ - public function getChunkEntities($X, $Z){ + public function getChunkEntities($X, $Z) : array{ return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getEntities() : []; } @@ -1949,7 +1918,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Tile[] */ - public function getChunkTiles($X, $Z){ + public function getChunkTiles($X, $Z) : array{ return ($chunk = $this->getChunk($X, $Z)) !== null ? $chunk->getTiles() : []; } @@ -1962,7 +1931,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-255 */ - public function getBlockIdAt($x, $y, $z){ + public function getBlockIdAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockId($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -1974,7 +1943,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $id 0-255 */ - public function setBlockIdAt($x, $y, $z, $id){ + public function setBlockIdAt(int $x, int $y, int $z, int $id){ unset($this->blockCache[Level::blockHash($x, $y, $z)]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockId($x & 0x0f, $y & 0x7f, $z & 0x0f, $id & 0xff); @@ -1996,7 +1965,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 16-bit */ - public function getBlockExtraDataAt($x, $y, $z){ + public function getBlockExtraDataAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockExtraData($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2009,7 +1978,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $id * @param int $data */ - public function setBlockExtraDataAt($x, $y, $z, $id, $data){ + public function setBlockExtraDataAt(int $x, int $y, int $z, int $id, int $data){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockExtraData($x & 0x0f, $y & 0x7f, $z & 0x0f, ($data << 8) | $id); $this->sendBlockExtraData($x, $y, $z, $id, $data); @@ -2024,7 +1993,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-15 */ - public function getBlockDataAt($x, $y, $z){ + public function getBlockDataAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockData($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2036,7 +2005,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $data 0-15 */ - public function setBlockDataAt($x, $y, $z, $data){ + public function setBlockDataAt(int $x, int $y, int $z, int $data){ unset($this->blockCache[Level::blockHash($x, $y, $z)]); $this->getChunk($x >> 4, $z >> 4, true)->setBlockData($x & 0x0f, $y & 0x7f, $z & 0x0f, $data & 0x0f); @@ -2058,7 +2027,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-15 */ - public function getBlockSkyLightAt($x, $y, $z){ + public function getBlockSkyLightAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockSkyLight($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2070,7 +2039,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $level 0-15 */ - public function setBlockSkyLightAt($x, $y, $z, $level){ + public function setBlockSkyLightAt(int $x, int $y, int $z, int $level){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockSkyLight($x & 0x0f, $y & 0x7f, $z & 0x0f, $level & 0x0f); } @@ -2083,7 +2052,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-15 */ - public function getBlockLightAt($x, $y, $z){ + public function getBlockLightAt(int $x, int $y, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBlockLight($x & 0x0f, $y & 0x7f, $z & 0x0f); } @@ -2095,7 +2064,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $level 0-15 */ - public function setBlockLightAt($x, $y, $z, $level){ + public function setBlockLightAt(int $x, int $y, int $z, int $level){ $this->getChunk($x >> 4, $z >> 4, true)->setBlockLight($x & 0x0f, $y & 0x7f, $z & 0x0f, $level & 0x0f); } @@ -2105,7 +2074,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int */ - public function getBiomeId($x, $z){ + public function getBiomeId(int $x, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getBiomeId($x & 0x0f, $z & 0x0f); } @@ -2115,7 +2084,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int[] */ - public function getBiomeColor($x, $z){ + public function getBiomeColor(int $x, int $z) : array{ return $this->getChunk($x >> 4, $z >> 4, true)->getBiomeColor($x & 0x0f, $z & 0x0f); } @@ -2125,7 +2094,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int */ - public function getHeightMap($x, $z){ + public function getHeightMap(int $x, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getHeightMap($x & 0x0f, $z & 0x0f); } @@ -2134,7 +2103,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $biomeId */ - public function setBiomeId($x, $z, $biomeId){ + public function setBiomeId(int $x, int $z, int $biomeId){ $this->getChunk($x >> 4, $z >> 4, true)->setBiomeId($x & 0x0f, $z & 0x0f, $biomeId); } @@ -2145,7 +2114,7 @@ class Level implements ChunkManager, Metadatable{ * @param int $G * @param int $B */ - public function setBiomeColor($x, $z, $R, $G, $B){ + public function setBiomeColor(int $x, int $z, int $R, int $G, int $B){ $this->getChunk($x >> 4, $z >> 4, true)->setBiomeColor($x & 0x0f, $z & 0x0f, $R, $G, $B); } @@ -2154,14 +2123,14 @@ class Level implements ChunkManager, Metadatable{ * @param int $z * @param int $value */ - public function setHeightMap($x, $z, $value){ + public function setHeightMap(int $x, int $z, int $value){ $this->getChunk($x >> 4, $z >> 4, true)->setHeightMap($x & 0x0f, $z & 0x0f, $value); } /** * @return FullChunk[]|Chunk[] */ - public function getChunks(){ + public function getChunks() : array{ return $this->chunks; } @@ -2174,7 +2143,7 @@ class Level implements ChunkManager, Metadatable{ * * @return FullChunk|Chunk */ - public function getChunk($x, $z, $create = false){ + public function getChunk(int $x, int $z, bool $create = false){ if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){ return $this->chunks[$index]; }elseif($this->loadChunk($x, $z, $create)){ @@ -2184,20 +2153,7 @@ class Level implements ChunkManager, Metadatable{ return null; } - /** - * @param int $x - * @param int $z - * @param bool $create - * - * @return FullChunk|Chunk - * - * @deprecated - */ - public function getChunkAt($x, $z, $create = false){ - return $this->getChunk($x, $z, $create); - } - - public function generateChunkCallback($x, $z, FullChunk $chunk){ + public function generateChunkCallback(int $x, int $z, FullChunk $chunk){ Timings::$generationCallbackTimer->startTiming(); if(isset($this->chunkPopulationQueue[$index = Level::chunkHash($x, $z)])){ $oldChunk = $this->getChunk($x, $z, false); @@ -2235,7 +2191,7 @@ class Level implements ChunkManager, Metadatable{ * @param FullChunk $chunk * @param bool $unload */ - public function setChunk($chunkX, $chunkZ, FullChunk $chunk = null, $unload = true){ + public function setChunk(int $chunkX, int $chunkZ, FullChunk $chunk = null, bool $unload = true){ if($chunk === null){ return; } @@ -2284,7 +2240,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int 0-127 */ - public function getHighestBlockAt($x, $z){ + public function getHighestBlockAt(int $x, int $z) : int{ return $this->getChunk($x >> 4, $z >> 4, true)->getHighestBlockAt($x & 0x0f, $z & 0x0f); } @@ -2294,7 +2250,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkLoaded($x, $z){ + public function isChunkLoaded(int $x, int $z) : bool{ return isset($this->chunks[Level::chunkHash($x, $z)]) or $this->provider->isChunkLoaded($x, $z); } @@ -2304,7 +2260,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkGenerated($x, $z){ + public function isChunkGenerated(int $x, int $z) : bool{ $chunk = $this->getChunk($x, $z); return $chunk !== null ? $chunk->isGenerated() : false; } @@ -2315,7 +2271,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkPopulated($x, $z){ + public function isChunkPopulated(int $x, int $z) : bool{ $chunk = $this->getChunk($x, $z); return $chunk !== null ? $chunk->isPopulated() : false; } @@ -2325,7 +2281,7 @@ class Level implements ChunkManager, Metadatable{ * * @return Position */ - public function getSpawnLocation(){ + public function getSpawnLocation() : Position{ return Position::fromObject($this->provider->getSpawn(), $this); } @@ -2340,7 +2296,7 @@ class Level implements ChunkManager, Metadatable{ $this->server->getPluginManager()->callEvent(new SpawnChangeEvent($this, $previousSpawn)); } - public function requestChunk($x, $z, Player $player){ + public function requestChunk(int $x, int $z, Player $player){ $index = Level::chunkHash($x, $z); if(!isset($this->chunkSendQueue[$index])){ $this->chunkSendQueue[$index] = []; @@ -2349,7 +2305,7 @@ class Level implements ChunkManager, Metadatable{ $this->chunkSendQueue[$index][$player->getLoaderId()] = $player; } - private function sendChunkFromCache($x, $z){ + private function sendChunkFromCache(int $x, int $z){ if(isset($this->chunkSendTasks[$index = Level::chunkHash($x, $z)])){ foreach($this->chunkSendQueue[$index] as $player){ /** @var Player $player */ @@ -2390,7 +2346,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function chunkRequestCallback($x, $z, $payload, $ordering = FullChunkDataPacket::ORDER_COLUMNS){ + public function chunkRequestCallback(int $x, int $z, string $payload, int $ordering = FullChunkDataPacket::ORDER_COLUMNS){ $this->timings->syncChunkSendTimer->startTiming(); $index = Level::chunkHash($x, $z); @@ -2487,7 +2443,7 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isChunkInUse($x, $z){ + public function isChunkInUse(int $x, int $z) : bool{ return isset($this->chunkLoaders[$index = Level::chunkHash($x, $z)]) and count($this->chunkLoaders[$index]) > 0; } @@ -2500,7 +2456,7 @@ class Level implements ChunkManager, Metadatable{ * * @throws \InvalidStateException */ - public function loadChunk($x, $z, $generate = true){ + public function loadChunk(int $x, int $z, bool $generate = true) : bool{ if(isset($this->chunks[$index = Level::chunkHash($x, $z)])){ return true; } @@ -2545,12 +2501,12 @@ class Level implements ChunkManager, Metadatable{ return true; } - private function queueUnloadChunk($x, $z){ + private function queueUnloadChunk(int $x, int $z){ $this->unloadQueue[$index = Level::chunkHash($x, $z)] = microtime(true); unset($this->chunkTickList[$index]); } - public function unloadChunkRequest($x, $z, $safe = true){ + public function unloadChunkRequest(int $x, int $z, bool $safe = true){ if(($safe === true and $this->isChunkInUse($x, $z)) or $this->isSpawnChunk($x, $z)){ return false; } @@ -2560,11 +2516,11 @@ class Level implements ChunkManager, Metadatable{ return true; } - public function cancelUnloadChunkRequest($x, $z){ + public function cancelUnloadChunkRequest(int $x, int $z){ unset($this->unloadQueue[Level::chunkHash($x, $z)]); } - public function unloadChunk($x, $z, $safe = true, $trySave = true){ + public function unloadChunk(int $x, int $z, bool $safe = true, bool $trySave = true) : bool{ if(($safe === true and $this->isChunkInUse($x, $z))){ return false; } @@ -2609,12 +2565,10 @@ class Level implements ChunkManager, Metadatable{ } } $this->provider->unloadChunk($x, $z, $safe); - }catch(\Exception $e){ + }catch(\Throwable $e){ $logger = $this->server->getLogger(); $logger->error($this->server->getLanguage()->translateString("pocketmine.level.chunkUnloadError", [$e->getMessage()])); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + $logger->logException($e); } unset($this->chunks[$index]); @@ -2634,23 +2588,13 @@ class Level implements ChunkManager, Metadatable{ * * @return bool */ - public function isSpawnChunk($X, $Z){ + public function isSpawnChunk(int $X, int $Z) : bool{ $spawnX = $this->provider->getSpawn()->getX() >> 4; $spawnZ = $this->provider->getSpawn()->getZ() >> 4; return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1; } - /** - * Returns the raw spawnpoint - * - * @deprecated - * @return Position - */ - public function getSpawn(){ - return $this->getSpawnLocation(); - } - /** * @param Vector3 $spawn default null * @@ -2704,23 +2648,12 @@ class Level implements ChunkManager, Metadatable{ return false; } - /** - * Sets the spawnpoint - * - * @param Vector3 $pos - * - * @deprecated - */ - public function setSpawn(Vector3 $pos){ - $this->setSpawnLocation($pos); - } - /** * Gets the current time * * @return int */ - public function getTime(){ + public function getTime() : int{ return (int) $this->time; } @@ -2729,7 +2662,7 @@ class Level implements ChunkManager, Metadatable{ * * @return string */ - public function getName(){ + public function getName() : string{ return $this->provider->getName(); } @@ -2738,7 +2671,7 @@ class Level implements ChunkManager, Metadatable{ * * @return string */ - public function getFolderName(){ + public function getFolderName() : string{ return $this->folderName; } @@ -2747,8 +2680,8 @@ class Level implements ChunkManager, Metadatable{ * * @param int $time */ - public function setTime($time){ - $this->time = (int) $time; + public function setTime(int $time){ + $this->time = $time; $this->sendTime(); } @@ -2773,7 +2706,7 @@ class Level implements ChunkManager, Metadatable{ * * @return int */ - public function getSeed(){ + public function getSeed() : int{ return $this->provider->getSeed(); } @@ -2782,12 +2715,12 @@ class Level implements ChunkManager, Metadatable{ * * @param int $seed */ - public function setSeed($seed){ + public function setSeed(int $seed){ $this->provider->setSeed($seed); } - public function populateChunk($x, $z, $force = false){ + public function populateChunk(int $x, int $z, bool $force = false) : bool{ if(isset($this->chunkPopulationQueue[$index = Level::chunkHash($x, $z)]) or (count($this->chunkPopulationQueue) >= $this->chunkPopulationQueueSize and !$force)){ return false; } @@ -2825,7 +2758,7 @@ class Level implements ChunkManager, Metadatable{ return true; } - public function generateChunk($x, $z, $force = false){ + public function generateChunk(int $x, int $z, bool $force = false){ if(count($this->chunkGenerationQueue) >= $this->chunkGenerationQueueSize and !$force){ return; } @@ -2839,7 +2772,7 @@ class Level implements ChunkManager, Metadatable{ } } - public function regenerateChunk($x, $z){ + public function regenerateChunk(int $x, int $z){ $this->unloadChunk($x, $z, false); $this->cancelUnloadChunkRequest($x, $z); @@ -2874,7 +2807,7 @@ class Level implements ChunkManager, Metadatable{ $this->timings->doChunkGC->stopTiming(); } - public function unloadChunks($force = false){ + public function unloadChunks(bool $force = false){ if(count($this->unloadQueue) > 0){ $maxUnload = 96; $now = microtime(true); @@ -2914,14 +2847,14 @@ class Level implements ChunkManager, Metadatable{ $this->server->getLevelMetadata()->removeMetadata($this, $metadataKey, $plugin); } - public function addEntityMotion($chunkX, $chunkZ, $entityId, $x, $y, $z){ + public function addEntityMotion(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z){ if(!isset($this->motionToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){ $this->motionToSend[$index] = []; } $this->motionToSend[$index][$entityId] = [$entityId, $x, $y, $z]; } - public function addEntityMovement($chunkX, $chunkZ, $entityId, $x, $y, $z, $yaw, $pitch, $headYaw = null){ + public function addEntityMovement(int $chunkX, int $chunkZ, int $entityId, float $x, float $y, float $z, float $yaw, float $pitch, $headYaw = null){ if(!isset($this->moveToSend[$index = Level::chunkHash($chunkX, $chunkZ)])){ $this->moveToSend[$index] = []; } diff --git a/src/pocketmine/level/Position.php b/src/pocketmine/level/Position.php index d06061328..d581ab0da 100644 --- a/src/pocketmine/level/Position.php +++ b/src/pocketmine/level/Position.php @@ -67,30 +67,6 @@ class Position extends Vector3{ return $this->level !== null; } - /** - * Marks the level reference as strong so it won't be collected - * by the garbage collector. - * - * @deprecated - * - * @return bool - */ - public function setStrong(){ - return false; - } - - /** - * Marks the level reference as weak so it won't have effect against - * the garbage collector decision. - * - * @deprecated - * - * @return bool - */ - public function setWeak(){ - return false; - } - /** * Returns a side Vector * @@ -102,9 +78,7 @@ class Position extends Vector3{ * @throws LevelException */ public function getSide($side, $step = 1){ - if(!$this->isValid()){ - throw new LevelException("Undefined Level reference"); - } + assert($this->isValid()); return Position::fromObject(parent::getSide($side, $step), $this->level); } diff --git a/src/pocketmine/level/SimpleChunkManager.php b/src/pocketmine/level/SimpleChunkManager.php index bd480e9dd..136ab9ed1 100644 --- a/src/pocketmine/level/SimpleChunkManager.php +++ b/src/pocketmine/level/SimpleChunkManager.php @@ -19,6 +19,8 @@ * */ +declare(strict_types=1); + namespace pocketmine\level; use pocketmine\level\format\FullChunk; @@ -43,7 +45,7 @@ class SimpleChunkManager implements ChunkManager{ * * @return int 0-255 */ - public function getBlockIdAt($x, $y, $z){ + public function getBlockIdAt(int $x, int $y, int $z) : int{ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ return $chunk->getBlockId($x & 0xf, $y & 0x7f, $z & 0xf); } @@ -58,7 +60,7 @@ class SimpleChunkManager implements ChunkManager{ * @param int $z * @param int $id 0-255 */ - public function setBlockIdAt($x, $y, $z, $id){ + public function setBlockIdAt(int $x, int $y, int $z, int $id){ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ $chunk->setBlockId($x & 0xf, $y & 0x7f, $z & 0xf, $id); } @@ -73,7 +75,7 @@ class SimpleChunkManager implements ChunkManager{ * * @return int 0-15 */ - public function getBlockDataAt($x, $y, $z){ + public function getBlockDataAt(int $x, int $y, int $z) : int{ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ return $chunk->getBlockData($x & 0xf, $y & 0x7f, $z & 0xf); } @@ -88,7 +90,7 @@ class SimpleChunkManager implements ChunkManager{ * @param int $z * @param int $data 0-15 */ - public function setBlockDataAt($x, $y, $z, $data){ + public function setBlockDataAt(int $x, int $y, int $z, int $data){ if($chunk = $this->getChunk($x >> 4, $z >> 4)){ $chunk->setBlockData($x & 0xf, $y & 0x7f, $z & 0xf, $data); } @@ -98,9 +100,9 @@ class SimpleChunkManager implements ChunkManager{ * @param int $chunkX * @param int $chunkZ * - * @return FullChunk + * @return FullChunk|null */ - public function getChunk($chunkX, $chunkZ){ + public function getChunk(int $chunkX, int $chunkZ){ return isset($this->chunks[$index = Level::chunkHash($chunkX, $chunkZ)]) ? $this->chunks[$index] : null; } @@ -109,7 +111,7 @@ class SimpleChunkManager implements ChunkManager{ * @param int $chunkZ * @param FullChunk $chunk */ - public function setChunk($chunkX, $chunkZ, FullChunk $chunk = null){ + public function setChunk(int $chunkX, int $chunkZ, FullChunk $chunk = null){ if($chunk === null){ unset($this->chunks[Level::chunkHash($chunkX, $chunkZ)]); return; @@ -126,7 +128,7 @@ class SimpleChunkManager implements ChunkManager{ * * @return int */ - public function getSeed(){ + public function getSeed() : int{ return $this->seed; } } \ No newline at end of file diff --git a/src/pocketmine/level/format/ChunkSection.php b/src/pocketmine/level/format/ChunkSection.php index 9de459921..130032bc0 100644 --- a/src/pocketmine/level/format/ChunkSection.php +++ b/src/pocketmine/level/format/ChunkSection.php @@ -62,19 +62,6 @@ interface ChunkSection{ */ public function setBlockData($x, $y, $z, $data); - /** - * Modifies $blockId and $meta - * - * @deprecated - * - * @param int $x 0-15 - * @param int $y 0-15 - * @param int $z 0-15 - * @param int &$blockId - * @param int &$meta - */ - public function getBlock($x, $y, $z, &$blockId, &$meta = null); - /** * Gets block and meta in one go * diff --git a/src/pocketmine/level/format/FullChunk.php b/src/pocketmine/level/format/FullChunk.php index 783a939ff..d5f3e155a 100644 --- a/src/pocketmine/level/format/FullChunk.php +++ b/src/pocketmine/level/format/FullChunk.php @@ -50,20 +50,6 @@ interface FullChunk{ */ public function setProvider(LevelProvider $provider); - - /** - * Modifies $blockId and $meta - * - * @deprecated - * - * @param int $x 0-15 - * @param int $y 0-127 - * @param int $z 0-15 - * @param int &$blockId - * @param int &$meta - */ - public function getBlock($x, $y, $z, &$blockId, &$meta = null); - /** * Gets block and meta in one go * 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..f7db19a17 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,12 +175,12 @@ 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; } return new Chunk($provider instanceof LevelProvider ? $provider : Anvil::class, $chunk->Level); - }catch(\Exception $e){ + }catch(\Throwable $e){ return null; } } @@ -198,12 +198,12 @@ 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; } return new Chunk($provider instanceof LevelProvider ? $provider : Anvil::class, $chunk->Level); - }catch(\Exception $e){ + }catch(\Throwable $e){ 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,14 +354,14 @@ 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){ + }catch(\Throwable $e){ return null; } } diff --git a/src/pocketmine/level/format/anvil/ChunkSection.php b/src/pocketmine/level/format/anvil/ChunkSection.php index bb42a551d..872fab017 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"]; @@ -70,12 +70,6 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{ } } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->getFullBlock($x, $y, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function getFullBlock($x, $y, $z){ $i = ($y << 8) + ($z << 4) + $x; if(($x & 1) === 0){ diff --git a/src/pocketmine/level/format/generic/BaseChunk.php b/src/pocketmine/level/format/generic/BaseChunk.php index 1b54b1603..25ecfd3ac 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 */ @@ -77,12 +77,6 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{ $this->NBTentities = $entities; } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->sections[$y >> 4]->getFullBlock($x, $y & 0x0f, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function getFullBlock($x, $y, $z){ return $this->sections[$y >> 4]->getFullBlock($x, $y & 0x0f, $z); } diff --git a/src/pocketmine/level/format/generic/BaseFullChunk.php b/src/pocketmine/level/format/generic/BaseFullChunk.php index 4a163eca0..9403656e4 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; @@ -203,15 +203,6 @@ abstract class BaseFullChunk implements FullChunk{ $this->z = $z; } - /** - * @return LevelProvider - * - * @deprecated - */ - public function getLevel(){ - return $this->getProvider(); - } - /** * @return LevelProvider */ 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/Chunk.php b/src/pocketmine/level/format/leveldb/Chunk.php index d4f64d3fe..0e4635091 100644 --- a/src/pocketmine/level/format/leveldb/Chunk.php +++ b/src/pocketmine/level/format/leveldb/Chunk.php @@ -101,12 +101,6 @@ class Chunk extends BaseFullChunk{ } } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->getFullBlock($x, $y, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function setBlock($x, $y, $z, $blockId = null, $meta = null){ $i = ($x << 11) | ($z << 7) | $y; @@ -305,7 +299,7 @@ class Chunk extends BaseFullChunk{ $chunk->setLightPopulated(); } return $chunk; - }catch(\Exception $e){ + }catch(\Throwable $e){ return null; } } @@ -393,7 +387,7 @@ class Chunk extends BaseFullChunk{ $chunk = new Chunk($provider instanceof LevelProvider ? $provider : LevelDB::class, $chunkX, $chunkZ, str_repeat("\x00", self::DATA_LENGTH)); $chunk->skyLight = str_repeat("\xff", 16384); return $chunk; - }catch(\Exception $e){ + }catch(\Throwable $e){ return null; } } 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..b97b30c83 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(); @@ -155,12 +155,6 @@ class Chunk extends BaseFullChunk{ } } - public function getBlock($x, $y, $z, &$blockId, &$meta = null){ - $full = $this->getFullBlock($x, $y, $z); - $blockId = $full >> 4; - $meta = $full & 0x0f; - } - public function setBlock($x, $y, $z, $blockId = null, $meta = null){ $i = ($x << 11) | ($z << 7) | $y; @@ -258,7 +252,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 +267,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 +287,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,12 +304,12 @@ 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; } return new Chunk($provider instanceof LevelProvider ? $provider : McRegion::class, $chunk->Level); - }catch(\Exception $e){ + }catch(\Throwable $e){ return null; } } @@ -348,12 +342,12 @@ 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){ + }catch(\Throwable $e){ return null; } } @@ -374,18 +368,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 +391,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 +401,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 +411,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,14 +448,14 @@ 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){ + }catch(\Throwable $e){ return null; } } 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/level/format/mcregion/RegionLoader.php b/src/pocketmine/level/format/mcregion/RegionLoader.php index c7a528874..c410f7ac5 100644 --- a/src/pocketmine/level/format/mcregion/RegionLoader.php +++ b/src/pocketmine/level/format/mcregion/RegionLoader.php @@ -195,7 +195,7 @@ class RegionLoader{ try{ $chunk = zlib_decode(substr($chunk, 5)); - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->locationTable[$i] = [0, 0, 0]; //Corrupted chunk, remove it continue; } diff --git a/src/pocketmine/level/generator/Generator.php b/src/pocketmine/level/generator/Generator.php index 7d9e12160..2a68ea10a 100644 --- a/src/pocketmine/level/generator/Generator.php +++ b/src/pocketmine/level/generator/Generator.php @@ -123,15 +123,10 @@ abstract class Generator{ * @throws \InvalidArgumentCountException */ public static function getFastNoise2D(Noise $noise, $xSize, $zSize, $samplingRate, $x, $y, $z){ - if($samplingRate === 0){ - throw new \InvalidArgumentException("samplingRate cannot be 0"); - } - if ($xSize % $samplingRate !== 0) { - throw new \InvalidArgumentCountException("xSize % samplingRate must return 0"); - } - if ($zSize % $samplingRate !== 0) { - throw new \InvalidArgumentCountException("zSize % samplingRate must return 0"); - } + assert($samplingRate !== 0, new \InvalidArgumentException("samplingRate cannot be 0")); + + assert($xSize % $samplingRate === 0, new \InvalidArgumentCountException("xSize % samplingRate must return 0")); + assert($zSize % $samplingRate === 0, new \InvalidArgumentCountException("zSize % samplingRate must return 0")); $noiseArray = new \SplFixedArray($xSize + 1); @@ -181,24 +176,14 @@ abstract class Generator{ * @throws \InvalidArgumentCountException */ public static function getFastNoise3D(Noise $noise, $xSize, $ySize, $zSize, $xSamplingRate, $ySamplingRate, $zSamplingRate, $x, $y, $z){ - if($xSamplingRate === 0){ - throw new \InvalidArgumentException("xSamplingRate cannot be 0"); - } - if($zSamplingRate === 0){ - throw new \InvalidArgumentException("zSamplingRate cannot be 0"); - } - if($ySamplingRate === 0){ - throw new \InvalidArgumentException("ySamplingRate cannot be 0"); - } - if ($xSize % $xSamplingRate !== 0) { - throw new \InvalidArgumentCountException("xSize % xSamplingRate must return 0"); - } - if ($zSize % $zSamplingRate !== 0) { - throw new \InvalidArgumentCountException("zSize % zSamplingRate must return 0"); - } - if ($ySize % $ySamplingRate !== 0) { - throw new \InvalidArgumentCountException("ySize % ySamplingRate must return 0"); - } + + assert($xSamplingRate !== 0, new \InvalidArgumentException("xSamplingRate cannot be 0")); + assert($zSamplingRate !== 0, new \InvalidArgumentException("zSamplingRate cannot be 0")); + assert($ySamplingRate !== 0, new \InvalidArgumentException("ySamplingRate cannot be 0")); + + assert($xSize % $xSamplingRate === 0, new \InvalidArgumentCountException("xSize % xSamplingRate must return 0")); + assert($zSize % $zSamplingRate === 0, new \InvalidArgumentCountException("zSize % zSamplingRate must return 0")); + assert($ySize % $ySamplingRate === 0, new \InvalidArgumentCountException("ySize % ySamplingRate must return 0")); $noiseArray = array_fill(0, $xSize + 1, array_fill(0, $zSize + 1, [])); diff --git a/src/pocketmine/level/generator/GeneratorRegisterTask.php b/src/pocketmine/level/generator/GeneratorRegisterTask.php index 38ba77404..1828787d5 100644 --- a/src/pocketmine/level/generator/GeneratorRegisterTask.php +++ b/src/pocketmine/level/generator/GeneratorRegisterTask.php @@ -39,7 +39,7 @@ class GeneratorRegisterTask extends AsyncTask{ public function __construct(Level $level, Generator $generator){ $this->generator = get_class($generator); - $this->settings = $generator->getSettings(); + $this->settings = serialize($generator->getSettings()); $this->seed = $level->getSeed(); $this->levelId = $level->getId(); } @@ -51,7 +51,7 @@ class GeneratorRegisterTask extends AsyncTask{ $this->saveToThreadStore("generation.level{$this->levelId}.manager", $manager); /** @var Generator $generator */ $generator = $this->generator; - $generator = new $generator($this->settings); + $generator = new $generator(unserialize($this->settings)); $generator->init($manager, new Random($manager->getSeed())); $this->saveToThreadStore("generation.level{$this->levelId}.generator", $generator); } diff --git a/src/pocketmine/metadata/MetadataStore.php b/src/pocketmine/metadata/MetadataStore.php index 77e4ef03c..420cfc181 100644 --- a/src/pocketmine/metadata/MetadataStore.php +++ b/src/pocketmine/metadata/MetadataStore.php @@ -29,7 +29,7 @@ use pocketmine\utils\PluginException; abstract class MetadataStore{ /** @var \WeakMap[] */ - private $metadataMap = []; + private $metadataMap; /** * Adds a metadata value to an object. @@ -48,8 +48,8 @@ abstract class MetadataStore{ $key = $this->disambiguate($subject, $metadataKey); if(!isset($this->metadataMap[$key])){ - $entry = new \WeakMap(); - $this->metadataMap[$key] = $entry; + //$entry = new \WeakMap(); + $this->metadataMap[$key] = new \SplObjectStorage();//$entry; }else{ $entry = $this->metadataMap[$key]; } diff --git a/src/pocketmine/metadata/MetadataValue.php b/src/pocketmine/metadata/MetadataValue.php index 866568032..4b927eaaf 100644 --- a/src/pocketmine/metadata/MetadataValue.php +++ b/src/pocketmine/metadata/MetadataValue.php @@ -24,18 +24,18 @@ namespace pocketmine\metadata; use pocketmine\plugin\Plugin; abstract class MetadataValue{ - /** @var \WeakRef */ - protected $owningPlugin; + /** @var Plugin */ + private $owningPlugin; protected function __construct(Plugin $owningPlugin){ - $this->owningPlugin = new \WeakRef($owningPlugin); + $this->owningPlugin = $owningPlugin; } /** * @return Plugin */ public function getOwningPlugin(){ - return $this->owningPlugin->get(); + return $this->owningPlugin; } /** 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 90% rename from src/pocketmine/nbt/tag/Compound.php rename to src/pocketmine/nbt/tag/CompoundTag.php index 654f33aa1..ebef4fadd 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 @@ -62,6 +62,8 @@ class Compound extends NamedTag implements \ArrayAccess{ } } + assert(false, "Offset $offset not found"); + return null; } @@ -88,16 +90,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/network/CompressBatchedTask.php b/src/pocketmine/network/CompressBatchedTask.php index 22a4aaa90..e2e68ca7b 100644 --- a/src/pocketmine/network/CompressBatchedTask.php +++ b/src/pocketmine/network/CompressBatchedTask.php @@ -29,26 +29,24 @@ class CompressBatchedTask extends AsyncTask{ public $level = 7; public $data; public $final; - public $channel = 0; public $targets = []; - public function __construct($data, array $targets, $level = 7, $channel = 0){ + public function __construct($data, array $targets, $level = 7){ $this->data = $data; $this->targets = $targets; $this->level = $level; - $this->channel = $channel; } public function onRun(){ try{ $this->final = zlib_encode($this->data, ZLIB_ENCODING_DEFLATE, $this->level); $this->data = null; - }catch(\Exception $e){ + }catch(\Throwable $e){ } } public function onCompletion(Server $server){ - $server->broadcastPacketsCallback($this->final, $this->targets, $this->channel); + $server->broadcastPacketsCallback($this->final, $this->targets); } } \ No newline at end of file diff --git a/src/pocketmine/network/Network.php b/src/pocketmine/network/Network.php index 49053ea95..6da9a47c0 100644 --- a/src/pocketmine/network/Network.php +++ b/src/pocketmine/network/Network.php @@ -85,25 +85,6 @@ class Network{ public static $BATCH_THRESHOLD = 512; - /** @deprecated */ - const CHANNEL_NONE = 0; - /** @deprecated */ - const CHANNEL_PRIORITY = 1; //Priority channel, only to be used when it matters - /** @deprecated */ - const CHANNEL_WORLD_CHUNKS = 2; //Chunk sending - /** @deprecated */ - const CHANNEL_MOVEMENT = 3; //Movement sending - /** @deprecated */ - const CHANNEL_BLOCKS = 4; //Block updates or explosions - /** @deprecated */ - const CHANNEL_WORLD_EVENTS = 5; //Entity, level or tile entity events - /** @deprecated */ - const CHANNEL_ENTITY_SPAWNING = 6; //Entity spawn/despawn channel - /** @deprecated */ - const CHANNEL_TEXT = 7; //Chat and other text stuff - /** @deprecated */ - const CHANNEL_END = 31; - /** @var \SplFixedArray */ private $packetPool; @@ -158,12 +139,10 @@ class Network{ foreach($this->interfaces as $interface){ try { $interface->process(); - }catch(\Exception $e){ + }catch(\Throwable $e){ $logger = $this->server->getLogger(); if(\pocketmine\DEBUG > 1){ - if($logger instanceof MainLogger){ - $logger->logException($e); - } + $logger->logException($e); } $interface->emergencyShutdown(); @@ -239,12 +218,12 @@ class Network{ $buf = substr($str, $offset, $pkLen); $offset += $pkLen; - if(($pk = $this->getPacket(ord($buf{0}))) !== null){ + if(($pk = $this->getPacket(ord($buf{1}))) !== null){ // #blameshoghi if($pk::NETWORK_ID === Info::BATCH_PACKET){ throw new \InvalidStateException("Invalid BatchPacket inside BatchPacket"); } - $pk->setBuffer($buf, 1); + $pk->setBuffer($buf, 2); // #blameshoghi $pk->decode(); $p->handleDataPacket($pk); @@ -254,13 +233,11 @@ class Network{ } } } - }catch(\Exception $e){ + }catch(\Throwable $e){ if(\pocketmine\DEBUG > 1){ $logger = $this->server->getLogger(); - if($logger instanceof MainLogger){ - $logger->debug("BatchPacket " . " 0x" . bin2hex($packet->payload)); - $logger->logException($e); - } + $logger->debug("BatchPacket " . " 0x" . bin2hex($packet->payload)); + $logger->logException($e); } } } diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index 0a7a55216..de195a44e 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -64,10 +64,6 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $this->rakLib = new RakLibServer($this->server->getLogger(), $this->server->getLoader(), $this->server->getPort(), $this->server->getIp() === "" ? "0.0.0.0" : $this->server->getIp()); $this->interface = new ServerHandler($this->rakLib, $this); - - for($i = 0; $i < 256; ++$i){ - $this->channelCounts[$i] = 0; - } } public function setNetwork(Network $network){ @@ -83,9 +79,9 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } if($this->rakLib->isTerminated()){ - $info = $this->rakLib->getTerminationInfo(); $this->network->unregisterInterface($this); - \ExceptionHandler::handler(E_ERROR, "RakLib Thread crashed [".$info["scope"]."]: " . (isset($info["message"]) ? $info["message"] : ""), $info["file"], $info["line"]); + + throw new \Exception("RakLib Thread crashed"); } return $work; @@ -140,13 +136,11 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ $this->players[$identifier]->handleDataPacket($pk); } } - }catch(\Exception $e){ + }catch(\Throwable $e){ if(\pocketmine\DEBUG > 1 and isset($pk)){ $logger = $this->server->getLogger(); - if($logger instanceof MainLogger){ - $logger->debug("Packet " . get_class($pk) . " 0x" . bin2hex($packet->buffer)); - $logger->logException($e); - } + $logger->debug("Packet " . get_class($pk) . " 0x" . bin2hex($packet->buffer)); + $logger->logException($e); } if(isset($this->players[$identifier])){ @@ -205,14 +199,9 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ if(!isset($packet->__encapsulatedPacket)){ $packet->__encapsulatedPacket = new CachedEncapsulatedPacket; $packet->__encapsulatedPacket->identifierACK = null; - $packet->__encapsulatedPacket->buffer = $packet->buffer; - if($packet->getChannel() !== 0){ - $packet->__encapsulatedPacket->reliability = 3; - $packet->__encapsulatedPacket->orderChannel = $packet->getChannel(); - $packet->__encapsulatedPacket->orderIndex = 0; - }else{ - $packet->__encapsulatedPacket->reliability = 2; - } + $packet->__encapsulatedPacket->buffer = chr(0x8e) . $packet->buffer; // #blameshoghi + $packet->__encapsulatedPacket->reliability = 3; + $packet->__encapsulatedPacket->orderChannel = 0; } $pk = $packet->__encapsulatedPacket; } @@ -220,20 +209,15 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ if(!$immediate and !$needACK and $packet::NETWORK_ID !== ProtocolInfo::BATCH_PACKET and Network::$BATCH_THRESHOLD >= 0 and strlen($packet->buffer) >= Network::$BATCH_THRESHOLD){ - $this->server->batchPackets([$player], [$packet], true, $packet->getChannel()); + $this->server->batchPackets([$player], [$packet], true); return null; } if($pk === null){ $pk = new EncapsulatedPacket(); - $pk->buffer = $packet->buffer; - if($packet->getChannel() !== 0){ - $packet->reliability = 3; - $packet->orderChannel = $packet->getChannel(); - $packet->orderIndex = 0; - }else{ - $packet->reliability = 2; - } + $pk->buffer = chr(0x8e) . $packet->buffer; // #blameshoghi + $packet->reliability = 3; + $packet->orderChannel = 0; if($needACK === true){ $pk->identifierACK = $this->identifiersACK[$identifier]++; @@ -249,12 +233,12 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ } private function getPacket($buffer){ - $pid = ord($buffer{0}); + $pid = ord($buffer{1}); // #blameshoghi if(($data = $this->network->getPacket($pid)) === null){ return null; } - $data->setBuffer($buffer, 1); + $data->setBuffer($buffer, 2); // #blameshoghi return $data; } diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index b71aa84a3..ef1e841d3 100644 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -37,7 +37,6 @@ abstract class DataPacket extends BinaryStream{ const NETWORK_ID = 0; public $isEncoded = false; - private $channel = 0; public function pid(){ return $this::NETWORK_ID; @@ -52,18 +51,6 @@ abstract class DataPacket extends BinaryStream{ $this->offset = 0; } - /** - * @deprecated This adds extra overhead on the network, so its usage is now discouraged. It was a test for the viability of this. - */ - public function setChannel($channel){ - $this->channel = (int) $channel; - return $this; - } - - public function getChannel(){ - return $this->channel; - } - public function clean(){ $this->buffer = null; $this->isEncoded = false; diff --git a/src/pocketmine/network/protocol/Info.php b/src/pocketmine/network/protocol/Info.php index 9b34b39b3..751b867bb 100644 --- a/src/pocketmine/network/protocol/Info.php +++ b/src/pocketmine/network/protocol/Info.php @@ -30,7 +30,7 @@ interface Info{ /** * Actual Minecraft: PE protocol version */ - const CURRENT_PROTOCOL = 39; + const CURRENT_PROTOCOL = 45; const LOGIN_PACKET = 0x8f; const PLAY_STATUS_PACKET = 0x90; @@ -79,14 +79,20 @@ interface Info{ const CRAFTING_EVENT_PACKET = 0xbb; const ADVENTURE_SETTINGS_PACKET = 0xbc; const BLOCK_ENTITY_DATA_PACKET = 0xbd; - //const PLAYER_INPUT_PACKET = 0xbe; + // const PLAYER_INPUT_PACKET = 0xbe; const FULL_CHUNK_DATA_PACKET = 0xbf; const SET_DIFFICULTY_PACKET = 0xc0; - //const CHANGE_DIMENSION_PACKET = 0xc1; + // const CHANGE_DIMENSION_PACKET = 0xc1; const SET_PLAYER_GAMETYPE_PACKET = 0xc2; const PLAYER_LIST_PACKET = 0xc3; - //const TELEMETRY_EVENT_PACKET = 0xc4; - //const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5 + // const TELEMETRY_EVENT_PACKET = 0xc4; + // const SPAWN_EXPERIENCE_ORB_PACKET = 0xc5 + // const CLIENTBOUND_MAP_ITEM_DATA_PACKET = 0xc6; + // const MAP_INFO_REQUEST_PACKET = 0xc7; + // const REQUEST_CHUNK_RADIUS_PACKET = 0xc8; + // const CHUNK_RADIUS_UPDATE_PACKET = 0xc9; + // const ITEM_FRAME_DROP_ITEM_PACKET = 0xca; + // const REPLACE_SELECTED_ITEM_PACKET = 0xcb; } diff --git a/src/pocketmine/network/rcon/RCON.php b/src/pocketmine/network/rcon/RCON.php index 455d018d0..50347b093 100644 --- a/src/pocketmine/network/rcon/RCON.php +++ b/src/pocketmine/network/rcon/RCON.php @@ -70,7 +70,7 @@ class RCON{ public function stop(){ for($n = 0; $n < $this->threads; ++$n){ $this->workers[$n]->close(); - usleep(50000); + Server::microSleep(50000); $this->workers[$n]->kill(); } @socket_close($this->socket); diff --git a/src/pocketmine/network/rcon/RCONInstance.php b/src/pocketmine/network/rcon/RCONInstance.php index 92d289647..64e1009a3 100644 --- a/src/pocketmine/network/rcon/RCONInstance.php +++ b/src/pocketmine/network/rcon/RCONInstance.php @@ -31,6 +31,11 @@ class RCONInstance extends Thread{ private $socket; private $password; private $maxClients; + private $waiting; + + public function isWaiting(){ + return $this->waiting === true; + } public function __construct($socket, $password, $maxClients = 50){ @@ -85,7 +90,9 @@ class RCONInstance extends Thread{ public function run(){ while($this->stop !== true){ - usleep(2000); + $this->synchronized(function(){ + $this->wait(2000); + }); $r = [$socket = $this->socket]; $w = null; $e = null; @@ -135,8 +142,10 @@ class RCONInstance extends Thread{ socket_getpeername($client, $addr, $port); $this->response = "[INFO] Successful Rcon connection from: /$addr:$port"; $this->synchronized(function (){ + $this->waiting = true; $this->wait(); }); + $this->waiting = false; $this->response = ""; $this->writePacket($client, $requestID, 2, ""); $this->{"status" . $n} = 1; @@ -154,15 +163,17 @@ class RCONInstance extends Thread{ if(strlen($payload) > 0){ $this->cmd = ltrim($payload); $this->synchronized(function (){ + $this->waiting = true; $this->wait(); }); + $this->waiting = false; $this->writePacket($client, $requestID, 0, str_replace("\n", "\r\n", trim($this->response))); $this->response = ""; $this->cmd = ""; } break; } - usleep(1); + }else{ @socket_set_option($client, SOL_SOCKET, SO_LINGER, ["l_onoff" => 1, "l_linger" => 1]); @socket_shutdown($client, 2); diff --git a/src/pocketmine/network/upnp/UPnP.php b/src/pocketmine/network/upnp/UPnP.php index e9b116dc2..e4ea65792 100644 --- a/src/pocketmine/network/upnp/UPnP.php +++ b/src/pocketmine/network/upnp/UPnP.php @@ -42,7 +42,7 @@ abstract class UPnP{ return false; } $com->StaticPortMappingCollection->Add($port, "UDP", $port, $myLocalIP, true, "PocketMine-MP"); - }catch(\Exception $e){ + }catch(\Throwable $e){ return false; } @@ -63,7 +63,7 @@ abstract class UPnP{ return false; } $com->StaticPortMappingCollection->Remove($port, "UDP"); - }catch(\Exception $e){ + }catch(\Throwable $e){ return false; } diff --git a/src/pocketmine/plugin/PluginLogger.php b/src/pocketmine/plugin/PluginLogger.php index 1a1dc5457..12cf47dfc 100644 --- a/src/pocketmine/plugin/PluginLogger.php +++ b/src/pocketmine/plugin/PluginLogger.php @@ -87,10 +87,14 @@ class PluginLogger implements \AttachableLogger{ $this->log(LogLevel::DEBUG, $message); } + public function logException(\Throwable $e, $trace = null){ + Server::getInstance()->getLogger()->logException($e, $trace); + } + public function log($level, $message){ Server::getInstance()->getLogger()->log($level, $this->pluginName . $message); foreach($this->attachments as $attachment){ $attachment->log($level, $message); } } -} \ No newline at end of file +} diff --git a/src/pocketmine/plugin/PluginManager.php b/src/pocketmine/plugin/PluginManager.php index 3a09bc0c5..eb15baf54 100644 --- a/src/pocketmine/plugin/PluginManager.php +++ b/src/pocketmine/plugin/PluginManager.php @@ -249,12 +249,9 @@ class PluginManager{ } } } - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->server->getLogger()->error($this->server->getLanguage()->translateString("pocketmine.plugin.fileError", [$file, $directory, $e->getMessage()])); - $logger = $this->server->getLogger(); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + $this->server->getLogger()->logException($e); } } } @@ -433,7 +430,7 @@ class PluginManager{ if(!isset($this->permSubs[$permission])){ $this->permSubs[$permission] = []; } - $this->permSubs[$permission][spl_object_hash($permissible)] = new \WeakRef($permissible); + $this->permSubs[$permission][spl_object_hash($permissible)] = $permissible; } /** @@ -456,6 +453,7 @@ class PluginManager{ */ public function getPermissionSubscriptions($permission){ if(isset($this->permSubs[$permission])){ + return $this->permSubs[$permission]; $subs = []; foreach($this->permSubs[$permission] as $k => $perm){ /** @var \WeakRef $perm */ @@ -479,9 +477,9 @@ class PluginManager{ */ public function subscribeToDefaultPerms($op, Permissible $permissible){ if($op === true){ - $this->defSubsOp[spl_object_hash($permissible)] = new \WeakRef($permissible); + $this->defSubsOp[spl_object_hash($permissible)] = $permissible; }else{ - $this->defSubs[spl_object_hash($permissible)] = new \WeakRef($permissible); + $this->defSubs[spl_object_hash($permissible)] = $permissible; } } @@ -506,6 +504,7 @@ class PluginManager{ $subs = []; if($op === true){ + return $this->defSubsOp; foreach($this->defSubsOp as $k => $perm){ /** @var \WeakRef $perm */ if($perm->acquire()){ @@ -516,6 +515,7 @@ class PluginManager{ } } }else{ + return $this->defSubs; foreach($this->defSubs as $k => $perm){ /** @var \WeakRef $perm */ if($perm->acquire()){ @@ -560,11 +560,8 @@ class PluginManager{ $this->addPermission($perm); } $plugin->getPluginLoader()->enablePlugin($plugin); - }catch(\Exception $e){ - $logger = Server::getInstance()->getLogger(); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + }catch(\Throwable $e){ + $this->server->getLogger()->logException($e); $this->disablePlugin($plugin); } } @@ -634,11 +631,8 @@ class PluginManager{ if($plugin->isEnabled()){ try{ $plugin->getPluginLoader()->disablePlugin($plugin); - }catch(\Exception $e){ - $logger = Server::getInstance()->getLogger(); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + }catch(\Throwable $e){ + $this->server->getLogger()->logException($e); } $this->server->getScheduler()->cancelTasks($plugin); @@ -671,7 +665,7 @@ class PluginManager{ try{ $registration->callEvent($event); - }catch(\Exception $e){ + }catch(\Throwable $e){ $this->server->getLogger()->critical( $this->server->getLanguage()->translateString("pocketmine.plugin.eventError", [ $event->getEventName(), @@ -679,10 +673,7 @@ class PluginManager{ $e->getMessage(), get_class($registration->getListener()) ])); - $logger = $this->server->getLogger(); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + $this->server->getLogger()->logException($e); } } } diff --git a/src/pocketmine/resources/creativeitems.json b/src/pocketmine/resources/creativeitems.json new file mode 100644 index 000000000..d8f03caf0 --- /dev/null +++ b/src/pocketmine/resources/creativeitems.json @@ -0,0 +1 @@ +{ "Cobblestone":{"ID":4,"Damage":0}, "Stone Bricks":{"ID":98,"Damage":0}, "Mossy Stone Bricks":{"ID":98,"Damage":1}, "Cracked Stone Bricks":{"ID":98,"Damage":2}, "Chiseled Stone Bricks":{"ID":98,"Damage":3}, "Moss Stone":{"ID":48,"Damage":0}, "Oak Wood Planks":{"ID":5,"Damage":0}, "Spruce Wood Planks":{"ID":5,"Damage":1}, "Birch Wood Planks":{"ID":5,"Damage":2}, "Jungle Wood Planks":{"ID":5,"Damage":3}, "Acacia Wood Planks":{"ID":5,"Damage":4}, "Dark Oak Wood Planks":{"ID":5,"Damage":5}, "Bricks":{"ID":45,"Damage":0}, "Stone":{"ID":1,"Damage":0}, "Granite":{"ID":1,"Damage":1}, "Polished Granite":{"ID":1,"Damage":2}, "Diorite":{"ID":1,"Damage":3}, "Polished Diorite":{"ID":1,"Damage":4}, "Andesite":{"ID":1,"Damage":5}, "Polished Andesite":{"ID":1,"Damage":6}, "Dirt":{"ID":3,"Damage":0}, "Podzol":{"ID":243,"Damage":0}, "Grass":{"ID":2,"Damage":0}, "Mycelium":{"ID":110,"Damage":0}, "Clay Block":{"ID":82,"Damage":0}, "Hardened Clay":{"ID":172,"Damage":0}, "White Stained Clay":{"ID":159,"Damage":0}, "Orange Stained Clay":{"ID":159,"Damage":1}, "Magenta Stained Clay":{"ID":159,"Damage":2}, "Light Blue Stained Clay":{"ID":159,"Damage":3}, "Yellow Stained Clay":{"ID":159,"Damage":4}, "Lime Stained Clay":{"ID":159,"Damage":5}, "Pink Stained Clay":{"ID":159,"Damage":6}, "Gray Stained Clay":{"ID":159,"Damage":7}, "Light Gray Stained Clay":{"ID":159,"Damage":8}, "Cyan Stained Clay":{"ID":159,"Damage":9}, "Purple Stained Clay":{"ID":159,"Damage":10}, "Blue Stained Clay":{"ID":159,"Damage":11}, "Brown Stained Clay":{"ID":159,"Damage":12}, "Green Stained Clay":{"ID":159,"Damage":13}, "Red Stained Clay":{"ID":159,"Damage":14}, "Black Stained Clay":{"ID":159,"Damage":15}, "Sandstone":{"ID":24,"Damage":0}, "Chiseled Sandstone":{"ID":24,"Damage":1}, "Smooth Sandstone":{"ID":24,"Damage":2}, "Sand":{"ID":12,"Damage":0}, "Red Sand":{"ID":12,"Damage":1}, "Gravel":{"ID":13,"Damage":0}, "Oak Wood":{"ID":17,"Damage":0}, "Spruce Wood":{"ID":17,"Damage":1}, "Birch Wood":{"ID":17,"Damage":2}, "Jungle Wood":{"ID":17,"Damage":3}, "Acacia Wood":{"ID":162,"Damage":0}, "Dark Oak Wood":{"ID":162,"Damage":1}, "Nether Bricks":{"ID":112,"Damage":0}, "Netherrack":{"ID":87,"Damage":0}, "Soul Sand":{"ID":88,"Damage":0}, "Bedrock":{"ID":7,"Damage":0}, "Cobblestone Stairs":{"ID":67,"Damage":0}, "Wood Stairs":{"ID":53,"Damage":0}, "Spruce Wood Stairs":{"ID":134,"Damage":0}, "Birch Wood Stairs":{"ID":135,"Damage":0}, "Jungle Wood Stairs":{"ID":136,"Damage":0}, "Acacia Wood Stairs":{"ID":163,"Damage":0}, "Dark Oak Wood Stairs":{"ID":164,"Damage":0}, "Brick Stairs":{"ID":108,"Damage":0}, "Sandstone Stairs":{"ID":128,"Damage":0}, "Stone Brick Stairs":{"ID":109,"Damage":0}, "Nether Bricks Stairs":{"ID":114,"Damage":0}, "Quartz Stairs":{"ID":156,"Damage":0}, "Stone Slab":{"ID":44,"Damage":0}, "Sandstone Slab":{"ID":44,"Damage":1}, "Oak Wooden Slab":{"ID":158,"Damage":0}, "Spruce Wooden Slab":{"ID":158,"Damage":1}, "Birch Wooden Slab":{"ID":158,"Damage":2}, "Jungle Wooden Slab":{"ID":158,"Damage":3}, "Acacia Wooden Slab":{"ID":158,"Damage":4}, "Dark Oak Wooden Slab":{"ID":158,"Damage":5}, "Cobblestone Slab":{"ID":44,"Damage":3}, "Brick Slab":{"ID":44,"Damage":4}, "Stone Brick Slab":{"ID":44,"Damage":5}, "Quartz Slab":{"ID":44,"Damage":6}, "Nether Brick Slab":{"ID":44,"Damage":7}, "Quartz Block":{"ID":155,"Damage":0}, "Chiseled Quartz Block":{"ID":155,"Damage":1}, "Quartz Pillar":{"ID":155,"Damage":2}, "Coal Ore":{"ID":16,"Damage":0}, "Iron Ore":{"ID":15,"Damage":0}, "Gold Ore":{"ID":14,"Damage":0}, "Diamond Ore":{"ID":56,"Damage":0}, "Lapis Lazuli Ore":{"ID":21,"Damage":0}, "Redstone Ore":{"ID":73,"Damage":0}, "Emerald Ore":{"ID":129,"Damage":0}, "Obsidian":{"ID":49,"Damage":0}, "Ice":{"ID":79,"Damage":0}, "Packed Ice":{"ID":174,"Damage":0}, "Snow Block":{"ID":80,"Damage":0}, "EndTag Stone":{"ID":121,"Damage":0}, "Cobblestone Wall":{"ID":139,"Damage":0}, "Mossy Cobblestone Wall":{"ID":139,"Damage":1}, "Lily Pad":{"ID":111,"Damage":0}, "Gold Block":{"ID":41,"Damage":0}, "Iron Block":{"ID":42,"Damage":0}, "Diamond Block":{"ID":57,"Damage":0}, "Lapis Lazuli Block":{"ID":22,"Damage":0}, "Coal Block":{"ID":173,"Damage":0}, "Emerald Block":{"ID":133,"Damage":0}, "Redstone Block":{"ID":152,"Damage":0}, "Snow Layer":{"ID":78,"Damage":0}, "Glass":{"ID":20,"Damage":0}, "Glowstone":{"ID":89,"Damage":0}, "Vines":{"ID":106,"Damage":0}, "Ladder":{"ID":65,"Damage":0}, "Sponge":{"ID":19,"Damage":0}, "Glass Pane":{"ID":102,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Iron Door":{"ID":330,"Damage":0}, "Wooden Trapdoor":{"ID":96,"Damage":0}, "Iron Trapdoor":{"ID":167,"Damage":0}, "Oak Fence":{"ID":85,"Damage":0}, "Spruce Fence":{"ID":85,"Damage":1}, "Birch Fence":{"ID":85,"Damage":2}, "Jungle Fence":{"ID":85,"Damage":3}, "Acacia Fence":{"ID":85,"Damage":4}, "Dark Oak Fence":{"ID":85,"Damage":5}, "Nether Brick Fence":{"ID":113,"Damage":0}, "Oak Fence Gate":{"ID":107,"Damage":0}, "Spruce Fence Gate":{"ID":183,"Damage":0}, "Birch Fence Gate":{"ID":184,"Damage":0}, "Jungle Fence Gate":{"ID":185,"Damage":0}, "Acacia Fence Gate":{"ID":187,"Damage":0}, "Dark Oak Fence Gate":{"ID":186,"Damage":0}, "Iron Bars":{"ID":101,"Damage":0}, "Bed":{"ID":355,"Damage":0}, "Bookshelf":{"ID":47,"Damage":0}, "Painting":{"ID":321,"Damage":0}, "Crafting Table":{"ID":58,"Damage":0}, "Stonecutter":{"ID":245,"Damage":0}, "Chest":{"ID":54,"Damage":0}, "Chest":{"ID":54,"Damage":0}, "Furnace":{"ID":61,"Damage":0}, "Brewing Stand":{"ID":379,"Damage":0}, "EndTag Portal Frame":{"ID":120,"Damage":0}, "Anvil":{"ID":145,"Damage":0}, "Anvil":{"ID":145,"Damage":4}, "Anvil":{"ID":145,"Damage":8}, "Dandelion":{"ID":37,"Damage":0}, "Poppy":{"ID":38,"Damage":0}, "Blue Orchid":{"ID":38,"Damage":1}, "Allium":{"ID":38,"Damage":2}, "Azure Bluet":{"ID":38,"Damage":3}, "Red Tulip":{"ID":38,"Damage":4}, "Orange Tulip":{"ID":38,"Damage":5}, "White Tulip":{"ID":38,"Damage":6}, "Pink Tulip":{"ID":38,"Damage":7}, "Oxeye Daisy":{"ID":38,"Damage":8}, "Brown Mushroom":{"ID":39,"Damage":0}, "Red Mushroom":{"ID":40,"Damage":0}, "Cactus":{"ID":81,"Damage":0}, "Melon Block":{"ID":103,"Damage":0}, "Pumpkin":{"ID":86,"Damage":0}, "Jack o'Lantern":{"ID":91,"Damage":0}, "Cobweb":{"ID":30,"Damage":0}, "Hay Bale":{"ID":170,"Damage":0}, "Tall Grass":{"ID":31,"Damage":1}, "Fern":{"ID":31,"Damage":2}, "Dead Bush":{"ID":32,"Damage":0}, "Oak Sapling":{"ID":6,"Damage":0}, "Spruce Sapling":{"ID":6,"Damage":1}, "Birch Sapling":{"ID":6,"Damage":2}, "Jungle Sapling":{"ID":6,"Damage":3}, "Acacia Sapling":{"ID":6,"Damage":4}, "Dark Oak Sapling":{"ID":6,"Damage":5}, "Oak Leaves":{"ID":18,"Damage":0}, "Spruce Leaves":{"ID":18,"Damage":1}, "Birch Leaves":{"ID":18,"Damage":2}, "Jungle Leaves":{"ID":18,"Damage":3}, "Acacia Leaves":{"ID":161,"Damage":0}, "Dark Oak Leaves":{"ID":161,"Damage":1}, "Cake":{"ID":354,"Damage":0}, "Sign":{"ID":323,"Damage":0}, "Flower Pot":{"ID":390,"Damage":0}, "Monster Spawner":{"ID":52,"Damage":0}, "Enchanting Table":{"ID":116,"Damage":0}, "White Wool":{"ID":35,"Damage":0}, "Gray Wool":{"ID":35,"Damage":7}, "Pink Wool":{"ID":35,"Damage":6}, "Lime Wool":{"ID":35,"Damage":5}, "Yellow Wool":{"ID":35,"Damage":4}, "Light Blue Wool":{"ID":35,"Damage":3}, "Magenta Wool":{"ID":35,"Damage":2}, "Orange Wool":{"ID":35,"Damage":1}, "Black Wool":{"ID":35,"Damage":15}, "Red Wool":{"ID":35,"Damage":14}, "Green Wool":{"ID":35,"Damage":13}, "Brown Wool":{"ID":35,"Damage":12}, "Blue Wool":{"ID":35,"Damage":11}, "Purple Wool":{"ID":35,"Damage":10}, "Cyan Wool":{"ID":35,"Damage":9}, "Light Gray Wool":{"ID":35,"Damage":8}, "White Carpet":{"ID":171,"Damage":0}, "Gray Carpet":{"ID":171,"Damage":7}, "Pink Carpet":{"ID":171,"Damage":6}, "Lime Carpet":{"ID":171,"Damage":5}, "Yellow Carpet":{"ID":171,"Damage":4}, "Light Blue Carpet":{"ID":171,"Damage":3}, "Magenta Carpet":{"ID":171,"Damage":2}, "Orange Carpet":{"ID":171,"Damage":1}, "Black Carpet":{"ID":171,"Damage":15}, "Red Carpet":{"ID":171,"Damage":14}, "Green Carpet":{"ID":171,"Damage":13}, "Brown Carpet":{"ID":171,"Damage":12}, "Blue Carpet":{"ID":171,"Damage":11}, "Purple Carpet":{"ID":171,"Damage":10}, "Cyan Carpet":{"ID":171,"Damage":9}, "Light Gray Carpet":{"ID":171,"Damage":8}, "Cobblestone Wall":{"ID":139,"Damage":0}, "Mossy Cobblestone Wall":{"ID":139,"Damage":1}, "Lily Pad":{"ID":111,"Damage":0}, "Gold Block":{"ID":41,"Damage":0}, "Iron Block":{"ID":42,"Damage":0}, "Diamond Block":{"ID":57,"Damage":0}, "Lapis Lazuli Block":{"ID":22,"Damage":0}, "Coal Block":{"ID":173,"Damage":0}, "Emerald Block":{"ID":133,"Damage":0}, "Redstone Block":{"ID":152,"Damage":0}, "Snow Layer":{"ID":78,"Damage":0}, "Glass":{"ID":20,"Damage":0}, "Glowstone":{"ID":89,"Damage":0}, "Vines":{"ID":106,"Damage":0}, "Ladder":{"ID":65,"Damage":0}, "Sponge":{"ID":19,"Damage":0}, "Glass Pane":{"ID":102,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Wooden Door":{"ID":324,"Damage":0}, "Iron Door":{"ID":330,"Damage":0}, "Wooden Trapdoor":{"ID":96,"Damage":0}, "Iron Trapdoor":{"ID":167,"Damage":0}, "Oak Fence":{"ID":85,"Damage":0}, "Spruce Fence":{"ID":85,"Damage":1}, "Birch Fence":{"ID":85,"Damage":2}, "Jungle Fence":{"ID":85,"Damage":3}, "Acacia Fence":{"ID":85,"Damage":4}, "Dark Oak Fence":{"ID":85,"Damage":5}, "Nether Brick Fence":{"ID":113,"Damage":0}, "Oak Fence Gate":{"ID":107,"Damage":0}, "Spruce Fence Gate":{"ID":183,"Damage":0}, "Birch Fence Gate":{"ID":184,"Damage":0}, "Jungle Fence Gate":{"ID":185,"Damage":0}, "Acacia Fence Gate":{"ID":187,"Damage":0}, "Dark Oak Fence Gate":{"ID":186,"Damage":0}, "Iron Bars":{"ID":101,"Damage":0}, "Bed":{"ID":355,"Damage":0}, "Bookshelf":{"ID":47,"Damage":0}, "Painting":{"ID":321,"Damage":0}, "Crafting Table":{"ID":58,"Damage":0}, "Stonecutter":{"ID":245,"Damage":0}, "Chest":{"ID":54,"Damage":0}, "Chest":{"ID":54,"Damage":0}, "Furnace":{"ID":61,"Damage":0}, "Brewing Stand":{"ID":379,"Damage":0}, "EndTag Portal Frame":{"ID":120,"Damage":0}, "Anvil":{"ID":145,"Damage":0}, "Anvil":{"ID":145,"Damage":4}, "Anvil":{"ID":145,"Damage":8}, "Dandelion":{"ID":37,"Damage":0}, "Poppy":{"ID":38,"Damage":0}, "Blue Orchid":{"ID":38,"Damage":1}, "Allium":{"ID":38,"Damage":2}, "Azure Bluet":{"ID":38,"Damage":3}, "Red Tulip":{"ID":38,"Damage":4}, "Orange Tulip":{"ID":38,"Damage":5}, "White Tulip":{"ID":38,"Damage":6}, "Pink Tulip":{"ID":38,"Damage":7}, "Oxeye Daisy":{"ID":38,"Damage":8}, "Brown Mushroom":{"ID":39,"Damage":0}, "Red Mushroom":{"ID":40,"Damage":0}, "Cactus":{"ID":81,"Damage":0}, "Melon Block":{"ID":103,"Damage":0}, "Pumpkin":{"ID":86,"Damage":0}, "Jack o'Lantern":{"ID":91,"Damage":0}, "Cobweb":{"ID":30,"Damage":0}, "Hay Bale":{"ID":170,"Damage":0}, "Tall Grass":{"ID":31,"Damage":1}, "Fern":{"ID":31,"Damage":2}, "Dead Bush":{"ID":32,"Damage":0}, "Oak Sapling":{"ID":6,"Damage":0}, "Spruce Sapling":{"ID":6,"Damage":1}, "Birch Sapling":{"ID":6,"Damage":2}, "Jungle Sapling":{"ID":6,"Damage":3}, "Acacia Sapling":{"ID":6,"Damage":4}, "Dark Oak Sapling":{"ID":6,"Damage":5}, "Oak Leaves":{"ID":18,"Damage":0}, "Spruce Leaves":{"ID":18,"Damage":1}, "Birch Leaves":{"ID":18,"Damage":2}, "Jungle Leaves":{"ID":18,"Damage":3}, "Acacia Leaves":{"ID":161,"Damage":0}, "Dark Oak Leaves":{"ID":161,"Damage":1}, "Cake":{"ID":354,"Damage":0}, "Sign":{"ID":323,"Damage":0}, "Flower Pot":{"ID":390,"Damage":0}, "Monster Spawner":{"ID":52,"Damage":0}, "Enchanting Table":{"ID":116,"Damage":0}, "White Wool":{"ID":35,"Damage":0}, "Gray Wool":{"ID":35,"Damage":7}, "Pink Wool":{"ID":35,"Damage":6}, "Lime Wool":{"ID":35,"Damage":5}, "Yellow Wool":{"ID":35,"Damage":4}, "Light Blue Wool":{"ID":35,"Damage":3}, "Magenta Wool":{"ID":35,"Damage":2}, "Orange Wool":{"ID":35,"Damage":1}, "Black Wool":{"ID":35,"Damage":15}, "Red Wool":{"ID":35,"Damage":14}, "Green Wool":{"ID":35,"Damage":13}, "Brown Wool":{"ID":35,"Damage":12}, "Blue Wool":{"ID":35,"Damage":11}, "Purple Wool":{"ID":35,"Damage":10}, "Cyan Wool":{"ID":35,"Damage":9}, "Light Gray Wool":{"ID":35,"Damage":8}, "White Carpet":{"ID":171,"Damage":0}, "Gray Carpet":{"ID":171,"Damage":7}, "Pink Carpet":{"ID":171,"Damage":6}, "Lime Carpet":{"ID":171,"Damage":5}, "Yellow Carpet":{"ID":171,"Damage":4}, "Light Blue Carpet":{"ID":171,"Damage":3}, "Magenta Carpet":{"ID":171,"Damage":2}, "Orange Carpet":{"ID":171,"Damage":1}, "Black Carpet":{"ID":171,"Damage":15}, "Red Carpet":{"ID":171,"Damage":14}, "Green Carpet":{"ID":171,"Damage":13}, "Brown Carpet":{"ID":171,"Damage":12}, "Blue Carpet":{"ID":171,"Damage":11}, "Purple Carpet":{"ID":171,"Damage":10}, "Cyan Carpet":{"ID":171,"Damage":9}, "Light Gray Carpet":{"ID":171,"Damage":8}, "Torch":{"ID":50,"Damage":0}, "Bucket":{"ID":325,"Damage":0}, "Bucket":{"ID":325,"Damage":1}, "Bucket":{"ID":325,"Damage":8}, "Bucket":{"ID":325,"Damage":10}, "TNT":{"ID":46,"Damage":0}, "Redstone":{"ID":331,"Damage":0}, "Bow":{"ID":261,"Damage":0}, "Fishing Rod":{"ID":346,"Damage":0}, "Flint and Steel":{"ID":259,"Damage":0}, "Shears":{"ID":359,"Damage":0}, "Clock":{"ID":347,"Damage":0}, "Compass":{"ID":345,"Damage":0}, "Minecart":{"ID":328,"Damage":0}, "Spawn Egg":{"ID":383,"Damage":15}, "Spawn Egg":{"ID":383,"Damage":32}, "Spawn Egg":{"ID":383,"Damage":17}, "Wooden Sword":{"ID":268,"Damage":0}, "Wooden Hoe":{"ID":290,"Damage":0}, "Wooden Shovel":{"ID":269,"Damage":0}, "Wooden Pickaxe":{"ID":270,"Damage":0}, "Wooden Axe":{"ID":271,"Damage":0}, "Stone Sword":{"ID":272,"Damage":0}, "Stone Hoe":{"ID":291,"Damage":0}, "Stone Shovel":{"ID":273,"Damage":0}, "Stone Pickaxe":{"ID":274,"Damage":0}, "Stone Axe":{"ID":275,"Damage":0}, "Iron Sword":{"ID":267,"Damage":0}, "Iron Hoe":{"ID":292,"Damage":0}, "Iron Shovel":{"ID":256,"Damage":0}, "Iron Pickaxe":{"ID":257,"Damage":0}, "Iron Axe":{"ID":258,"Damage":0}, "Diamond Sword":{"ID":276,"Damage":0}, "Diamond Hoe":{"ID":293,"Damage":0}, "Diamond Shovel":{"ID":277,"Damage":0}, "Diamond Pickaxe":{"ID":278,"Damage":0}, "Diamond Axe":{"ID":279,"Damage":0}, "Gold Sword":{"ID":283,"Damage":0}, "Gold Hoe":{"ID":294,"Damage":0}, "Gold Shovel":{"ID":284,"Damage":0}, "Gold Pickaxe":{"ID":285,"Damage":0}, "Gold Axe":{"ID":286,"Damage":0}, "Leather Cap":{"ID":298,"Damage":0}, "Leather Tunic":{"ID":299,"Damage":0}, "Leather Pants":{"ID":300,"Damage":0}, "Leather Boots":{"ID":301,"Damage":0}, "Chainmail Helmet":{"ID":302,"Damage":0}, "Chain Chestplate":{"ID":303,"Damage":0}, "Chain Leggings":{"ID":304,"Damage":0}, "Chainmail Boots":{"ID":305,"Damage":0}, "Iron Helmet":{"ID":306,"Damage":0}, "Iron Chestplate":{"ID":307,"Damage":0}, "Iron Leggings":{"ID":308,"Damage":0}, "Iron Boots":{"ID":309,"Damage":0}, "Diamond Helmet":{"ID":310,"Damage":0}, "Diamond Chestplate":{"ID":311,"Damage":0}, "Diamond Leggings":{"ID":312,"Damage":0}, "Diamond Boots":{"ID":313,"Damage":0}, "Gold Helmet":{"ID":314,"Damage":0}, "Gold Chestplate":{"ID":315,"Damage":0}, "Gold Leggings":{"ID":316,"Damage":0}, "Gold Boots":{"ID":317,"Damage":0}, "Snowball":{"ID":332,"Damage":0}, "Coal":{"ID":263,"Damage":0}, "Charcoal":{"ID":263,"Damage":1}, "Diamond":{"ID":264,"Damage":0}, "Iron Ingot":{"ID":265,"Damage":0}, "Gold Ingot":{"ID":266,"Damage":0}, "Emerald":{"ID":388,"Damage":0}, "Stick":{"ID":280,"Damage":0}, "Bowl":{"ID":281,"Damage":0}, "String":{"ID":287,"Damage":0}, "Feather":{"ID":288,"Damage":0}, "Flint":{"ID":318,"Damage":0}, "Leather":{"ID":334,"Damage":0}, "Clay":{"ID":337,"Damage":0}, "Sugar":{"ID":353,"Damage":0}, "Nether Quartz":{"ID":406,"Damage":0}, "Paper":{"ID":339,"Damage":0}, "Book":{"ID":340,"Damage":0}, "Arrow":{"ID":262,"Damage":0}, "Bone":{"ID":352,"Damage":0}, "Sugar Cane":{"ID":338,"Damage":0}, "Wheat":{"ID":296,"Damage":0}, "Wheat Seeds":{"ID":295,"Damage":0}, "Pumpkin Seeds":{"ID":361,"Damage":0}, "Melon Seeds":{"ID":362,"Damage":0}, "Beetroot Seeds":{"ID":458,"Damage":0}, "Egg":{"ID":344,"Damage":0}, "Apple":{"ID":260,"Damage":0}, "Golden Apple":{"ID":322,"Damage":0}, "Raw Fish":{"ID":349,"Damage":0}, "Raw Salmon":{"ID":349,"Damage":1}, "Clownfish":{"ID":349,"Damage":2}, "Pufferfish":{"ID":349,"Damage":3}, "Cooked Fish":{"ID":350,"Damage":0}, "Cooked Salmon":{"ID":350,"Damage":1}, "Bread":{"ID":297,"Damage":0}, "Raw Porkchop":{"ID":319,"Damage":0}, "Cooked Porkchop":{"ID":320,"Damage":0}, "Raw Chicken":{"ID":365,"Damage":0}, "Cooked Chicken":{"ID":366,"Damage":0}, "Raw Beef":{"ID":363,"Damage":0}, "Steak":{"ID":364,"Damage":0}, "Melon":{"ID":360,"Damage":0}, "Carrot":{"ID":391,"Damage":0}, "Potato":{"ID":392,"Damage":0}, "Baked Potato":{"ID":393,"Damage":0}, "Cookie":{"ID":357,"Damage":0}, "Pumpkin Pie":{"ID":400,"Damage":0}, "Gold Nugget":{"ID":371,"Damage":0}, "Slimeball":{"ID":341,"Damage":0}, "Gunpowder":{"ID":289,"Damage":0}, "Glowstone Dust":{"ID":348,"Damage":0}, "Dye":{"ID":351,"Damage":0}, "Dye":{"ID":351,"Damage":7}, "Dye":{"ID":351,"Damage":6}, "Dye":{"ID":351,"Damage":5}, "Dye":{"ID":351,"Damage":4}, "Dye":{"ID":351,"Damage":3}, "Dye":{"ID":351,"Damage":2}, "Dye":{"ID":351,"Damage":1}, "Dye":{"ID":351,"Damage":15}, "Dye":{"ID":351,"Damage":14}, "Dye":{"ID":351,"Damage":13}, "Dye":{"ID":351,"Damage":12}, "Dye":{"ID":351,"Damage":11}, "Dye":{"ID":351,"Damage":10}, "Dye":{"ID":351,"Damage":9}, "Dye":{"ID":351,"Damage":8} } \ No newline at end of file diff --git a/src/pocketmine/resources/pocketmine.yml b/src/pocketmine/resources/pocketmine.yml index 6cdb388f7..4695bf704 100644 --- a/src/pocketmine/resources/pocketmine.yml +++ b/src/pocketmine/resources/pocketmine.yml @@ -84,6 +84,7 @@ network: upnp-forwarding: false debug: + #To enable assertion execution, set zend.assertions in your php.ini to 1 #If > 1, it will show debug messages in the console level: 1 #Enables /status, /gc diff --git a/src/pocketmine/resources/recipes.json b/src/pocketmine/resources/recipes.json new file mode 100644 index 000000000..25d8a08e1 --- /dev/null +++ b/src/pocketmine/resources/recipes.json @@ -0,0 +1 @@ +[{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":270,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":269,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":271,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":290,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":274,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":273,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":275,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":291,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":257,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":256,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":258,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":292,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":278,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":277,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":279,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":293,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":285,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":284,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":286,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":294,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":359,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":268,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":272,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":267,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":276,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":283,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":261,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":318,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":288,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":262,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null},{"ID":266,"Count":9,"Damage":0,"NBT":null}],"Result":[{"ID":41,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":41,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":266,"Count":9,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null},{"ID":265,"Count":9,"Damage":0,"NBT":null}],"Result":[{"ID":42,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":42,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":265,"Count":9,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null},{"ID":264,"Count":9,"Damage":0,"NBT":null}],"Result":[{"ID":57,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":57,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":264,"Count":9,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null},{"ID":388,"Count":9,"Damage":0,"NBT":null}],"Result":[{"ID":133,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":133,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":388,"Count":9,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null},{"ID":331,"Count":9,"Damage":0,"NBT":null}],"Result":[{"ID":152,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":152,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":331,"Count":9,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null},{"ID":351,"Count":9,"Damage":4,"NBT":null}],"Result":[{"ID":22,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":22,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":351,"Count":9,"Damage":4,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null},{"ID":296,"Count":9,"Damage":0,"NBT":null}],"Result":[{"ID":170,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":170,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":296,"Count":9,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null},{"ID":263,"Count":9,"Damage":0,"NBT":null}],"Result":[{"ID":173,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":173,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":263,"Count":9,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":266,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":371,"Count":9,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":39,"Count":1,"Damage":-1,"NBT":null},{"ID":40,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":281,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":282,"Count":1,"Damage":0,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":39,"Count":1,"Damage":-1,"NBT":null},{"ID":40,"Count":1,"Damage":-1,"NBT":null},{"ID":281,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":282,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":457,"Count":1,"Damage":0,"NBT":null},{"ID":457,"Count":1,"Damage":0,"NBT":null},{"ID":457,"Count":1,"Damage":0,"NBT":null},{"ID":457,"Count":1,"Damage":0,"NBT":null},{"ID":457,"Count":1,"Damage":0,"NBT":null},{"ID":457,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":281,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":459,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":296,"Count":1,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":3,"NBT":null},{"ID":296,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":357,"Count":8,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":103,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":360,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":362,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":86,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":361,"Count":4,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":86,"Count":1,"Damage":-1,"NBT":null},{"ID":353,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":344,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":400,"Count":1,"Damage":0,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":86,"Count":1,"Damage":-1,"NBT":null},{"ID":353,"Count":1,"Damage":0,"NBT":null},{"ID":344,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":400,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":375,"Count":1,"Damage":0,"NBT":null},{"ID":353,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":39,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":376,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":54,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":131,"Count":1,"Damage":-1,"NBT":null},{"ID":54,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":146,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":61,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":58,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":12,"Count":1,"Damage":0,"NBT":null},{"ID":12,"Count":1,"Damage":0,"NBT":null},{"ID":12,"Count":1,"Damage":0,"NBT":null},{"ID":12,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":24,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":24,"Count":4,"Damage":2,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":44,"Count":1,"Damage":1,"NBT":null},{"ID":44,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":24,"Count":1,"Damage":1,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":0,"NBT":null},{"ID":1,"Count":1,"Damage":0,"NBT":null},{"ID":1,"Count":1,"Damage":0,"NBT":null},{"ID":1,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":98,"Count":4,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":106,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":98,"Count":1,"Damage":1,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":106,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":98,"Count":1,"Damage":1,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":44,"Count":1,"Damage":5,"NBT":null},{"ID":44,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":98,"Count":1,"Damage":3,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":106,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":48,"Count":1,"Damage":0,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":106,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":48,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":101,"Count":16,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":102,"Count":16,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":405,"Count":1,"Damage":0,"NBT":null},{"ID":405,"Count":1,"Damage":0,"NBT":null},{"ID":405,"Count":1,"Damage":0,"NBT":null},{"ID":405,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":112,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":155,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":44,"Count":1,"Damage":6,"NBT":null},{"ID":44,"Count":1,"Damage":6,"NBT":null}],"Result":[{"ID":155,"Count":1,"Damage":1,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":155,"Count":1,"Damage":0,"NBT":null},{"ID":155,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":155,"Count":2,"Damage":2,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":1,"Count":2,"Damage":3,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":3,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":1,"Count":1,"Damage":1,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":1,"Count":1,"Damage":3,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":1,"Count":1,"Damage":1,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":3,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":1,"Count":2,"Damage":5,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":1,"Count":1,"Damage":3,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":1,"Count":2,"Damage":5,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":3,"NBT":null},{"ID":1,"Count":1,"Damage":3,"NBT":null},{"ID":1,"Count":1,"Damage":3,"NBT":null},{"ID":1,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":1,"Count":4,"Damage":4,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":1,"NBT":null},{"ID":1,"Count":1,"Damage":1,"NBT":null},{"ID":1,"Count":1,"Damage":1,"NBT":null},{"ID":1,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":1,"Count":4,"Damage":2,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":5,"NBT":null},{"ID":1,"Count":1,"Damage":5,"NBT":null},{"ID":1,"Count":1,"Damage":5,"NBT":null},{"ID":1,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":1,"Count":4,"Damage":6,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":298,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":299,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":300,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":301,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":306,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":307,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":308,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":309,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":310,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":311,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":312,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":313,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":314,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":315,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":316,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":317,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":15,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":14,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":2,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":13,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":3,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":12,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":11,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":5,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":10,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":6,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":9,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":7,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":8,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":8,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":7,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":9,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":6,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":10,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":5,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":11,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":4,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":12,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":3,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":13,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":2,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":14,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":1,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":15,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":37,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":11,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":244,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":1,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":1,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":352,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":351,"Count":3,"Damage":15,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":9,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":9,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":11,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":14,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":11,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":14,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":2,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":10,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":2,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":10,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":8,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":8,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":8,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":7,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":8,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":7,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":3,"Damage":7,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":3,"Damage":7,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":11,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":3,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":11,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":3,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":12,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":12,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":6,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":6,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":5,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":5,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":5,"NBT":null},{"ID":351,"Count":1,"Damage":9,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":13,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":5,"NBT":null},{"ID":351,"Count":1,"Damage":9,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":13,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":351,"Count":1,"Damage":9,"NBT":null}],"Result":[{"ID":351,"Count":3,"Damage":13,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":9,"NBT":null}],"Result":[{"ID":351,"Count":3,"Damage":13,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":351,"Count":4,"Damage":13,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":351,"Count":4,"Damage":13,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":12,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":13,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":7,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":1,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":14,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":6,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":7,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":7,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":9,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":38,"Count":1,"Damage":8,"NBT":null}],"Result":[{"ID":351,"Count":1,"Damage":7,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":175,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":11,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":175,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":13,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":175,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":1,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":175,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":351,"Count":2,"Damage":9,"NBT":null}]},{"Type":5},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":338,"Count":1,"Damage":0,"NBT":null},{"ID":338,"Count":1,"Damage":0,"NBT":null},{"ID":338,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":339,"Count":3,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":339,"Count":1,"Damage":0,"NBT":null},{"ID":339,"Count":1,"Damage":0,"NBT":null},{"ID":339,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":340,"Count":1,"Damage":0,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":339,"Count":1,"Damage":0,"NBT":null},{"ID":339,"Count":1,"Damage":0,"NBT":null},{"ID":339,"Count":1,"Damage":0,"NBT":null},{"ID":334,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":340,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":139,"Count":6,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":48,"Count":1,"Damage":-1,"NBT":null},{"ID":48,"Count":1,"Damage":-1,"NBT":null},{"ID":48,"Count":1,"Damage":-1,"NBT":null},{"ID":48,"Count":1,"Damage":-1,"NBT":null},{"ID":48,"Count":1,"Damage":-1,"NBT":null},{"ID":48,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":139,"Count":6,"Damage":1,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":113,"Count":6,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":85,"Count":3,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":85,"Count":3,"Damage":1,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":85,"Count":3,"Damage":2,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":85,"Count":3,"Damage":3,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":85,"Count":3,"Damage":4,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":85,"Count":3,"Damage":5,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":107,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":183,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":184,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":185,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":187,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":186,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":42,"Count":1,"Damage":-1,"NBT":null},{"ID":42,"Count":1,"Damage":-1,"NBT":null},{"ID":42,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":145,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":340,"Count":1,"Damage":0,"NBT":null},{"ID":340,"Count":1,"Damage":0,"NBT":null},{"ID":340,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":47,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":332,"Count":1,"Damage":0,"NBT":null},{"ID":332,"Count":1,"Damage":0,"NBT":null},{"ID":332,"Count":1,"Damage":0,"NBT":null},{"ID":332,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":80,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":80,"Count":1,"Damage":-1,"NBT":null},{"ID":80,"Count":1,"Damage":-1,"NBT":null},{"ID":80,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":78,"Count":6,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":337,"Count":1,"Damage":0,"NBT":null},{"ID":337,"Count":1,"Damage":0,"NBT":null},{"ID":337,"Count":1,"Damage":0,"NBT":null},{"ID":337,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":82,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":336,"Count":1,"Damage":0,"NBT":null},{"ID":336,"Count":1,"Damage":0,"NBT":null},{"ID":336,"Count":1,"Damage":0,"NBT":null},{"ID":336,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":45,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":348,"Count":1,"Damage":0,"NBT":null},{"ID":348,"Count":1,"Damage":0,"NBT":null},{"ID":348,"Count":1,"Damage":0,"NBT":null},{"ID":348,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":89,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":287,"Count":1,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":35,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":289,"Count":1,"Damage":0,"NBT":null},{"ID":12,"Count":1,"Damage":-1,"NBT":null},{"ID":289,"Count":1,"Damage":0,"NBT":null},{"ID":12,"Count":1,"Damage":-1,"NBT":null},{"ID":289,"Count":1,"Damage":0,"NBT":null},{"ID":12,"Count":1,"Damage":-1,"NBT":null},{"ID":289,"Count":1,"Damage":0,"NBT":null},{"ID":12,"Count":1,"Damage":-1,"NBT":null},{"ID":289,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":46,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":44,"Count":6,"Damage":3,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":-1,"NBT":null},{"ID":1,"Count":1,"Damage":-1,"NBT":null},{"ID":1,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":44,"Count":6,"Damage":0,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":44,"Count":6,"Damage":1,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":158,"Count":6,"Damage":0,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":158,"Count":6,"Damage":1,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":158,"Count":6,"Damage":2,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":158,"Count":6,"Damage":3,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":158,"Count":6,"Damage":4,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":158,"Count":6,"Damage":5,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":45,"Count":1,"Damage":-1,"NBT":null},{"ID":45,"Count":1,"Damage":-1,"NBT":null},{"ID":45,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":44,"Count":6,"Damage":4,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":98,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":44,"Count":6,"Damage":5,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":44,"Count":6,"Damage":7,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":155,"Count":1,"Damage":-1,"NBT":null},{"ID":155,"Count":1,"Damage":-1,"NBT":null},{"ID":155,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":44,"Count":6,"Damage":6,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":65,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":324,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":427,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":428,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":429,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":430,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":431,"Count":3,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":96,"Count":2,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":167,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":1,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":131,"Count":2,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":25,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":2,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":330,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":323,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":325,"Count":1,"Damage":1,"NBT":null},{"ID":325,"Count":1,"Damage":1,"NBT":null},{"ID":325,"Count":1,"Damage":1,"NBT":null},{"ID":353,"Count":1,"Damage":0,"NBT":null},{"ID":344,"Count":1,"Damage":0,"NBT":null},{"ID":353,"Count":1,"Damage":0,"NBT":null},{"ID":296,"Count":1,"Damage":0,"NBT":null},{"ID":296,"Count":1,"Damage":0,"NBT":null},{"ID":296,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":354,"Count":1,"Damage":0,"NBT":null},{"ID":325,"Count":3,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":338,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":353,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":391,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":396,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":360,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null},{"ID":371,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":382,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":369,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":377,"Count":2,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":377,"Count":1,"Damage":0,"NBT":null},{"ID":341,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":378,"Count":1,"Damage":0,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":377,"Count":1,"Damage":0,"NBT":null},{"ID":341,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":378,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":39,"Count":1,"Damage":-1,"NBT":null},{"ID":353,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":375,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":376,"Count":1,"Damage":0,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":39,"Count":1,"Damage":-1,"NBT":null},{"ID":353,"Count":1,"Damage":0,"NBT":null},{"ID":375,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":376,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":17,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":5,"Count":4,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":17,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":5,"Count":4,"Damage":1,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":17,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":5,"Count":4,"Damage":2,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":17,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":5,"Count":4,"Damage":3,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":162,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":5,"Count":4,"Damage":4,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":162,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":5,"Count":4,"Damage":5,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":280,"Count":4,"Damage":0,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":263,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":50,"Count":4,"Damage":0,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":263,"Count":1,"Damage":1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":50,"Count":4,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":281,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":412,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":391,"Count":1,"Damage":0,"NBT":null},{"ID":393,"Count":1,"Damage":0,"NBT":null},{"ID":39,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":281,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":413,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":412,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":391,"Count":1,"Damage":0,"NBT":null},{"ID":393,"Count":1,"Damage":0,"NBT":null},{"ID":40,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":281,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":413,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":374,"Count":3,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":336,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":336,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":336,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":390,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":66,"Count":16,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":27,"Count":6,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":70,"Count":1,"Damage":-1,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":28,"Count":6,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":76,"Count":1,"Damage":-1,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":126,"Count":6,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":328,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":369,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":379,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":86,"Count":1,"Damage":-1,"NBT":null},{"ID":50,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":91,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":269,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":333,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":269,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":333,"Count":1,"Damage":1,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":269,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":333,"Count":1,"Damage":2,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":269,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":333,"Count":1,"Damage":3,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":269,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":333,"Count":1,"Damage":4,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":269,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":333,"Count":1,"Damage":5,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":325,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":318,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":259,"Count":1,"Damage":0,"NBT":null}]},{"Type":0,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":318,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":259,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":3,"Type":1,"Ingredients":[{"ID":296,"Count":1,"Damage":0,"NBT":null},{"ID":296,"Count":1,"Damage":0,"NBT":null},{"ID":296,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":297,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":53,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null},{"ID":5,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":134,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null},{"ID":5,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":135,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null},{"ID":5,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":136,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null},{"ID":5,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":163,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null},{"ID":5,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":164,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":67,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":45,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":45,"Count":1,"Damage":-1,"NBT":null},{"ID":45,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":45,"Count":1,"Damage":-1,"NBT":null},{"ID":45,"Count":1,"Damage":-1,"NBT":null},{"ID":45,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":108,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null},{"ID":24,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":128,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":98,"Count":1,"Damage":-1,"NBT":null},{"ID":98,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":109,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":155,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":155,"Count":1,"Damage":-1,"NBT":null},{"ID":155,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":155,"Count":1,"Damage":-1,"NBT":null},{"ID":155,"Count":1,"Damage":-1,"NBT":null},{"ID":155,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":156,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null},{"ID":112,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":114,"Count":4,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":287,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":346,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":35,"Count":1,"Damage":-1,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":321,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":260,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":322,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":41,"Count":1,"Damage":-1,"NBT":null},{"ID":41,"Count":1,"Damage":-1,"NBT":null},{"ID":41,"Count":1,"Damage":-1,"NBT":null},{"ID":41,"Count":1,"Damage":-1,"NBT":null},{"ID":260,"Count":1,"Damage":0,"NBT":null},{"ID":41,"Count":1,"Damage":-1,"NBT":null},{"ID":41,"Count":1,"Damage":-1,"NBT":null},{"ID":41,"Count":1,"Damage":-1,"NBT":null},{"ID":41,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":466,"Count":1,"Damage":1,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":280,"Count":1,"Damage":0,"NBT":null},{"ID":4,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":69,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":1,"Type":1,"Ingredients":[{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":280,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":76,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":20,"Count":1,"Damage":-1,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":406,"Count":1,"Damage":0,"NBT":null},{"ID":158,"Count":1,"Damage":-1,"NBT":null},{"ID":158,"Count":1,"Damage":-1,"NBT":null},{"ID":158,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":151,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":89,"Count":1,"Damage":-1,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":123,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":347,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":331,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null}],"Result":[{"ID":345,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":77,"Count":1,"Damage":5,"NBT":null}]},{"Height":1,"Width":1,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":143,"Count":1,"Damage":5,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":1,"Count":1,"Damage":0,"NBT":null},{"ID":1,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":70,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":72,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":266,"Count":1,"Damage":0,"NBT":null},{"ID":266,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":147,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":265,"Count":1,"Damage":0,"NBT":null},{"ID":265,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":148,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":3,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":-1,"NBT":null},{"ID":35,"Count":1,"Damage":-1,"NBT":null},{"ID":35,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null},{"ID":5,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":355,"Count":1,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":340,"Count":1,"Damage":0,"NBT":null},{"ID":0,"Count":0,"Damage":0,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":49,"Count":1,"Damage":-1,"NBT":null},{"ID":264,"Count":1,"Damage":0,"NBT":null},{"ID":49,"Count":1,"Damage":-1,"NBT":null},{"ID":49,"Count":1,"Damage":-1,"NBT":null},{"ID":49,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":116,"Count":1,"Damage":0,"NBT":null}]},{"Height":2,"Width":2,"Type":1,"Ingredients":[{"ID":415,"Count":1,"Damage":0,"NBT":null},{"ID":415,"Count":1,"Damage":0,"NBT":null},{"ID":415,"Count":1,"Damage":0,"NBT":null},{"ID":415,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":334,"Count":1,"Damage":0,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":0,"NBT":null},{"ID":35,"Count":1,"Damage":0,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":0,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":0,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":15,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":1,"NBT":null},{"ID":35,"Count":1,"Damage":1,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":1,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":14,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":2,"NBT":null},{"ID":35,"Count":1,"Damage":2,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":2,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":2,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":13,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":3,"NBT":null},{"ID":35,"Count":1,"Damage":3,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":3,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":3,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":12,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":4,"NBT":null},{"ID":35,"Count":1,"Damage":4,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":4,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":4,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":11,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":5,"NBT":null},{"ID":35,"Count":1,"Damage":5,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":5,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":5,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":10,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":6,"NBT":null},{"ID":35,"Count":1,"Damage":6,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":6,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":6,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":9,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":7,"NBT":null},{"ID":35,"Count":1,"Damage":7,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":7,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":7,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":8,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":8,"NBT":null},{"ID":35,"Count":1,"Damage":8,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":8,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":8,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":7,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":9,"NBT":null},{"ID":35,"Count":1,"Damage":9,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":9,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":9,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":6,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":10,"NBT":null},{"ID":35,"Count":1,"Damage":10,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":10,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":10,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":5,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":11,"NBT":null},{"ID":35,"Count":1,"Damage":11,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":11,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":11,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":4,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":12,"NBT":null},{"ID":35,"Count":1,"Damage":12,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":12,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":12,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":3,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":13,"NBT":null},{"ID":35,"Count":1,"Damage":13,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":13,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":13,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":2,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":14,"NBT":null},{"ID":35,"Count":1,"Damage":14,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":14,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":14,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":1,"NBT":null}]},{"Height":1,"Width":2,"Type":1,"Ingredients":[{"ID":35,"Count":1,"Damage":15,"NBT":null},{"ID":35,"Count":1,"Damage":15,"NBT":null}],"Result":[{"ID":171,"Count":3,"Damage":15,"NBT":null}]},{"Height":3,"Width":3,"Type":1,"Ingredients":[{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":351,"Count":1,"Damage":15,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null},{"ID":172,"Count":1,"Damage":-1,"NBT":null}],"Result":[{"ID":159,"Count":8,"Damage":0,"NBT":null}]},{"Type":2,"Ingredients":4,"Result":{"ID":1,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":12,"Result":{"ID":20,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":14,"Result":{"ID":266,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":15,"Result":{"ID":265,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":16,"Result":{"ID":263,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":17,"Result":{"ID":263,"Count":1,"Damage":1,"NBT":null}},{"Type":2,"Ingredients":21,"Result":{"ID":351,"Count":1,"Damage":4,"NBT":null}},{"Type":2,"Ingredients":56,"Result":{"ID":264,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":73,"Result":{"ID":331,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":81,"Result":{"ID":351,"Count":1,"Damage":2,"NBT":null}},{"Type":2,"Ingredients":82,"Result":{"ID":172,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":87,"Result":{"ID":405,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":129,"Result":{"ID":388,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":153,"Result":{"ID":406,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":162,"Result":{"ID":263,"Count":1,"Damage":1,"NBT":null}},{"Type":2,"Ingredients":319,"Result":{"ID":320,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":337,"Result":{"ID":336,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":349,"Result":{"ID":350,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":363,"Result":{"ID":364,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":365,"Result":{"ID":366,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":392,"Result":{"ID":393,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":411,"Result":{"ID":412,"Count":1,"Damage":0,"NBT":null}},{"Type":2,"Ingredients":460,"Result":{"ID":463,"Count":1,"Damage":0,"NBT":null}},{"Type":3,"Ingredients":{"ID":98,"Damage":0},"Result":{"ID":98,"Count":1,"Damage":2,"NBT":null}}] diff --git a/src/pocketmine/scheduler/AsyncPool.php b/src/pocketmine/scheduler/AsyncPool.php index 65b68a690..dafb9f48b 100644 --- a/src/pocketmine/scheduler/AsyncPool.php +++ b/src/pocketmine/scheduler/AsyncPool.php @@ -47,7 +47,7 @@ class AsyncPool{ for($i = 0; $i < $this->size; ++$i){ $this->workerUsage[$i] = 0; - $this->workers[$i] = new AsyncWorker; + $this->workers[$i] = new AsyncWorker($this->server->getLogger(), $i + 1); $this->workers[$i]->setClassLoader($this->server->getLoader()); $this->workers[$i]->start(); } @@ -62,7 +62,7 @@ class AsyncPool{ if($newSize > $this->size){ for($i = $this->size; $i < $newSize; ++$i){ $this->workerUsage[$i] = 0; - $this->workers[$i] = new AsyncWorker; + $this->workers[$i] = new AsyncWorker($this->server->getLogger(), $i + 1); $this->workers[$i]->setClassLoader($this->server->getLoader()); $this->workers[$i]->start(); } @@ -109,8 +109,7 @@ class AsyncPool{ if(!$force and ($task->isRunning() or !$task->isGarbage())){ return; } - $this->workers[$w = $this->taskWorkers[$task->getTaskId()]]->unstack($task); - $this->workerUsage[$w]--; + $this->workerUsage[$this->taskWorkers[$task->getTaskId()]]--; } unset($this->tasks[$task->getTaskId()]); @@ -127,7 +126,7 @@ class AsyncPool{ } if(count($this->tasks) > 0){ - usleep(25000); + Server::microSleep(25000); } }while(count($this->tasks) > 0); @@ -143,18 +142,16 @@ class AsyncPool{ Timings::$schedulerAsyncTimer->startTiming(); foreach($this->tasks as $task){ - if($task->isGarbage() and !$task->isRunning()){ + if($task->isGarbage() and !$task->isRunning() and !$task->isCrashed()){ if(!$task->hasCancelledRun()){ $task->onCompletion($this->server); } $this->removeTask($task); - }elseif($task->isTerminated()){ - $info = $task->getTerminationInfo(); + }elseif($task->isTerminated() or $task->isCrashed()){ + $this->server->getLogger()->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": Task crashed"); $this->removeTask($task, true); - $this->server->getLogger()->critical("Could not execute asynchronous task " . (new \ReflectionClass($task))->getShortName() . ": " . (isset($info["message"]) ? $info["message"] : "Unknown")); - $this->server->getLogger()->critical("On ".$info["scope"].", line ".$info["line"] .", ".$info["function"]."()"); } } diff --git a/src/pocketmine/scheduler/AsyncTask.php b/src/pocketmine/scheduler/AsyncTask.php index 48bcb3bc4..0e4ea0502 100644 --- a/src/pocketmine/scheduler/AsyncTask.php +++ b/src/pocketmine/scheduler/AsyncTask.php @@ -22,13 +22,14 @@ namespace pocketmine\scheduler; use pocketmine\Server; +use pocketmine\Collectable; /** * Class used to run async tasks in other threads. * * WARNING: Do not call PocketMine-MP API methods, or save objects from/on other Threads!! */ -abstract class AsyncTask extends \Collectable{ +abstract class AsyncTask extends Collectable{ /** @var AsyncWorker $worker */ public $worker = null; @@ -39,23 +40,25 @@ abstract class AsyncTask extends \Collectable{ /** @var int */ private $taskId = null; + private $crashed = false; + public function run(){ $this->result = null; if($this->cancelRun !== true){ - $this->onRun(); + try{ + $this->onRun(); + }catch(\Throwable $e){ + $this->crashed = true; + $this->worker->handleException($e); + } } $this->setGarbage(); } - /** - * @deprecated - * - * @return bool - */ - public function isFinished(){ - return $this->isGarbage(); + public function isCrashed(){ + return $this->crashed; } /** @@ -144,7 +147,9 @@ abstract class AsyncTask extends \Collectable{ public function cleanObject(){ foreach($this as $p => $v){ - $this->{$p} = null; + if(!($v instanceof \Threaded)){ + $this->{$p} = null; + } } } diff --git a/src/pocketmine/scheduler/AsyncWorker.php b/src/pocketmine/scheduler/AsyncWorker.php index 3d1825c56..0f77c96d4 100644 --- a/src/pocketmine/scheduler/AsyncWorker.php +++ b/src/pocketmine/scheduler/AsyncWorker.php @@ -25,6 +25,14 @@ use pocketmine\Worker; class AsyncWorker extends Worker{ + private $logger; + private $id; + + public function __construct(\ThreadedLogger $logger, $id){ + $this->logger = $logger; + $this->id = $id; + } + public function run(){ $this->registerClassLoader(); gc_enable(); @@ -32,14 +40,13 @@ class AsyncWorker extends Worker{ global $store; $store = []; - } - public function start($options = PTHREADS_INHERIT_NONE){ - parent::start(PTHREADS_INHERIT_CONSTANTS | PTHREADS_INHERIT_FUNCTIONS); + public function handleException(\Throwable $e){ + $this->logger->logException($e); } public function getThreadName(){ - return "Asynchronous Worker"; + return "Asynchronous Worker #" . $this->id; } } diff --git a/src/pocketmine/scheduler/CallbackTask.php b/src/pocketmine/scheduler/CallbackTask.php deleted file mode 100644 index 4d4969404..000000000 --- a/src/pocketmine/scheduler/CallbackTask.php +++ /dev/null @@ -1,62 +0,0 @@ -callable = $callable; - $this->args = $args; - $this->args[] = $this; - } - - /** - * @return callable - */ - public function getCallable(){ - return $this->callable; - } - - public function onRun($currentTicks){ - call_user_func_array($this->callable, $this->args); - } - -} diff --git a/src/pocketmine/scheduler/FileWriteTask.php b/src/pocketmine/scheduler/FileWriteTask.php index f952e91e8..d76174d1a 100644 --- a/src/pocketmine/scheduler/FileWriteTask.php +++ b/src/pocketmine/scheduler/FileWriteTask.php @@ -36,7 +36,7 @@ class FileWriteTask extends AsyncTask{ public function onRun(){ try{ file_put_contents($this->path, $this->contents, (int) $this->flags); - }catch (\Exception $e){ + }catch (\Throwable $e){ } } diff --git a/src/pocketmine/scheduler/SendUsageTask.php b/src/pocketmine/scheduler/SendUsageTask.php index fbd285afa..686ba6d62 100644 --- a/src/pocketmine/scheduler/SendUsageTask.php +++ b/src/pocketmine/scheduler/SendUsageTask.php @@ -24,8 +24,8 @@ namespace pocketmine\scheduler; use pocketmine\network\protocol\Info; use pocketmine\Server; use pocketmine\utils\Utils; -use pocketmine\utils\VersionString; use pocketmine\utils\UUID; +use pocketmine\utils\VersionString; class SendUsageTask extends AsyncTask{ @@ -144,7 +144,7 @@ class SendUsageTask extends AsyncTask{ "Content-Type: application/json", "Content-Length: ". strlen($this->data) ]); - }catch(\Exception $e){ + }catch(\Throwable $e){ } } diff --git a/src/pocketmine/scheduler/ServerScheduler.php b/src/pocketmine/scheduler/ServerScheduler.php index 4271f0f72..6d37ac088 100644 --- a/src/pocketmine/scheduler/ServerScheduler.php +++ b/src/pocketmine/scheduler/ServerScheduler.php @@ -160,7 +160,9 @@ class ServerScheduler{ } $this->tasks = []; $this->asyncPool->removeTasks(); - $this->queue = new ReversePriorityQueue(); + while(!$this->queue->isEmpty()){ + $this->queue->extract(); + } $this->ids = 1; } @@ -245,12 +247,9 @@ class ServerScheduler{ $task->timings->startTiming(); try{ $task->run($this->currentTick); - }catch(\Exception $e){ + }catch(\Throwable $e){ Server::getInstance()->getLogger()->critical("Could not execute task " . $task->getTaskName() . ": " . $e->getMessage()); - $logger = Server::getInstance()->getLogger(); - if($logger instanceof MainLogger){ - $logger->logException($e); - } + Server::getInstance()->getLogger()->logException($e); } $task->timings->stopTiming(); } diff --git a/src/pocketmine/scheduler/Task.php b/src/pocketmine/scheduler/Task.php index 5793466ae..cbf82a74a 100644 --- a/src/pocketmine/scheduler/Task.php +++ b/src/pocketmine/scheduler/Task.php @@ -21,6 +21,9 @@ namespace pocketmine\scheduler; +/** + * WARNING! Plugins that create tasks MUST extend PluginTask + */ abstract class Task{ /** @var TaskHandler */ 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 a94ae40bc..0ddc33df9 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 6da32496c..f972597e9 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 50515d14f..14d36cce3 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\BlockEntityDataPacket; 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 689236f66..059f11913 100644 --- a/src/pocketmine/tile/Tile.php +++ b/src/pocketmine/tile/Tile.php @@ -29,9 +29,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{ @@ -70,12 +70,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); @@ -109,10 +109,8 @@ abstract class Tile extends Position{ return self::$shortNames[static::class]; } - public function __construct(FullChunk $chunk, Compound $nbt){ - if($chunk === null or $chunk->getProvider() === null){ - throw new ChunkException("Invalid garbage Chunk given to Tile"); - } + public function __construct(FullChunk $chunk, CompoundTag $nbt){ + assert($chunk !== null and $chunk->getProvider() !== null); $this->timings = Timings::getTileEntityTimings($this); @@ -137,10 +135,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); } /** diff --git a/src/pocketmine/utils/BinaryStream.php b/src/pocketmine/utils/BinaryStream.php index d4ec2a96e..30c5dca73 100644 --- a/src/pocketmine/utils/BinaryStream.php +++ b/src/pocketmine/utils/BinaryStream.php @@ -206,7 +206,7 @@ class BinaryStream extends \stdClass{ $data = $this->getShort(); - $nbtLen = $this->getShort(); + $nbtLen = $this->getLShort(); $nbt = ""; @@ -232,7 +232,7 @@ class BinaryStream extends \stdClass{ $this->putByte($item->getCount()); $this->putShort($item->getDamage() === null ? -1 : $item->getDamage()); $nbt = $item->getCompoundTag(); - $this->putShort(strlen($nbt)); + $this->putLShort(strlen($nbt)); $this->put($nbt); } diff --git a/src/pocketmine/utils/Cache.php b/src/pocketmine/utils/Cache.php deleted file mode 100644 index 1bea19e6e..000000000 --- a/src/pocketmine/utils/Cache.php +++ /dev/null @@ -1,86 +0,0 @@ - $data){ - if($data[1] < $time){ - unset(self::$cached[$index]); - } - } - } - -} \ No newline at end of file diff --git a/src/pocketmine/utils/Config.php b/src/pocketmine/utils/Config.php index 5de2ed481..8039e2a8b 100644 --- a/src/pocketmine/utils/Config.php +++ b/src/pocketmine/utils/Config.php @@ -207,10 +207,10 @@ class Config{ }else{ file_put_contents($this->file, $content); } - }catch(\Exception $e){ + }catch(\Throwable $e){ $logger = Server::getInstance()->getLogger(); $logger->critical("Could not save Config " . $this->file . ": " . $e->getMessage()); - if(\pocketmine\DEBUG > 1 and $logger instanceof MainLogger){ + if(\pocketmine\DEBUG > 1){ $logger->logException($e); } } @@ -321,46 +321,6 @@ class Config{ return ($this->correct and isset($this->config[$k])) ? $this->config[$k] : $default; } - /** - * @param string $path - * - * @deprecated - * - * @return mixed - */ - public function getPath($path){ - $currPath =& $this->config; - foreach(explode(".", $path) as $component){ - if(isset($currPath[$component])){ - $currPath =& $currPath[$component]; - }else{ - $currPath = null; - } - } - - return $currPath; - } - - /** - * - * @deprecated - * - * @param string $path - * @param mixed $value - */ - public function setPath($path, $value){ - $currPath =& $this->config; - $components = explode(".", $path); - $final = array_pop($components); - foreach($components as $component){ - if(!isset($currPath[$component])){ - $currPath[$component] = []; - } - $currPath =& $currPath[$component]; - } - $currPath[$final] = $value; - } - /** * @param string $k key to be set * @param mixed $v value to set key diff --git a/src/pocketmine/utils/MainLogger.php b/src/pocketmine/utils/MainLogger.php index 94929f941..65f02874e 100644 --- a/src/pocketmine/utils/MainLogger.php +++ b/src/pocketmine/utils/MainLogger.php @@ -48,7 +48,7 @@ class MainLogger extends \AttachableThreadedLogger{ touch($logFile); $this->logFile = $logFile; $this->logDebug = (bool) $logDebug; - $this->logStream = \ThreadedFactory::create(); + $this->logStream = new \Threaded; $this->start(); } @@ -101,7 +101,7 @@ class MainLogger extends \AttachableThreadedLogger{ $this->logDebug = (bool) $logDebug; } - public function logException(\Exception $e, $trace = null){ + public function logException(\Throwable $e, $trace = null){ if($trace === null){ $trace = $e->getTrace(); } diff --git a/src/pocketmine/utils/ServerKiller.php b/src/pocketmine/utils/ServerKiller.php index 2e3326ebb..8bc2521d0 100644 --- a/src/pocketmine/utils/ServerKiller.php +++ b/src/pocketmine/utils/ServerKiller.php @@ -32,9 +32,14 @@ class ServerKiller extends Thread{ } public function run(){ - sleep($this->time); - echo "\nTook too long to stop, server was killed forcefully!\n"; - @\pocketmine\kill(getmypid()); + $start = time() + 1; + $this->synchronized(function(){ + $this->wait($this->time * 1000000); + }); + if(time() - $start >= $this->time){ + echo "\nTook too long to stop, server was killed forcefully!\n"; + @\pocketmine\kill(getmypid()); + } } public function getThreadName(){ diff --git a/src/pocketmine/utils/TextWrapper.php b/src/pocketmine/utils/TextWrapper.php deleted file mode 100644 index efe313ab5..000000000 --- a/src/pocketmine/utils/TextWrapper.php +++ /dev/null @@ -1,93 +0,0 @@ -?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_abcdefghijklmnopqrstuvwxyz{|}~"; - - private static $allowedCharsArray = []; - - public static function init(){ - self::$allowedCharsArray = []; - $len = strlen(self::$allowedChars); - for($i = 0; $i < $len; ++$i){ - self::$allowedCharsArray[self::$allowedChars{$i}] = self::$characterWidths[$i]; - } - } - - /** - * @deprecated - * - * @param $text - * - * @return string - */ - public static function wrap($text){ - $result = ""; - $len = strlen($text); - $lineWidth = 0; - $lineLength = 0; - - for($i = 0; $i < $len; ++$i){ - $char = $text{$i}; - - if($char === "\n"){ - $lineLength = 0; - $lineWidth = 0; - }elseif(isset(self::$allowedCharsArray[$char])){ - $width = self::$allowedCharsArray[$char]; - - if($lineLength + 1 > self::CHAT_STRING_LENGTH or $lineWidth + $width > self::CHAT_WINDOW_WIDTH){ - $result .= "\n"; - $lineLength = 0; - $lineWidth = 0; - } - - ++$lineLength; - $lineWidth += $width; - }else{ - return $text; - } - - $result .= $char; - } - - return $result; - } -} \ No newline at end of file diff --git a/src/pocketmine/utils/Utils.php b/src/pocketmine/utils/Utils.php index 94ebca6c0..18085f03c 100644 --- a/src/pocketmine/utils/Utils.php +++ b/src/pocketmine/utils/Utils.php @@ -2,11 +2,11 @@ /* * - * ____ _ _ __ __ _ __ __ ____ - * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ + * ____ _ _ __ __ _ __ __ ____ + * | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \ * | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) | - * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ - * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| + * | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/ + * |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_| * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by @@ -15,7 +15,7 @@ * * @author PocketMine Team * @link http://www.pocketmine.net/ - * + * * */ @@ -49,34 +49,6 @@ class Utils{ } } - /** - * @deprecated - */ - public static function randomUUID(){ - return Utils::toUUID(Binary::writeInt(time()) . Binary::writeShort(getmypid()) . Binary::writeShort(getmyuid()) . Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)) . Binary::writeInt(mt_rand(-0x7fffffff, 0x7fffffff)), 2); - } - - /** - * @deprecated - */ - public static function dataToUUID(...$params){ - return Utils::toUUID(hash("md5", implode($params), true), 3); - } - - /** - * @deprecated - */ - public static function toUUID($data, $version = 2, $fixed = "8"){ - if(strlen($data) !== 16){ - throw new \InvalidArgumentException("Data must be 16 bytes"); - } - - $hex = bin2hex($data); - - //xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx 8-4-4-12 - return substr($hex, 0, 8) . "-" . substr($hex, 8, 4) . "-" . hexdec($version) . substr($hex, 13, 3) . "-" . $fixed{0} . substr($hex, 17, 3) . "-" . substr($hex, 20, 12); - } - /** * Gets this machine / server instance unique ID * Returns a hash, the first 32 characters (or 16 if raw) @@ -220,7 +192,7 @@ class Utils{ self::$os = "other"; } } - + return self::$os; } diff --git a/src/pocketmine/utils/VersionString.php b/src/pocketmine/utils/VersionString.php index 35e5e8c5c..069c2fb8e 100644 --- a/src/pocketmine/utils/VersionString.php +++ b/src/pocketmine/utils/VersionString.php @@ -54,13 +54,6 @@ class VersionString{ return (int) (($this->generation << 9) + ($this->major << 5) + $this->minor); } - /** - * @deprecated - */ - public function getStage(){ - return "final"; - } - public function getGeneration(){ return $this->generation; } diff --git a/src/raklib b/src/raklib index d7da0c554..a5cca45a9 160000 --- a/src/raklib +++ b/src/raklib @@ -1 +1 @@ -Subproject commit d7da0c5549215c7616a6fc103299afb0aeac88e7 +Subproject commit a5cca45a922ca193a616069f885866efc7158c67 diff --git a/src/spl b/src/spl index d59c0f673..6edaf9802 160000 --- a/src/spl +++ b/src/spl @@ -1 +1 @@ -Subproject commit d59c0f673455f02b2620853f3fa6290d63ffd960 +Subproject commit 6edaf9802cbada5e7638ceadfe042be9921376d8 diff --git a/start.sh b/start.sh index 32d6a5c9a..d4dcd8080 100755 --- a/start.sh +++ b/start.sh @@ -22,13 +22,13 @@ while getopts "p:f:l" OPTION 2> /dev/null; do done if [ "$PHP_BINARY" == "" ]; then - if [ -f ./bin/php5/bin/php ]; then + if [ -f ./bin/php7/bin/php ]; then export PHPRC="" - PHP_BINARY="./bin/php5/bin/php" - elif type php 2>/dev/null; then + PHP_BINARY="./bin/php7/bin/php" + elif [ type php 2>/dev/null ]; then PHP_BINARY=$(type -p php) else - echo "Couldn't find a working PHP binary, please use the installer." + echo "Couldn't find a working PHP 7 binary, please use the installer." exit 1 fi fi @@ -58,4 +58,4 @@ done if [ ${LOOPS} -gt 1 ]; then echo "Restarted $LOOPS times" -fi \ No newline at end of file +fi