mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 09:19:42 +00:00
Removed useless confusing array indices in CompoundTag constructors (#1116)
This commit is contained in:
parent
e11f1e94e9
commit
a4b8dd43e6
@ -2532,17 +2532,17 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
|
|
||||||
if($item->getId() === Item::SNOWBALL){
|
if($item->getId() === Item::SNOWBALL){
|
||||||
$nbt = new CompoundTag("", [
|
$nbt = new CompoundTag("", [
|
||||||
"Pos" => new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
new DoubleTag("", $this->x),
|
new DoubleTag("", $this->x),
|
||||||
new DoubleTag("", $this->y + $this->getEyeHeight()),
|
new DoubleTag("", $this->y + $this->getEyeHeight()),
|
||||||
new DoubleTag("", $this->z)
|
new DoubleTag("", $this->z)
|
||||||
]),
|
]),
|
||||||
"Motion" => new ListTag("Motion", [
|
new ListTag("Motion", [
|
||||||
new DoubleTag("", $aimPos->x),
|
new DoubleTag("", $aimPos->x),
|
||||||
new DoubleTag("", $aimPos->y),
|
new DoubleTag("", $aimPos->y),
|
||||||
new DoubleTag("", $aimPos->z)
|
new DoubleTag("", $aimPos->z)
|
||||||
]),
|
]),
|
||||||
"Rotation" => new ListTag("Rotation", [
|
new ListTag("Rotation", [
|
||||||
new FloatTag("", $this->yaw),
|
new FloatTag("", $this->yaw),
|
||||||
new FloatTag("", $this->pitch)
|
new FloatTag("", $this->pitch)
|
||||||
]),
|
]),
|
||||||
@ -2627,22 +2627,22 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
|||||||
}
|
}
|
||||||
|
|
||||||
$nbt = new CompoundTag("", [
|
$nbt = new CompoundTag("", [
|
||||||
"Pos" => new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
new DoubleTag("", $this->x),
|
new DoubleTag("", $this->x),
|
||||||
new DoubleTag("", $this->y + $this->getEyeHeight()),
|
new DoubleTag("", $this->y + $this->getEyeHeight()),
|
||||||
new DoubleTag("", $this->z)
|
new DoubleTag("", $this->z)
|
||||||
]),
|
]),
|
||||||
"Motion" => new ListTag("Motion", [
|
new ListTag("Motion", [
|
||||||
new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)),
|
new DoubleTag("", -sin($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI)),
|
||||||
new DoubleTag("", -sin($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))
|
new DoubleTag("", cos($this->yaw / 180 * M_PI) * cos($this->pitch / 180 * M_PI))
|
||||||
]),
|
]),
|
||||||
"Rotation" => new ListTag("Rotation", [
|
new ListTag("Rotation", [
|
||||||
//yaw/pitch for arrows taken crosswise, not along the arrow shaft.
|
//yaw/pitch for arrows taken crosswise, not along the arrow shaft.
|
||||||
new FloatTag("", ($this->yaw > 180 ? 360 : 0) - $this->yaw), //arrow yaw must range from -180 to +180
|
new FloatTag("", ($this->yaw > 180 ? 360 : 0) - $this->yaw), //arrow yaw must range from -180 to +180
|
||||||
new FloatTag("", -$this->pitch)
|
new FloatTag("", -$this->pitch)
|
||||||
]),
|
]),
|
||||||
"Fire" => new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0)
|
new ShortTag("Fire", $this->isOnFire() ? 45 * 60 : 0)
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$diff = ($this->server->getTick() - $this->startAction);
|
$diff = ($this->server->getTick() - $this->startAction);
|
||||||
|
@ -41,22 +41,22 @@ abstract class Fallable extends Solid{
|
|||||||
if($down->getId() === self::AIR or ($down instanceof Liquid)){
|
if($down->getId() === self::AIR or ($down instanceof Liquid)){
|
||||||
$this->level->setBlock($this, Block::get(Block::AIR), true, true);
|
$this->level->setBlock($this, Block::get(Block::AIR), true, true);
|
||||||
$fall = Entity::createEntity("FallingSand", $this->getLevel(), new CompoundTag("", [
|
$fall = Entity::createEntity("FallingSand", $this->getLevel(), new CompoundTag("", [
|
||||||
"Pos" => new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
new DoubleTag("", $this->x + 0.5),
|
new DoubleTag("", $this->x + 0.5),
|
||||||
new DoubleTag("", $this->y),
|
new DoubleTag("", $this->y),
|
||||||
new DoubleTag("", $this->z + 0.5)
|
new DoubleTag("", $this->z + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new ListTag("Motion", [
|
new ListTag("Motion", [
|
||||||
new DoubleTag("", 0),
|
new DoubleTag("", 0),
|
||||||
new DoubleTag("", 0),
|
new DoubleTag("", 0),
|
||||||
new DoubleTag("", 0)
|
new DoubleTag("", 0)
|
||||||
]),
|
]),
|
||||||
"Rotation" => new ListTag("Rotation", [
|
new ListTag("Rotation", [
|
||||||
new FloatTag("", 0),
|
new FloatTag("", 0),
|
||||||
new FloatTag("", 0)
|
new FloatTag("", 0)
|
||||||
]),
|
]),
|
||||||
"TileID" => new IntTag("TileID", $this->getId()),
|
new IntTag("TileID", $this->getId()),
|
||||||
"Data" => new ByteTag("Data", $this->getDamage()),
|
new ByteTag("Data", $this->getDamage()),
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$fall->spawnToAll();
|
$fall->spawnToAll();
|
||||||
|
@ -61,14 +61,14 @@ class SignPost extends Transparent{
|
|||||||
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
public function place(Item $item, Block $block, Block $target, $face, $fx, $fy, $fz, Player $player = null){
|
||||||
if($face !== 0){
|
if($face !== 0){
|
||||||
$nbt = new CompoundTag("", [
|
$nbt = new CompoundTag("", [
|
||||||
"id" => new StringTag("id", Tile::SIGN),
|
new StringTag("id", Tile::SIGN),
|
||||||
"x" => new IntTag("x", $block->x),
|
new IntTag("x", $block->x),
|
||||||
"y" => new IntTag("y", $block->y),
|
new IntTag("y", $block->y),
|
||||||
"z" => new IntTag("z", $block->z),
|
new IntTag("z", $block->z),
|
||||||
"Text1" => new StringTag("Text1", ""),
|
new StringTag("Text1", ""),
|
||||||
"Text2" => new StringTag("Text2", ""),
|
new StringTag("Text2", ""),
|
||||||
"Text3" => new StringTag("Text3", ""),
|
new StringTag("Text3", ""),
|
||||||
"Text4" => new StringTag("Text4", "")
|
new StringTag("Text4", "")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if($player !== null){
|
if($player !== null){
|
||||||
|
@ -68,21 +68,21 @@ class TNT extends Solid{
|
|||||||
|
|
||||||
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
|
$mot = (new Random())->nextSignedFloat() * M_PI * 2;
|
||||||
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel(), new CompoundTag("", [
|
$tnt = Entity::createEntity("PrimedTNT", $this->getLevel(), new CompoundTag("", [
|
||||||
"Pos" => new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
new DoubleTag("", $this->x + 0.5),
|
new DoubleTag("", $this->x + 0.5),
|
||||||
new DoubleTag("", $this->y),
|
new DoubleTag("", $this->y),
|
||||||
new DoubleTag("", $this->z + 0.5)
|
new DoubleTag("", $this->z + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new ListTag("Motion", [
|
new ListTag("Motion", [
|
||||||
new DoubleTag("", -sin($mot) * 0.02),
|
new DoubleTag("", -sin($mot) * 0.02),
|
||||||
new DoubleTag("", 0.2),
|
new DoubleTag("", 0.2),
|
||||||
new DoubleTag("", -cos($mot) * 0.02)
|
new DoubleTag("", -cos($mot) * 0.02)
|
||||||
]),
|
]),
|
||||||
"Rotation" => new ListTag("Rotation", [
|
new ListTag("Rotation", [
|
||||||
new FloatTag("", 0),
|
new FloatTag("", 0),
|
||||||
new FloatTag("", 0)
|
new FloatTag("", 0)
|
||||||
]),
|
]),
|
||||||
"Fuse" => new ByteTag("Fuse", $fuse)
|
new ByteTag("Fuse", $fuse)
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$tnt->spawnToAll();
|
$tnt->spawnToAll();
|
||||||
|
@ -774,11 +774,11 @@ abstract class Entity extends Location implements Metadatable{
|
|||||||
$effects = [];
|
$effects = [];
|
||||||
foreach($this->effects as $effect){
|
foreach($this->effects as $effect){
|
||||||
$effects[] = new CompoundTag("", [
|
$effects[] = new CompoundTag("", [
|
||||||
"Id" => new ByteTag("Id", $effect->getId()),
|
new ByteTag("Id", $effect->getId()),
|
||||||
"Amplifier" => new ByteTag("Amplifier", Binary::signByte($effect->getAmplifier())),
|
new ByteTag("Amplifier", Binary::signByte($effect->getAmplifier())),
|
||||||
"Duration" => new IntTag("Duration", $effect->getDuration()),
|
new IntTag("Duration", $effect->getDuration()),
|
||||||
"Ambient" => new ByteTag("Ambient", 0),
|
new ByteTag("Ambient", 0),
|
||||||
"ShowParticles" => new ByteTag("ShowParticles", $effect->isVisible() ? 1 : 0)
|
new ByteTag("ShowParticles", $effect->isVisible() ? 1 : 0)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -485,8 +485,8 @@ class Human extends Creature implements ProjectileSource, InventoryHolder{
|
|||||||
|
|
||||||
if(strlen($this->getSkinData()) > 0){
|
if(strlen($this->getSkinData()) > 0){
|
||||||
$this->namedtag->Skin = new CompoundTag("Skin", [
|
$this->namedtag->Skin = new CompoundTag("Skin", [
|
||||||
"Data" => new StringTag("Data", $this->getSkinData()),
|
new StringTag("Data", $this->getSkinData()),
|
||||||
"Name" => new StringTag("Name", $this->getSkinId())
|
new StringTag("Name", $this->getSkinId())
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -548,8 +548,8 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
foreach($tag->ench as $k => $entry){
|
foreach($tag->ench as $k => $entry){
|
||||||
if($entry["id"] === $ench->getId()){
|
if($entry["id"] === $ench->getId()){
|
||||||
$tag->ench->{$k} = new CompoundTag("", [
|
$tag->ench->{$k} = new CompoundTag("", [
|
||||||
"id" => new ShortTag("id", $ench->getId()),
|
new ShortTag("id", $ench->getId()),
|
||||||
"lvl" => new ShortTag("lvl", $ench->getLevel())
|
new ShortTag("lvl", $ench->getLevel())
|
||||||
]);
|
]);
|
||||||
$found = true;
|
$found = true;
|
||||||
break;
|
break;
|
||||||
@ -558,8 +558,8 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
|
|
||||||
if(!$found){
|
if(!$found){
|
||||||
$tag->ench->{count($tag->ench) + 1} = new CompoundTag("", [
|
$tag->ench->{count($tag->ench) + 1} = new CompoundTag("", [
|
||||||
"id" => new ShortTag("id", $ench->getId()),
|
new ShortTag("id", $ench->getId()),
|
||||||
"lvl" => new ShortTag("lvl", $ench->getLevel())
|
new ShortTag("lvl", $ench->getLevel())
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -643,7 +643,7 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
$tag->display->Name = new StringTag("Name", $name);
|
$tag->display->Name = new StringTag("Name", $name);
|
||||||
}else{
|
}else{
|
||||||
$tag->display = new CompoundTag("display", [
|
$tag->display = new CompoundTag("display", [
|
||||||
"Name" => new StringTag("Name", $name)
|
new StringTag("Name", $name)
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1009,9 +1009,9 @@ class Item implements ItemIds, \JsonSerializable{
|
|||||||
*/
|
*/
|
||||||
public function nbtSerialize(int $slot = -1, string $tagName = "") : CompoundTag{
|
public function nbtSerialize(int $slot = -1, string $tagName = "") : CompoundTag{
|
||||||
$tag = new CompoundTag($tagName, [
|
$tag = new CompoundTag($tagName, [
|
||||||
"id" => new ShortTag("id", $this->id),
|
new ShortTag("id", $this->id),
|
||||||
"Count" => new ByteTag("Count", Binary::signByte($this->count)),
|
new ByteTag("Count", Binary::signByte($this->count)),
|
||||||
"Damage" => new ShortTag("Damage", $this->meta),
|
new ShortTag("Damage", $this->meta),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
if($this->hasCompoundTag()){
|
if($this->hasCompoundTag()){
|
||||||
|
@ -44,17 +44,17 @@ class SpawnEgg extends Item{
|
|||||||
|
|
||||||
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
public function onActivate(Level $level, Player $player, Block $block, Block $target, $face, $fx, $fy, $fz){
|
||||||
$nbt = new CompoundTag("", [
|
$nbt = new CompoundTag("", [
|
||||||
"Pos" => new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
new DoubleTag("", $block->getX() + 0.5),
|
new DoubleTag("", $block->getX() + 0.5),
|
||||||
new DoubleTag("", $block->getY()),
|
new DoubleTag("", $block->getY()),
|
||||||
new DoubleTag("", $block->getZ() + 0.5)
|
new DoubleTag("", $block->getZ() + 0.5)
|
||||||
]),
|
]),
|
||||||
"Motion" => new ListTag("Motion", [
|
new ListTag("Motion", [
|
||||||
new DoubleTag("", 0),
|
new DoubleTag("", 0),
|
||||||
new DoubleTag("", 0),
|
new DoubleTag("", 0),
|
||||||
new DoubleTag("", 0)
|
new DoubleTag("", 0)
|
||||||
]),
|
]),
|
||||||
"Rotation" => new ListTag("Rotation", [
|
new ListTag("Rotation", [
|
||||||
new FloatTag("", lcg_value() * 360),
|
new FloatTag("", lcg_value() * 360),
|
||||||
new FloatTag("", 0)
|
new FloatTag("", 0)
|
||||||
]),
|
]),
|
||||||
|
@ -1513,24 +1513,23 @@ class Level implements ChunkManager, Metadatable{
|
|||||||
|
|
||||||
if($item->getId() > 0 and $item->getCount() > 0){
|
if($item->getId() > 0 and $item->getCount() > 0){
|
||||||
$itemEntity = Entity::createEntity("Item", $this, new CompoundTag("", [
|
$itemEntity = Entity::createEntity("Item", $this, new CompoundTag("", [
|
||||||
"Pos" => new ListTag("Pos", [
|
new ListTag("Pos", [
|
||||||
new DoubleTag("", $source->getX()),
|
new DoubleTag("", $source->getX()),
|
||||||
new DoubleTag("", $source->getY()),
|
new DoubleTag("", $source->getY()),
|
||||||
new DoubleTag("", $source->getZ())
|
new DoubleTag("", $source->getZ())
|
||||||
]),
|
]),
|
||||||
|
new ListTag("Motion", [
|
||||||
"Motion" => new ListTag("Motion", [
|
|
||||||
new DoubleTag("", $motion->x),
|
new DoubleTag("", $motion->x),
|
||||||
new DoubleTag("", $motion->y),
|
new DoubleTag("", $motion->y),
|
||||||
new DoubleTag("", $motion->z)
|
new DoubleTag("", $motion->z)
|
||||||
]),
|
]),
|
||||||
"Rotation" => new ListTag("Rotation", [
|
new ListTag("Rotation", [
|
||||||
new FloatTag("", lcg_value() * 360),
|
new FloatTag("", lcg_value() * 360),
|
||||||
new FloatTag("", 0)
|
new FloatTag("", 0)
|
||||||
]),
|
]),
|
||||||
"Health" => new ShortTag("Health", 5),
|
new ShortTag("Health", 5),
|
||||||
"Item" => $itemTag,
|
$itemTag,
|
||||||
"PickupDelay" => new ShortTag("PickupDelay", $delay)
|
new ShortTag("PickupDelay", $delay)
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$itemEntity->spawnToAll();
|
$itemEntity->spawnToAll();
|
||||||
|
@ -123,7 +123,7 @@ abstract class BaseLevelProvider implements LevelProvider{
|
|||||||
public function saveLevelData(){
|
public function saveLevelData(){
|
||||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||||
$nbt->setData(new CompoundTag("", [
|
$nbt->setData(new CompoundTag("", [
|
||||||
"Data" => $this->levelData
|
$this->levelData
|
||||||
]));
|
]));
|
||||||
$buffer = $nbt->writeCompressed();
|
$buffer = $nbt->writeCompressed();
|
||||||
file_put_contents($this->getPath() . "level.dat", $buffer);
|
file_put_contents($this->getPath() . "level.dat", $buffer);
|
||||||
|
@ -155,39 +155,39 @@ class LevelDB extends BaseLevelProvider{
|
|||||||
|
|
||||||
$levelData = new CompoundTag("", [
|
$levelData = new CompoundTag("", [
|
||||||
//Vanilla fields
|
//Vanilla fields
|
||||||
"DayCycleStopTime" => new IntTag("DayCycleStopTime", -1),
|
new IntTag("DayCycleStopTime", -1),
|
||||||
"Difficulty" => new IntTag("Difficulty", 2),
|
new IntTag("Difficulty", 2),
|
||||||
"ForceGameType" => new ByteTag("ForceGameType", 0),
|
new ByteTag("ForceGameType", 0),
|
||||||
"GameType" => new IntTag("GameType", 0),
|
new IntTag("GameType", 0),
|
||||||
"Generator" => new IntTag("Generator", $generatorType),
|
new IntTag("Generator", $generatorType),
|
||||||
"LastPlayed" => new LongTag("LastPlayed", time()),
|
new LongTag("LastPlayed", time()),
|
||||||
"LevelName" => new StringTag("LevelName", $name),
|
new StringTag("LevelName", $name),
|
||||||
"NetworkVersion" => new IntTag("NetworkVersion", ProtocolInfo::CURRENT_PROTOCOL),
|
new IntTag("NetworkVersion", ProtocolInfo::CURRENT_PROTOCOL),
|
||||||
//"Platform" => new IntTag("Platform", 2), //TODO: find out what the possible values are for
|
//new IntTag("Platform", 2), //TODO: find out what the possible values are for
|
||||||
"RandomSeed" => new LongTag("RandomSeed", $seed),
|
new LongTag("RandomSeed", $seed),
|
||||||
"SpawnX" => new IntTag("SpawnX", 0),
|
new IntTag("SpawnX", 0),
|
||||||
"SpawnY" => new IntTag("SpawnY", 32767),
|
new IntTag("SpawnY", 32767),
|
||||||
"SpawnZ" => new IntTag("SpawnZ", 0),
|
new IntTag("SpawnZ", 0),
|
||||||
"StorageVersion" => new IntTag("StorageVersion", self::CURRENT_STORAGE_VERSION),
|
new IntTag("StorageVersion", self::CURRENT_STORAGE_VERSION),
|
||||||
"Time" => new LongTag("Time", 0),
|
new LongTag("Time", 0),
|
||||||
"eduLevel" => new ByteTag("eduLevel", 0),
|
new ByteTag("eduLevel", 0),
|
||||||
"falldamage" => new ByteTag("falldamage", 1),
|
new ByteTag("falldamage", 1),
|
||||||
"firedamage" => new ByteTag("firedamage", 1),
|
new ByteTag("firedamage", 1),
|
||||||
"hasBeenLoadedInCreative" => new ByteTag("hasBeenLoadedInCreative", 1), //badly named, this actually determines whether achievements can be earned in this world...
|
new ByteTag("hasBeenLoadedInCreative", 1), //badly named, this actually determines whether achievements can be earned in this world...
|
||||||
"immutableWorld" => new ByteTag("immutableWorld", 0),
|
new ByteTag("immutableWorld", 0),
|
||||||
"lightningLevel" => new FloatTag("lightningLevel", 0.0),
|
new FloatTag("lightningLevel", 0.0),
|
||||||
"lightningTime" => new IntTag("lightningTime", 0),
|
new IntTag("lightningTime", 0),
|
||||||
"pvp" => new ByteTag("pvp", 1),
|
new ByteTag("pvp", 1),
|
||||||
"rainLevel" => new FloatTag("rainLevel", 0.0),
|
new FloatTag("rainLevel", 0.0),
|
||||||
"rainTime" => new IntTag("rainTime", 0),
|
new IntTag("rainTime", 0),
|
||||||
"spawnMobs" => new ByteTag("spawnMobs", 1),
|
new ByteTag("spawnMobs", 1),
|
||||||
"texturePacksRequired" => new ByteTag("texturePacksRequired", 0), //TODO
|
new ByteTag("texturePacksRequired", 0), //TODO
|
||||||
|
|
||||||
//Additional PocketMine-MP fields
|
//Additional PocketMine-MP fields
|
||||||
"GameRules" => new CompoundTag("GameRules", []),
|
new CompoundTag("GameRules", []),
|
||||||
"hardcore" => new ByteTag("hardcore", 0),
|
new ByteTag("hardcore", 0),
|
||||||
"generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)),
|
new StringTag("generatorName", Generator::getGeneratorName($generator)),
|
||||||
"generatorOptions" => new StringTag("generatorOptions", $options["preset"] ?? "")
|
new StringTag("generatorOptions", $options["preset"] ?? "")
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
$nbt = new NBT(NBT::LITTLE_ENDIAN);
|
||||||
|
@ -57,11 +57,11 @@ class Anvil extends McRegion{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$nbt->Sections[++$subChunks] = new CompoundTag("", [
|
$nbt->Sections[++$subChunks] = new CompoundTag("", [
|
||||||
"Y" => new ByteTag("Y", $y),
|
new ByteTag("Y", $y),
|
||||||
"Blocks" => new ByteArrayTag("Blocks", ChunkUtils::reorderByteArray($subChunk->getBlockIdArray())), //Generic in-memory chunks are currently always XZY
|
new ByteArrayTag("Blocks", ChunkUtils::reorderByteArray($subChunk->getBlockIdArray())), //Generic in-memory chunks are currently always XZY
|
||||||
"Data" => new ByteArrayTag("Data", ChunkUtils::reorderNibbleArray($subChunk->getBlockDataArray())),
|
new ByteArrayTag("Data", ChunkUtils::reorderNibbleArray($subChunk->getBlockDataArray())),
|
||||||
"SkyLight" => new ByteArrayTag("SkyLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockSkyLightArray(), "\xff")),
|
new ByteArrayTag("SkyLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockSkyLightArray(), "\xff")),
|
||||||
"BlockLight" => new ByteArrayTag("BlockLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockLightArray()))
|
new ByteArrayTag("BlockLight", ChunkUtils::reorderNibbleArray($subChunk->getBlockLightArray()))
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ class Anvil extends McRegion{
|
|||||||
|
|
||||||
$writer = new NBT(NBT::BIG_ENDIAN);
|
$writer = new NBT(NBT::BIG_ENDIAN);
|
||||||
$nbt->setName("Level");
|
$nbt->setName("Level");
|
||||||
$writer->setData(new CompoundTag("", ["Level" => $nbt]));
|
$writer->setData(new CompoundTag("", [$nbt]));
|
||||||
|
|
||||||
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
|
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ class McRegion extends BaseLevelProvider{
|
|||||||
|
|
||||||
$writer = new NBT(NBT::BIG_ENDIAN);
|
$writer = new NBT(NBT::BIG_ENDIAN);
|
||||||
$nbt->setName("Level");
|
$nbt->setName("Level");
|
||||||
$writer->setData(new CompoundTag("", ["Level" => $nbt]));
|
$writer->setData(new CompoundTag("", [$nbt]));
|
||||||
|
|
||||||
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
|
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
|
||||||
}
|
}
|
||||||
@ -248,27 +248,27 @@ class McRegion extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
//TODO, add extra details
|
//TODO, add extra details
|
||||||
$levelData = new CompoundTag("Data", [
|
$levelData = new CompoundTag("Data", [
|
||||||
"hardcore" => new ByteTag("hardcore", 0),
|
new ByteTag("hardcore", 0),
|
||||||
"initialized" => new ByteTag("initialized", 1),
|
new ByteTag("initialized", 1),
|
||||||
"GameType" => new IntTag("GameType", 0),
|
new IntTag("GameType", 0),
|
||||||
"generatorVersion" => new IntTag("generatorVersion", 1), //2 in MCPE
|
new IntTag("generatorVersion", 1), //2 in MCPE
|
||||||
"SpawnX" => new IntTag("SpawnX", 256),
|
new IntTag("SpawnX", 256),
|
||||||
"SpawnY" => new IntTag("SpawnY", 70),
|
new IntTag("SpawnY", 70),
|
||||||
"SpawnZ" => new IntTag("SpawnZ", 256),
|
new IntTag("SpawnZ", 256),
|
||||||
"version" => new IntTag("version", static::getPcWorldFormatVersion()),
|
new IntTag("version", static::getPcWorldFormatVersion()),
|
||||||
"DayTime" => new IntTag("DayTime", 0),
|
new IntTag("DayTime", 0),
|
||||||
"LastPlayed" => new LongTag("LastPlayed", (int) (microtime(true) * 1000)),
|
new LongTag("LastPlayed", (int) (microtime(true) * 1000)),
|
||||||
"RandomSeed" => new LongTag("RandomSeed", $seed),
|
new LongTag("RandomSeed", $seed),
|
||||||
"SizeOnDisk" => new LongTag("SizeOnDisk", 0),
|
new LongTag("SizeOnDisk", 0),
|
||||||
"Time" => new LongTag("Time", 0),
|
new LongTag("Time", 0),
|
||||||
"generatorName" => new StringTag("generatorName", Generator::getGeneratorName($generator)),
|
new StringTag("generatorName", Generator::getGeneratorName($generator)),
|
||||||
"generatorOptions" => new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""),
|
new StringTag("generatorOptions", isset($options["preset"]) ? $options["preset"] : ""),
|
||||||
"LevelName" => new StringTag("LevelName", $name),
|
new StringTag("LevelName", $name),
|
||||||
"GameRules" => new CompoundTag("GameRules", [])
|
new CompoundTag("GameRules", [])
|
||||||
]);
|
]);
|
||||||
$nbt = new NBT(NBT::BIG_ENDIAN);
|
$nbt = new NBT(NBT::BIG_ENDIAN);
|
||||||
$nbt->setData(new CompoundTag("", [
|
$nbt->setData(new CompoundTag("", [
|
||||||
"Data" => $levelData
|
$levelData
|
||||||
]));
|
]));
|
||||||
$buffer = $nbt->writeCompressed();
|
$buffer = $nbt->writeCompressed();
|
||||||
file_put_contents($path . "level.dat", $buffer);
|
file_put_contents($path . "level.dat", $buffer);
|
||||||
|
@ -60,11 +60,11 @@ class PMAnvil extends Anvil{
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$nbt->Sections[++$subChunks] = new CompoundTag("", [
|
$nbt->Sections[++$subChunks] = new CompoundTag("", [
|
||||||
"Y" => new ByteTag("Y", $y),
|
new ByteTag("Y", $y),
|
||||||
"Blocks" => new ByteArrayTag("Blocks", $subChunk->getBlockIdArray()),
|
new ByteArrayTag("Blocks", $subChunk->getBlockIdArray()),
|
||||||
"Data" => new ByteArrayTag("Data", $subChunk->getBlockDataArray()),
|
new ByteArrayTag("Data", $subChunk->getBlockDataArray()),
|
||||||
"SkyLight" => new ByteArrayTag("SkyLight", $subChunk->getBlockSkyLightArray()),
|
new ByteArrayTag("SkyLight", $subChunk->getBlockSkyLightArray()),
|
||||||
"BlockLight" => new ByteArrayTag("BlockLight", $subChunk->getBlockLightArray())
|
new ByteArrayTag("BlockLight", $subChunk->getBlockLightArray())
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ class PMAnvil extends Anvil{
|
|||||||
|
|
||||||
$writer = new NBT(NBT::BIG_ENDIAN);
|
$writer = new NBT(NBT::BIG_ENDIAN);
|
||||||
$nbt->setName("Level");
|
$nbt->setName("Level");
|
||||||
$writer->setData(new CompoundTag("", ["Level" => $nbt]));
|
$writer->setData(new CompoundTag("", [$nbt]));
|
||||||
|
|
||||||
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
|
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user