mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 02:09:42 +00:00
updated pocketmine/nbt dependency
this is going to need work on exception handling, but right now it's so inconsistent that it doesn't matter anyway.
This commit is contained in:
parent
6e39e34c1e
commit
995309424e
8
composer.lock
generated
8
composer.lock
generated
@ -443,12 +443,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pmmp/NBT.git",
|
||||
"reference": "1cdf6aec3024e2061b8c3e5045c43250df94a740"
|
||||
"reference": "f205b5e6fe47ddf0ead4f1438b37f9cdee1fc407"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/pmmp/NBT/zipball/1cdf6aec3024e2061b8c3e5045c43250df94a740",
|
||||
"reference": "1cdf6aec3024e2061b8c3e5045c43250df94a740",
|
||||
"url": "https://api.github.com/repos/pmmp/NBT/zipball/f205b5e6fe47ddf0ead4f1438b37f9cdee1fc407",
|
||||
"reference": "f205b5e6fe47ddf0ead4f1438b37f9cdee1fc407",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
@ -472,7 +472,7 @@
|
||||
"LGPL-3.0"
|
||||
],
|
||||
"description": "PHP library for working with Named Binary Tags",
|
||||
"time": "2020-02-24T21:43:33+00:00"
|
||||
"time": "2020-03-04T16:39:25+00:00"
|
||||
},
|
||||
{
|
||||
"name": "pocketmine/raklib",
|
||||
|
@ -45,7 +45,7 @@ class Comparator extends Tile{
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
$this->signalStrength = $nbt->getInt(self::TAG_OUTPUT_SIGNAL, 0, true);
|
||||
$this->signalStrength = $nbt->getInt(self::TAG_OUTPUT_SIGNAL, 0);
|
||||
}
|
||||
|
||||
protected function writeSaveData(CompoundTag $nbt) : void{
|
||||
|
@ -66,14 +66,14 @@ class Furnace extends Spawnable implements Container, Nameable{
|
||||
}
|
||||
|
||||
public function readSaveData(CompoundTag $nbt) : void{
|
||||
$this->remainingFuelTime = max(0, $nbt->getShort(self::TAG_BURN_TIME, $this->remainingFuelTime, true));
|
||||
$this->remainingFuelTime = max(0, $nbt->getShort(self::TAG_BURN_TIME, $this->remainingFuelTime));
|
||||
|
||||
$this->cookTime = $nbt->getShort(self::TAG_COOK_TIME, $this->cookTime, true);
|
||||
$this->cookTime = $nbt->getShort(self::TAG_COOK_TIME, $this->cookTime);
|
||||
if($this->remainingFuelTime === 0){
|
||||
$this->cookTime = 0;
|
||||
}
|
||||
|
||||
$this->maxFuelTime = $nbt->getShort(self::TAG_MAX_TIME, $this->maxFuelTime, true);
|
||||
$this->maxFuelTime = $nbt->getShort(self::TAG_MAX_TIME, $this->maxFuelTime);
|
||||
if($this->maxFuelTime === 0){
|
||||
$this->maxFuelTime = $this->remainingFuelTime;
|
||||
}
|
||||
|
@ -54,8 +54,8 @@ class ItemFrame extends Spawnable{
|
||||
if(($itemTag = $nbt->getCompoundTag(self::TAG_ITEM)) !== null){
|
||||
$this->item = Item::nbtDeserialize($itemTag);
|
||||
}
|
||||
$this->itemRotation = $nbt->getByte(self::TAG_ITEM_ROTATION, $this->itemRotation, true);
|
||||
$this->itemDropChance = $nbt->getFloat(self::TAG_ITEM_DROP_CHANCE, $this->itemDropChance, true);
|
||||
$this->itemRotation = $nbt->getByte(self::TAG_ITEM_ROTATION, $this->itemRotation);
|
||||
$this->itemDropChance = $nbt->getFloat(self::TAG_ITEM_DROP_CHANCE, $this->itemDropChance);
|
||||
}
|
||||
|
||||
protected function writeSaveData(CompoundTag $nbt) : void{
|
||||
|
@ -58,7 +58,7 @@ class Skull extends Spawnable{
|
||||
//bad data, drop it
|
||||
}
|
||||
}
|
||||
$rotation = $nbt->getByte(self::TAG_ROT, 0, true);
|
||||
$rotation = $nbt->getByte(self::TAG_ROT, 0);
|
||||
if($rotation >= 0 and $rotation <= 15){
|
||||
$this->skullRotation = $rotation;
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ final class TileFactory{
|
||||
* @internal
|
||||
*/
|
||||
public static function createFromData(World $world, CompoundTag $nbt) : ?Tile{
|
||||
$type = $nbt->getString(Tile::TAG_ID, "", true);
|
||||
$type = $nbt->getString(Tile::TAG_ID, "");
|
||||
if(!isset(self::$knownTiles[$type])){
|
||||
return null;
|
||||
}
|
||||
|
@ -248,15 +248,15 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
||||
|
||||
$this->inventory->setHeldItemIndex($nbt->getInt("SelectedInventorySlot", 0), false);
|
||||
|
||||
$this->hungerManager->setFood((float) $nbt->getInt("foodLevel", (int) $this->hungerManager->getFood(), true));
|
||||
$this->hungerManager->setExhaustion($nbt->getFloat("foodExhaustionLevel", $this->hungerManager->getExhaustion(), true));
|
||||
$this->hungerManager->setSaturation($nbt->getFloat("foodSaturationLevel", $this->hungerManager->getSaturation(), true));
|
||||
$this->hungerManager->setFoodTickTimer($nbt->getInt("foodTickTimer", $this->hungerManager->getFoodTickTimer(), true));
|
||||
$this->hungerManager->setFood((float) $nbt->getInt("foodLevel", (int) $this->hungerManager->getFood()));
|
||||
$this->hungerManager->setExhaustion($nbt->getFloat("foodExhaustionLevel", $this->hungerManager->getExhaustion()));
|
||||
$this->hungerManager->setSaturation($nbt->getFloat("foodSaturationLevel", $this->hungerManager->getSaturation()));
|
||||
$this->hungerManager->setFoodTickTimer($nbt->getInt("foodTickTimer", $this->hungerManager->getFoodTickTimer()));
|
||||
|
||||
$this->xpManager->setXpAndProgressNoEvent(
|
||||
$nbt->getInt("XpLevel", 0, true),
|
||||
$nbt->getFloat("XpP", 0.0, true));
|
||||
$this->xpManager->setLifetimeTotalXp($nbt->getInt("XpTotal", 0, true));
|
||||
$nbt->getInt("XpLevel", 0),
|
||||
$nbt->getFloat("XpP", 0.0));
|
||||
$this->xpManager->setLifetimeTotalXp($nbt->getInt("XpTotal", 0));
|
||||
|
||||
if($nbt->hasTag("XpSeed", IntTag::class)){
|
||||
$this->xpSeed = $nbt->getInt("XpSeed");
|
||||
|
@ -60,7 +60,7 @@ class PrimedTNT extends Entity implements Explosive{
|
||||
protected function initEntity(CompoundTag $nbt) : void{
|
||||
parent::initEntity($nbt);
|
||||
|
||||
$this->fuse = $nbt->getShort("Fuse", 80, true);
|
||||
$this->fuse = $nbt->getShort("Fuse", 80);
|
||||
|
||||
$this->getWorld()->addSound($this->location, new IgniteSound());
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ class Arrow extends Projectile{
|
||||
protected function initEntity(CompoundTag $nbt) : void{
|
||||
parent::initEntity($nbt);
|
||||
|
||||
$this->pickupMode = $nbt->getByte(self::TAG_PICKUP, self::PICKUP_ANY, true);
|
||||
$this->pickupMode = $nbt->getByte(self::TAG_PICKUP, self::PICKUP_ANY);
|
||||
$this->collideTicks = $nbt->getShort("life", $this->collideTicks);
|
||||
}
|
||||
|
||||
|
@ -273,7 +273,7 @@ class Item implements \JsonSerializable{
|
||||
|
||||
$display = $tag->getCompoundTag(self::TAG_DISPLAY);
|
||||
if($display !== null){
|
||||
$this->customName = $display->getString(self::TAG_DISPLAY_NAME, $this->customName, true);
|
||||
$this->customName = $display->getString(self::TAG_DISPLAY_NAME, $this->customName);
|
||||
$lore = $display->getListTag(self::TAG_DISPLAY_LORE);
|
||||
if($lore !== null and $lore->getTagType() === NBT::TAG_String){
|
||||
/** @var StringTag $t */
|
||||
@ -288,8 +288,8 @@ class Item implements \JsonSerializable{
|
||||
if($enchantments !== null and $enchantments->getTagType() === NBT::TAG_Compound){
|
||||
/** @var CompoundTag $enchantment */
|
||||
foreach($enchantments as $enchantment){
|
||||
$magicNumber = $enchantment->getShort("id", -1, true);
|
||||
$level = $enchantment->getShort("lvl", 0, true);
|
||||
$magicNumber = $enchantment->getShort("id", -1);
|
||||
$level = $enchantment->getShort("lvl", 0);
|
||||
if($level <= 0){
|
||||
continue;
|
||||
}
|
||||
|
@ -267,7 +267,7 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
||||
|
||||
$spawnReset = false;
|
||||
|
||||
if($namedtag !== null and ($world = $this->server->getWorldManager()->getWorldByName($namedtag->getString("Level", "", true))) !== null){
|
||||
if($namedtag !== null and ($world = $this->server->getWorldManager()->getWorldByName($namedtag->getString("Level", ""))) !== null){
|
||||
/** @var float[] $pos */
|
||||
$pos = $namedtag->getListTag("Pos")->getAllValues();
|
||||
$spawn = new Vector3($pos[0], $pos[1], $pos[2]);
|
||||
|
@ -33,6 +33,8 @@ use pocketmine\block\tile\TileFactory;
|
||||
use pocketmine\entity\Entity;
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\World;
|
||||
use function array_fill;
|
||||
@ -498,7 +500,14 @@ class Chunk{
|
||||
try{
|
||||
$entity = EntityFactory::createFromData($world, $nbt);
|
||||
if(!($entity instanceof Entity)){
|
||||
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type " . $nbt->getString("id", $nbt->getString("identifier", "<unknown>", true), true));
|
||||
$saveIdTag = $nbt->getTag("id") ?? $nbt->getTag("identifier");
|
||||
$saveId = "<unknown>";
|
||||
if($saveIdTag instanceof StringTag){
|
||||
$saveId = $saveIdTag->getValue();
|
||||
}elseif($saveIdTag instanceof IntTag){ //legacy MCPE format
|
||||
$saveId = "legacy(" . $saveIdTag->getValue() . ")";
|
||||
}
|
||||
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown entity type $saveId");
|
||||
continue;
|
||||
}
|
||||
}catch(\Exception $t){ //TODO: this shouldn't be here
|
||||
@ -517,7 +526,7 @@ class Chunk{
|
||||
if(($tile = TileFactory::createFromData($world, $nbt)) !== null){
|
||||
$world->addTile($tile);
|
||||
}else{
|
||||
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>", true));
|
||||
$world->getLogger()->warning("Chunk $this->x $this->z: Deleted unknown tile entity type " . $nbt->getString("id", "<unknown>"));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ namespace pocketmine\world\format\io\data;
|
||||
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\IntTag;
|
||||
use pocketmine\world\format\io\exception\CorruptedWorldException;
|
||||
use pocketmine\world\format\io\exception\UnsupportedWorldFormatException;
|
||||
use pocketmine\world\format\io\WorldData;
|
||||
@ -124,11 +125,14 @@ abstract class BaseNbtWorldData implements WorldData{
|
||||
}
|
||||
|
||||
public function getTime() : int{
|
||||
return $this->compoundTag->getLong("Time", 0, true);
|
||||
if($this->compoundTag->hasTag("Time", IntTag::class)){ //some older PM worlds had this in the wrong format
|
||||
return $this->compoundTag->getInt("Time");
|
||||
}
|
||||
return $this->compoundTag->getLong("Time", 0);
|
||||
}
|
||||
|
||||
public function setTime(int $value) : void{
|
||||
$this->compoundTag->setLong("Time", $value, true); //some older PM worlds had this in the wrong format
|
||||
$this->compoundTag->setLong("Time", $value);
|
||||
}
|
||||
|
||||
public function getSpawn() : Vector3{
|
||||
|
@ -122,7 +122,7 @@ class BedrockWorldData extends BaseNbtWorldData{
|
||||
throw new CorruptedWorldException($e->getMessage(), 0, $e);
|
||||
}
|
||||
|
||||
$version = $worldData->getInt("StorageVersion", Limits::INT32_MAX, true);
|
||||
$version = $worldData->getInt("StorageVersion", Limits::INT32_MAX);
|
||||
if($version > self::CURRENT_STORAGE_VERSION){
|
||||
throw new UnsupportedWorldFormatException("LevelDB world format version $version is currently unsupported");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ class JavaWorldData extends BaseNbtWorldData{
|
||||
|
||||
protected function fix() : void{
|
||||
if(!$this->compoundTag->hasTag("generatorName", StringTag::class)){
|
||||
$this->compoundTag->setString("generatorName", "default", true);
|
||||
$this->compoundTag->setString("generatorName", "default");
|
||||
}elseif(($generatorName = self::hackyFixForGeneratorClasspathInLevelDat($this->compoundTag->getString("generatorName"))) !== null){
|
||||
$this->compoundTag->setString("generatorName", $generatorName);
|
||||
}
|
||||
|
@ -75,7 +75,7 @@ trait LegacyAnvilChunkTrait{
|
||||
if($chunk->hasTag("BiomeColors", IntArrayTag::class)){
|
||||
$biomeIds = ChunkUtils::convertBiomeColors($chunk->getIntArray("BiomeColors")); //Convert back to original format
|
||||
}else{
|
||||
$biomeIds = $chunk->getByteArray("Biomes", "", true);
|
||||
$biomeIds = $chunk->getByteArray("Biomes", "");
|
||||
}
|
||||
|
||||
$result = new Chunk(
|
||||
|
Loading…
x
Reference in New Issue
Block a user