Removed useless confusing array indices in CompoundTag constructors (#1116)

This commit is contained in:
Dylan K. Taylor
2017-06-20 12:11:24 +01:00
committed by GitHub
parent e11f1e94e9
commit a4b8dd43e6
14 changed files with 111 additions and 112 deletions

View File

@ -1513,24 +1513,23 @@ class Level implements ChunkManager, Metadatable{
if($item->getId() > 0 and $item->getCount() > 0){
$itemEntity = Entity::createEntity("Item", $this, new CompoundTag("", [
"Pos" => new ListTag("Pos", [
new ListTag("Pos", [
new DoubleTag("", $source->getX()),
new DoubleTag("", $source->getY()),
new DoubleTag("", $source->getZ())
]),
"Motion" => new ListTag("Motion", [
new ListTag("Motion", [
new DoubleTag("", $motion->x),
new DoubleTag("", $motion->y),
new DoubleTag("", $motion->z)
]),
"Rotation" => new ListTag("Rotation", [
new ListTag("Rotation", [
new FloatTag("", lcg_value() * 360),
new FloatTag("", 0)
]),
"Health" => new ShortTag("Health", 5),
"Item" => $itemTag,
"PickupDelay" => new ShortTag("PickupDelay", $delay)
new ShortTag("Health", 5),
$itemTag,
new ShortTag("PickupDelay", $delay)
]));
$itemEntity->spawnToAll();

View File

@ -123,7 +123,7 @@ abstract class BaseLevelProvider implements LevelProvider{
public function saveLevelData(){
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->setData(new CompoundTag("", [
"Data" => $this->levelData
$this->levelData
]));
$buffer = $nbt->writeCompressed();
file_put_contents($this->getPath() . "level.dat", $buffer);

View File

@ -155,39 +155,39 @@ class LevelDB extends BaseLevelProvider{
$levelData = new CompoundTag("", [
//Vanilla fields
"DayCycleStopTime" => new IntTag("DayCycleStopTime", -1),
"Difficulty" => new IntTag("Difficulty", 2),
"ForceGameType" => new ByteTag("ForceGameType", 0),
"GameType" => new IntTag("GameType", 0),
"Generator" => new IntTag("Generator", $generatorType),
"LastPlayed" => new LongTag("LastPlayed", time()),
"LevelName" => new StringTag("LevelName", $name),
"NetworkVersion" => new IntTag("NetworkVersion", ProtocolInfo::CURRENT_PROTOCOL),
//"Platform" => new IntTag("Platform", 2), //TODO: find out what the possible values are for
"RandomSeed" => new LongTag("RandomSeed", $seed),
"SpawnX" => new IntTag("SpawnX", 0),
"SpawnY" => new IntTag("SpawnY", 32767),
"SpawnZ" => new IntTag("SpawnZ", 0),
"StorageVersion" => new IntTag("StorageVersion", self::CURRENT_STORAGE_VERSION),
"Time" => new LongTag("Time", 0),
"eduLevel" => new ByteTag("eduLevel", 0),
"falldamage" => new ByteTag("falldamage", 1),
"firedamage" => new ByteTag("firedamage", 1),
"hasBeenLoadedInCreative" => new ByteTag("hasBeenLoadedInCreative", 1), //badly named, this actually determines whether achievements can be earned in this world...
"immutableWorld" => new ByteTag("immutableWorld", 0),
"lightningLevel" => new FloatTag("lightningLevel", 0.0),
"lightningTime" => new IntTag("lightningTime", 0),
"pvp" => new ByteTag("pvp", 1),
"rainLevel" => new FloatTag("rainLevel", 0.0),
"rainTime" => new IntTag("rainTime", 0),
"spawnMobs" => new ByteTag("spawnMobs", 1),
"texturePacksRequired" => new ByteTag("texturePacksRequired", 0), //TODO
new IntTag("DayCycleStopTime", -1),
new IntTag("Difficulty", 2),
new ByteTag("ForceGameType", 0),
new IntTag("GameType", 0),
new IntTag("Generator", $generatorType),
new LongTag("LastPlayed", time()),
new StringTag("LevelName", $name),
new IntTag("NetworkVersion", ProtocolInfo::CURRENT_PROTOCOL),
//new IntTag("Platform", 2), //TODO: find out what the possible values are for
new LongTag("RandomSeed", $seed),
new IntTag("SpawnX", 0),
new IntTag("SpawnY", 32767),
new IntTag("SpawnZ", 0),
new IntTag("StorageVersion", self::CURRENT_STORAGE_VERSION),
new LongTag("Time", 0),
new ByteTag("eduLevel", 0),
new ByteTag("falldamage", 1),
new ByteTag("firedamage", 1),
new ByteTag("hasBeenLoadedInCreative", 1), //badly named, this actually determines whether achievements can be earned in this world...
new ByteTag("immutableWorld", 0),
new FloatTag("lightningLevel", 0.0),
new IntTag("lightningTime", 0),
new ByteTag("pvp", 1),
new FloatTag("rainLevel", 0.0),
new IntTag("rainTime", 0),
new ByteTag("spawnMobs", 1),
new ByteTag("texturePacksRequired", 0), //TODO
//Additional PocketMine-MP fields
"GameRules" => new CompoundTag("GameRules", []),
"hardcore" => new ByteTag("hardcore", 0),
"generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)),
"generatorOptions" => new StringTag("generatorOptions", $options["preset"] ?? "")
new CompoundTag("GameRules", []),
new ByteTag("hardcore", 0),
new StringTag("generatorName", Generator::getGeneratorName($generator)),
new StringTag("generatorOptions", $options["preset"] ?? "")
]);
$nbt = new NBT(NBT::LITTLE_ENDIAN);

View File

@ -57,11 +57,11 @@ class Anvil extends McRegion{
continue;
}
$nbt->Sections[++$subChunks] = new CompoundTag("", [
"Y" => new ByteTag("Y", $y),
"Blocks" => new ByteArrayTag("Blocks", ChunkUtils::reorderByteArray($subChunk->getBlockIdArray())), //Generic in-memory chunks are currently always XZY
"Data" => new ByteArrayTag("Data", ChunkUtils::reorderNibbleArray($subChunk->getBlockDataArray())),
"SkyLight" => new ByteArrayTag("SkyLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockSkyLightArray(), "\xff")),
"BlockLight" => new ByteArrayTag("BlockLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockLightArray()))
new ByteTag("Y", $y),
new ByteArrayTag("Blocks", ChunkUtils::reorderByteArray($subChunk->getBlockIdArray())), //Generic in-memory chunks are currently always XZY
new ByteArrayTag("Data", ChunkUtils::reorderNibbleArray($subChunk->getBlockDataArray())),
new ByteArrayTag("SkyLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockSkyLightArray(), "\xff")),
new ByteArrayTag("BlockLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockLightArray()))
]);
}
@ -93,7 +93,7 @@ class Anvil extends McRegion{
$writer = new NBT(NBT::BIG_ENDIAN);
$nbt->setName("Level");
$writer->setData(new CompoundTag("", ["Level" => $nbt]));
$writer->setData(new CompoundTag("", [$nbt]));
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
}

View File

@ -109,7 +109,7 @@ class McRegion extends BaseLevelProvider{
$writer = new NBT(NBT::BIG_ENDIAN);
$nbt->setName("Level");
$writer->setData(new CompoundTag("", ["Level" => $nbt]));
$writer->setData(new CompoundTag("", [$nbt]));
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
}
@ -248,27 +248,27 @@ class McRegion extends BaseLevelProvider{
}
//TODO, add extra details
$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", 256),
"SpawnY" => new IntTag("SpawnY", 70),
"SpawnZ" => new IntTag("SpawnZ", 256),
"version" => new IntTag("version", static::getPcWorldFormatVersion()),
"DayTime" => new IntTag("DayTime", 0),
"LastPlayed" => new LongTag("LastPlayed", (int) (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", [])
new ByteTag("hardcore", 0),
new ByteTag("initialized", 1),
new IntTag("GameType", 0),
new IntTag("generatorVersion", 1), //2 in MCPE
new IntTag("SpawnX", 256),
new IntTag("SpawnY", 70),
new IntTag("SpawnZ", 256),
new IntTag("version", static::getPcWorldFormatVersion()),
new IntTag("DayTime", 0),
new LongTag("LastPlayed", (int) (microtime(true) * 1000)),
new LongTag("RandomSeed", $seed),
new LongTag("SizeOnDisk", 0),
new LongTag("Time", 0),
new StringTag("generatorName", Generator::getGeneratorName($generator)),
new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""),
new StringTag("LevelName", $name),
new CompoundTag("GameRules", [])
]);
$nbt = new NBT(NBT::BIG_ENDIAN);
$nbt->setData(new CompoundTag("", [
"Data" => $levelData
$levelData
]));
$buffer = $nbt->writeCompressed();
file_put_contents($path . "level.dat", $buffer);

View File

@ -60,11 +60,11 @@ class PMAnvil extends Anvil{
continue;
}
$nbt->Sections[++$subChunks] = new CompoundTag("", [
"Y" => new ByteTag("Y", $y),
"Blocks" => new ByteArrayTag("Blocks", $subChunk->getBlockIdArray()),
"Data" => new ByteArrayTag("Data", $subChunk->getBlockDataArray()),
"SkyLight" => new ByteArrayTag("SkyLight", $subChunk->getBlockSkyLightArray()),
"BlockLight" => new ByteArrayTag("BlockLight", $subChunk->getBlockLightArray())
new ByteTag("Y", $y),
new ByteArrayTag("Blocks", $subChunk->getBlockIdArray()),
new ByteArrayTag("Data", $subChunk->getBlockDataArray()),
new ByteArrayTag("SkyLight", $subChunk->getBlockSkyLightArray()),
new ByteArrayTag("BlockLight", $subChunk->getBlockLightArray())
]);
}
@ -96,7 +96,7 @@ class PMAnvil extends Anvil{
$writer = new NBT(NBT::BIG_ENDIAN);
$nbt->setName("Level");
$writer->setData(new CompoundTag("", ["Level" => $nbt]));
$writer->setData(new CompoundTag("", [$nbt]));
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
}