Merge branch '3.6'

This commit is contained in:
Dylan K. Taylor 2019-02-09 19:22:00 +00:00
commit 0c89159cf2
20 changed files with 422 additions and 126 deletions

2
composer.lock generated
View File

@ -277,7 +277,7 @@
{
"name": "Berry Langerak",
"email": "berry@berryllium.nl",
"role": "Developer"
"role": "developer"
},
{
"name": "Rick van der Staaij",

View File

@ -0,0 +1,251 @@
{
"minecraft:air": 0,
"minecraft:stone": 1,
"minecraft:grass": 2,
"minecraft:dirt": 3,
"minecraft:cobblestone": 4,
"minecraft:planks": 5,
"minecraft:sapling": 6,
"minecraft:bedrock": 7,
"minecraft:flowing_water": 8,
"minecraft:water": 9,
"minecraft:flowing_lava": 10,
"minecraft:lava": 11,
"minecraft:sand": 12,
"minecraft:gravel": 13,
"minecraft:gold_ore": 14,
"minecraft:iron_ore": 15,
"minecraft:coal_ore": 16,
"minecraft:log": 17,
"minecraft:leaves": 18,
"minecraft:sponge": 19,
"minecraft:glass": 20,
"minecraft:lapis_ore": 21,
"minecraft:lapis_block": 22,
"minecraft:dispenser": 23,
"minecraft:sandstone": 24,
"minecraft:noteblock": 25,
"minecraft:bed": 26,
"minecraft:golden_rail": 27,
"minecraft:detector_rail": 28,
"minecraft:sticky_piston": 29,
"minecraft:web": 30,
"minecraft:tallgrass": 31,
"minecraft:deadbush": 32,
"minecraft:piston": 33,
"minecraft:pistonArmCollision": 34,
"minecraft:wool": 35,
"minecraft:element_0": 36,
"minecraft:yellow_flower": 37,
"minecraft:red_flower": 38,
"minecraft:brown_mushroom": 39,
"minecraft:red_mushroom": 40,
"minecraft:gold_block": 41,
"minecraft:iron_block": 42,
"minecraft:double_stone_slab": 43,
"minecraft:stone_slab": 44,
"minecraft:brick_block": 45,
"minecraft:tnt": 46,
"minecraft:bookshelf": 47,
"minecraft:mossy_cobblestone": 48,
"minecraft:obsidian": 49,
"minecraft:torch": 50,
"minecraft:fire": 51,
"minecraft:mob_spawner": 52,
"minecraft:oak_stairs": 53,
"minecraft:chest": 54,
"minecraft:redstone_wire": 55,
"minecraft:diamond_ore": 56,
"minecraft:diamond_block": 57,
"minecraft:crafting_table": 58,
"minecraft:wheat": 59,
"minecraft:farmland": 60,
"minecraft:furnace": 61,
"minecraft:lit_furnace": 62,
"minecraft:standing_sign": 63,
"minecraft:wooden_door": 64,
"minecraft:ladder": 65,
"minecraft:rail": 66,
"minecraft:stone_stairs": 67,
"minecraft:wall_sign": 68,
"minecraft:lever": 69,
"minecraft:stone_pressure_plate": 70,
"minecraft:iron_door": 71,
"minecraft:wooden_pressure_plate": 72,
"minecraft:redstone_ore": 73,
"minecraft:lit_redstone_ore": 74,
"minecraft:unlit_redstone_torch": 75,
"minecraft:redstone_torch": 76,
"minecraft:stone_button": 77,
"minecraft:snow_layer": 78,
"minecraft:ice": 79,
"minecraft:snow": 80,
"minecraft:cactus": 81,
"minecraft:clay": 82,
"minecraft:reeds": 83,
"minecraft:jukebox": 84,
"minecraft:fence": 85,
"minecraft:pumpkin": 86,
"minecraft:netherrack": 87,
"minecraft:soul_sand": 88,
"minecraft:glowstone": 89,
"minecraft:portal": 90,
"minecraft:lit_pumpkin": 91,
"minecraft:cake": 92,
"minecraft:unpowered_repeater": 93,
"minecraft:powered_repeater": 94,
"minecraft:invisibleBedrock": 95,
"minecraft:trapdoor": 96,
"minecraft:monster_egg": 97,
"minecraft:stonebrick": 98,
"minecraft:brown_mushroom_block": 99,
"minecraft:red_mushroom_block": 100,
"minecraft:iron_bars": 101,
"minecraft:glass_pane": 102,
"minecraft:melon_block": 103,
"minecraft:pumpkin_stem": 104,
"minecraft:melon_stem": 105,
"minecraft:vine": 106,
"minecraft:fence_gate": 107,
"minecraft:brick_stairs": 108,
"minecraft:stone_brick_stairs": 109,
"minecraft:mycelium": 110,
"minecraft:waterlily": 111,
"minecraft:nether_brick": 112,
"minecraft:nether_brick_fence": 113,
"minecraft:nether_brick_stairs": 114,
"minecraft:nether_wart": 115,
"minecraft:enchanting_table": 116,
"minecraft:brewing_stand": 117,
"minecraft:cauldron": 118,
"minecraft:end_portal": 119,
"minecraft:end_portal_frame": 120,
"minecraft:end_stone": 121,
"minecraft:dragon_egg": 122,
"minecraft:redstone_lamp": 123,
"minecraft:lit_redstone_lamp": 124,
"minecraft:dropper": 125,
"minecraft:activator_rail": 126,
"minecraft:cocoa": 127,
"minecraft:sandstone_stairs": 128,
"minecraft:emerald_ore": 129,
"minecraft:ender_chest": 130,
"minecraft:tripwire_hook": 131,
"minecraft:tripWire": 132,
"minecraft:emerald_block": 133,
"minecraft:spruce_stairs": 134,
"minecraft:birch_stairs": 135,
"minecraft:jungle_stairs": 136,
"minecraft:command_block": 137,
"minecraft:beacon": 138,
"minecraft:cobblestone_wall": 139,
"minecraft:flower_pot": 140,
"minecraft:carrots": 141,
"minecraft:potatoes": 142,
"minecraft:wooden_button": 143,
"minecraft:skull": 144,
"minecraft:anvil": 145,
"minecraft:trapped_chest": 146,
"minecraft:light_weighted_pressure_plate": 147,
"minecraft:heavy_weighted_pressure_plate": 148,
"minecraft:unpowered_comparator": 149,
"minecraft:powered_comparator": 150,
"minecraft:daylight_detector": 151,
"minecraft:redstone_block": 152,
"minecraft:quartz_ore": 153,
"minecraft:hopper": 154,
"minecraft:quartz_block": 155,
"minecraft:quartz_stairs": 156,
"minecraft:double_wooden_slab": 157,
"minecraft:wooden_slab": 158,
"minecraft:stained_hardened_clay": 159,
"minecraft:stained_glass_pane": 160,
"minecraft:leaves2": 161,
"minecraft:log2": 162,
"minecraft:acacia_stairs": 163,
"minecraft:dark_oak_stairs": 164,
"minecraft:slime": 165,
"minecraft:iron_trapdoor": 167,
"minecraft:prismarine": 168,
"minecraft:seaLantern": 169,
"minecraft:hay_block": 170,
"minecraft:carpet": 171,
"minecraft:hardened_clay": 172,
"minecraft:coal_block": 173,
"minecraft:packed_ice": 174,
"minecraft:double_plant": 175,
"minecraft:standing_banner": 176,
"minecraft:wall_banner": 177,
"minecraft:daylight_detector_inverted": 178,
"minecraft:red_sandstone": 179,
"minecraft:red_sandstone_stairs": 180,
"minecraft:double_stone_slab2": 181,
"minecraft:stone_slab2": 182,
"minecraft:spruce_fence_gate": 183,
"minecraft:birch_fence_gate": 184,
"minecraft:jungle_fence_gate": 185,
"minecraft:dark_oak_fence_gate": 186,
"minecraft:acacia_fence_gate": 187,
"minecraft:repeating_command_block": 188,
"minecraft:chain_command_block": 189,
"minecraft:hard_glass_pane": 190,
"minecraft:hard_stained_glass_pane": 191,
"minecraft:chemical_heat": 192,
"minecraft:spruce_door": 193,
"minecraft:birch_door": 194,
"minecraft:jungle_door": 195,
"minecraft:acacia_door": 196,
"minecraft:dark_oak_door": 197,
"minecraft:grass_path": 198,
"minecraft:frame": 199,
"minecraft:chorus_flower": 200,
"minecraft:purpur_block": 201,
"minecraft:colored_torch_rg": 202,
"minecraft:purpur_stairs": 203,
"minecraft:colored_torch_bp": 204,
"minecraft:undyed_shulker_box": 205,
"minecraft:end_bricks": 206,
"minecraft:frosted_ice": 207,
"minecraft:end_rod": 208,
"minecraft:end_gateway": 209,
"minecraft:magma": 213,
"minecraft:nether_wart_block": 214,
"minecraft:red_nether_brick": 215,
"minecraft:bone_block": 216,
"minecraft:shulker_box": 218,
"minecraft:purple_glazed_terracotta": 219,
"minecraft:white_glazed_terracotta": 220,
"minecraft:orange_glazed_terracotta": 221,
"minecraft:magenta_glazed_terracotta": 222,
"minecraft:light_blue_glazed_terracotta": 223,
"minecraft:yellow_glazed_terracotta": 224,
"minecraft:lime_glazed_terracotta": 225,
"minecraft:pink_glazed_terracotta": 226,
"minecraft:gray_glazed_terracotta": 227,
"minecraft:silver_glazed_terracotta": 228,
"minecraft:cyan_glazed_terracotta": 229,
"minecraft:blue_glazed_terracotta": 231,
"minecraft:brown_glazed_terracotta": 232,
"minecraft:green_glazed_terracotta": 233,
"minecraft:red_glazed_terracotta": 234,
"minecraft:black_glazed_terracotta": 235,
"minecraft:concrete": 236,
"minecraft:concretePowder": 237,
"minecraft:chemistry_table": 238,
"minecraft:underwater_torch": 239,
"minecraft:chorus_plant": 240,
"minecraft:stained_glass": 241,
"minecraft:podzol": 243,
"minecraft:beetroot": 244,
"minecraft:stonecutter": 245,
"minecraft:glowingobsidian": 246,
"minecraft:netherreactor": 247,
"minecraft:info_update": 248,
"minecraft:info_update2": 249,
"minecraft:movingBlock": 250,
"minecraft:observer": 251,
"minecraft:structure_block": 252,
"minecraft:hard_glass": 253,
"minecraft:hard_stained_glass": 254,
"minecraft:reserved6": 255
}

File diff suppressed because one or more lines are too long

@ -1 +1 @@
Subproject commit b9247957dad663760f22842836844cfcd4b0c03e
Subproject commit 90c5fcd4ab8a839f84f686b42f671e3900977fde

View File

@ -189,7 +189,13 @@ class BlockFactory{
new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 6, "Quartz"),
new StoneSlab(Block::STONE_SLAB, Block::DOUBLE_STONE_SLAB, 7, "Nether Brick"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 0, "Red Sandstone"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 1, "Purpur")
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 1, "Purpur"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 2, "Prismarine"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 3, "Dark Prismarine"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 4, "Prismarine Bricks"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 5, "Mossy Cobblestone"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 6, "Smooth Sandstone"),
new StoneSlab(Block::STONE_SLAB2, Block::DOUBLE_STONE_SLAB2, 7, "Red Nether Brick")
];
foreach(WoodType::ALL as $woodType){
$slabTypes[] = new WoodenSlab($woodType);
@ -301,8 +307,25 @@ class BlockFactory{
//TODO: COMMAND_BLOCK
//TODO: BEACON
self::registerBlock(new CobblestoneWall(Block::COBBLESTONE_WALL, CobblestoneWall::NONE_MOSSY_WALL, "Cobblestone Wall"));
self::registerBlock(new CobblestoneWall(Block::COBBLESTONE_WALL, CobblestoneWall::MOSSY_WALL, "Mossy Cobblestone Wall"));
static $wallTypes = [
CobblestoneWall::NONE_MOSSY_WALL => "Cobblestone",
CobblestoneWall::MOSSY_WALL => "Mossy Cobblestone",
CobblestoneWall::GRANITE_WALL => "Granite",
CobblestoneWall::DIORITE_WALL => "Diorite",
CobblestoneWall::ANDESITE_WALL => "Andesite",
CobblestoneWall::SANDSTONE_WALL => "Sandstone",
CobblestoneWall::BRICK_WALL => "Brick",
CobblestoneWall::STONE_BRICK_WALL => "Stone Brick",
CobblestoneWall::MOSSY_STONE_BRICK_WALL => "Mossy Stone Brick",
CobblestoneWall::NETHER_BRICK_WALL => "Nether Brick",
CobblestoneWall::END_STONE_BRICK_WALL => "End Stone Brick",
CobblestoneWall::PRISMARINE_WALL => "Prismarine",
CobblestoneWall::RED_SANDSTONE_WALL => "Red Sandstone",
CobblestoneWall::RED_NETHER_BRICK_WALL => "Red Nether Brick"
];
foreach($wallTypes as $magicNumber => $prefix){
self::registerBlock(new CobblestoneWall(Block::COBBLESTONE_WALL, $magicNumber, $prefix . " Wall"));
}
self::registerBlock(new FlowerPot());
self::registerBlock(new Carrot());
@ -562,8 +585,13 @@ class BlockFactory{
public static function registerStaticRuntimeIdMappings() : void{
/** @var mixed[] $runtimeIdMap */
$runtimeIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "runtimeid_table.json"), true);
$legacyIdMap = json_decode(file_get_contents(\pocketmine\RESOURCE_PATH . "legacy_id_map.json"), true);
foreach($runtimeIdMap as $k => $obj){
self::registerMapping($k, $obj["id"], $obj["data"]);
//this has to use the json offset to make sure the mapping is consistent with what we send over network, even though we aren't using all the entries
if(!isset($legacyIdMap[$obj["name"]])){
continue;
}
self::registerMapping($k, $legacyIdMap[$obj["name"]], $obj["data"]);
}
}

View File

@ -30,6 +30,18 @@ use pocketmine\math\Facing;
class CobblestoneWall extends Transparent{
public const NONE_MOSSY_WALL = 0;
public const MOSSY_WALL = 1;
public const GRANITE_WALL = 2;
public const DIORITE_WALL = 3;
public const ANDESITE_WALL = 4;
public const SANDSTONE_WALL = 5;
public const BRICK_WALL = 6;
public const STONE_BRICK_WALL = 7;
public const MOSSY_STONE_BRICK_WALL = 8;
public const NETHER_BRICK_WALL = 9;
public const END_STONE_BRICK_WALL = 10;
public const PRISMARINE_WALL = 11;
public const RED_SANDSTONE_WALL = 12;
public const RED_NETHER_BRICK_WALL = 13;
/** @var bool[] facing => dummy */
protected $connections = [];

View File

@ -332,10 +332,10 @@ class ItemFactory{
/**
* Returns an instance of the Item with the specified id, meta, count and NBT.
*
* @param int $id
* @param int $meta
* @param int $count
* @param CompoundTag $tags
* @param int $id
* @param int $meta
* @param int $count
* @param CompoundTag|null $tags
*
* @return Item
* @throws \InvalidArgumentException

View File

@ -30,8 +30,6 @@ use pocketmine\entity\Entity;
use pocketmine\item\Item;
use pocketmine\item\ItemFactory;
use pocketmine\math\Vector3;
use pocketmine\nbt\LittleEndianNbtSerializer;
use pocketmine\nbt\NbtDataException;
use pocketmine\network\BadPacketException;
use pocketmine\network\mcpe\protocol\types\CommandOriginData;
use pocketmine\network\mcpe\protocol\types\EntityLink;
@ -42,8 +40,6 @@ use function count;
use function strlen;
class NetworkBinaryStream extends BinaryStream{
/** @var LittleEndianNbtSerializer */
private static $itemNbtSerializer = null;
/**
* @return string
@ -100,15 +96,14 @@ class NetworkBinaryStream extends BinaryStream{
$nbtLen = $this->getLShort();
$compound = null;
if($nbtLen > 0){
if(self::$itemNbtSerializer === null){
self::$itemNbtSerializer = new LittleEndianNbtSerializer();
}
try{
$compound = self::$itemNbtSerializer->read($this->get($nbtLen));
}catch(NbtDataException $e){
throw new BadPacketException($e->getMessage(), 0, $e);
if($nbtLen === 0xffff){
$c = $this->getByte();
if($c !== 1){
throw new BadPacketException("Unexpected NBT count $c");
}
$compound = (new NetworkNbtSerializer())->read($this->buffer, $this->offset);
}elseif($nbtLen !== 0){
throw new BadPacketException("Unexpected fake NBT length $nbtLen");
}
//TODO
@ -140,32 +135,14 @@ class NetworkBinaryStream extends BinaryStream{
$auxValue = (($item->getDamage() & 0x7fff) << 8) | $item->getCount();
$this->putVarInt($auxValue);
$nbt = "";
$nbtLen = 0;
if($item->hasNamedTag()){
if(self::$itemNbtSerializer === null){
self::$itemNbtSerializer = new LittleEndianNbtSerializer();
}
$nbt = self::$itemNbtSerializer->write($item->getNamedTag());
$nbtLen = strlen($nbt);
if($nbtLen > 32767){
/*
* TODO: Workaround bug in the protocol (overflow)
* Encoded tags larger than 32KB overflow the length field, so we can't send these over network.
* However, it's unreasonable to randomly throw this burden off onto users by crashing their servers, so the
* next best solution is to just not send the NBT. This is also not an ideal solution (books and the like
* with too-large tags won't work on the client side) but it's better than crashing the server or client due
* to a protocol bug. Mojang have confirmed this will be resolved by a future MCPE release, so we'll just
* work around this problem until then.
*/
$nbt = "";
$nbtLen = 0;
}
$this->putLShort(0xffff);
$this->putByte(1); //TODO: some kind of count field? always 1 as of 1.9.0
$this->put((new NetworkNbtSerializer())->write($item->getNamedTag()));
}else{
$this->putLShort(0);
}
$this->putLShort($nbtLen);
$this->put($nbt);
$this->putVarInt(0); //CanPlaceOn entry count (TODO)
$this->putVarInt(0); //CanDestroy entry count (TODO)
}

View File

@ -25,7 +25,6 @@ namespace pocketmine\network\mcpe\handler;
use pocketmine\network\mcpe\protocol\AddBehaviorTreePacket;
use pocketmine\network\mcpe\protocol\AddEntityPacket;
use pocketmine\network\mcpe\protocol\AddHangingEntityPacket;
use pocketmine\network\mcpe\protocol\AddItemEntityPacket;
use pocketmine\network\mcpe\protocol\AddPaintingPacket;
use pocketmine\network\mcpe\protocol\AddPlayerPacket;
@ -71,6 +70,7 @@ use pocketmine\network\mcpe\protocol\LabTablePacket;
use pocketmine\network\mcpe\protocol\LevelEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacket;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacketV1;
use pocketmine\network\mcpe\protocol\LevelSoundEventPacketV2;
use pocketmine\network\mcpe\protocol\LoginPacket;
use pocketmine\network\mcpe\protocol\MapInfoRequestPacket;
use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket;
@ -217,10 +217,6 @@ abstract class SessionHandler{
return false;
}
public function handleAddHangingEntity(AddHangingEntityPacket $packet) : bool{
return false;
}
public function handleTakeItemEntity(TakeItemEntityPacket $packet) : bool{
return false;
}
@ -629,7 +625,7 @@ abstract class SessionHandler{
return false;
}
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
public function handleLevelSoundEventPacketV2(LevelSoundEventPacketV2 $packet) : bool{
return false;
}
@ -640,4 +636,8 @@ abstract class SessionHandler{
public function handleBiomeDefinitionList(BiomeDefinitionListPacket $packet) : bool{
return false;
}
public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
return false;
}
}

View File

@ -28,19 +28,37 @@ namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\mcpe\handler\SessionHandler;
class AddPaintingPacket extends AddHangingEntityPacket{
class AddPaintingPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_PAINTING_PACKET;
/** @var string */
public $title;
/** @var int|null */
public $entityUniqueId = null;
/** @var int */
public $entityRuntimeId;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $direction;
protected function decodePayload() : void{
parent::decodePayload();
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->direction = $this->getVarInt();
$this->title = $this->getString();
}
protected function encodePayload() : void{
parent::encodePayload();
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->direction);
$this->putString($this->title);
}

File diff suppressed because one or more lines are too long

View File

@ -299,7 +299,7 @@ class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, Ser
public $disableRelativeVolume = false;
protected function decodePayload() : void{
$this->sound = $this->getByte();
$this->sound = $this->getUnsignedVarInt();
$this->position = $this->getVector3();
$this->extraData = $this->getVarInt();
$this->entityType = $this->getString();
@ -308,7 +308,7 @@ class LevelSoundEventPacket extends DataPacket implements ClientboundPacket, Ser
}
protected function encodePayload() : void{
$this->putByte($this->sound);
$this->putUnsignedVarInt($this->sound);
$this->putVector3($this->position);
$this->putVarInt($this->extraData);
$this->putString($this->entityType);

View File

@ -25,39 +25,47 @@ namespace pocketmine\network\mcpe\protocol;
#include <rules/DataPacket.h>
use pocketmine\math\Vector3;
use pocketmine\network\mcpe\handler\SessionHandler;
class AddHangingEntityPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::ADD_HANGING_ENTITY_PACKET;
/**
* Useless leftover from a 1.9 refactor, does nothing
*/
class LevelSoundEventPacketV2 extends DataPacket{
public const NETWORK_ID = ProtocolInfo::LEVEL_SOUND_EVENT_PACKET_V2;
/** @var int|null */
public $entityUniqueId = null;
/** @var int */
public $entityRuntimeId;
public $sound;
/** @var Vector3 */
public $position;
/** @var int */
public $x;
/** @var int */
public $y;
/** @var int */
public $z;
/** @var int */
public $direction;
public $extraData = -1;
/** @var string */
public $entityType = ":"; //???
/** @var bool */
public $isBabyMob = false; //...
/** @var bool */
public $disableRelativeVolume = false;
protected function decodePayload() : void{
$this->entityUniqueId = $this->getEntityUniqueId();
$this->entityRuntimeId = $this->getEntityRuntimeId();
$this->getBlockPosition($this->x, $this->y, $this->z);
$this->direction = $this->getVarInt();
$this->sound = $this->getByte();
$this->position = $this->getVector3();
$this->extraData = $this->getVarInt();
$this->entityType = $this->getString();
$this->isBabyMob = $this->getBool();
$this->disableRelativeVolume = $this->getBool();
}
protected function encodePayload() : void{
$this->putEntityUniqueId($this->entityUniqueId ?? $this->entityRuntimeId);
$this->putEntityRuntimeId($this->entityRuntimeId);
$this->putBlockPosition($this->x, $this->y, $this->z);
$this->putVarInt($this->direction);
$this->putByte($this->sound);
$this->putVector3($this->position);
$this->putVarInt($this->extraData);
$this->putString($this->entityType);
$this->putBool($this->isBabyMob);
$this->putBool($this->disableRelativeVolume);
}
public function handle(SessionHandler $handler) : bool{
return $handler->handleAddHangingEntity($this);
return $handler->handleLevelSoundEventPacketV2($this);
}
}

View File

@ -32,13 +32,17 @@ class NetworkStackLatencyPacket extends DataPacket implements ClientboundPacket,
/** @var int */
public $timestamp;
/** @var bool */
public $needResponse;
protected function decodePayload() : void{
$this->timestamp = $this->getLLong();
$this->needResponse = $this->getBool();
}
protected function encodePayload() : void{
$this->putLLong($this->timestamp);
$this->putBool($this->needResponse);
}
public function handle(SessionHandler $handler) : bool{

View File

@ -23,12 +23,10 @@ declare(strict_types=1);
namespace pocketmine\network\mcpe\protocol;
use pocketmine\network\BadPacketException;
use pocketmine\utils\Binary;
use pocketmine\utils\BinaryDataException;
class PacketPool{
/** @var \SplFixedArray<Packet> */
/** @var \SplFixedArray<DataPacket> */
protected static $pool = null;
public static function init() : void{
@ -49,7 +47,6 @@ class PacketPool{
static::registerPacket(new AddEntityPacket());
static::registerPacket(new RemoveEntityPacket());
static::registerPacket(new AddItemEntityPacket());
static::registerPacket(new AddHangingEntityPacket());
static::registerPacket(new TakeItemEntityPacket());
static::registerPacket(new MoveEntityAbsolutePacket());
static::registerPacket(new MovePlayerPacket());
@ -152,40 +149,36 @@ class PacketPool{
static::registerPacket(new ScriptCustomEventPacket());
static::registerPacket(new SpawnParticleEffectPacket());
static::registerPacket(new AvailableEntityIdentifiersPacket());
static::registerPacket(new LevelSoundEventPacket());
static::registerPacket(new LevelSoundEventPacketV2());
static::registerPacket(new NetworkChunkPublisherUpdatePacket());
static::registerPacket(new BiomeDefinitionListPacket());
static::registerPacket(new LevelSoundEventPacket());
}
/**
* @param Packet $packet
* @param DataPacket $packet
*/
public static function registerPacket(Packet $packet) : void{
public static function registerPacket(DataPacket $packet) : void{
static::$pool[$packet->pid()] = clone $packet;
}
/**
* @param int $pid
*
* @return Packet
* @return DataPacket
*/
public static function getPacketById(int $pid) : Packet{
public static function getPacketById(int $pid) : DataPacket{
return isset(static::$pool[$pid]) ? clone static::$pool[$pid] : new UnknownPacket();
}
/**
* @param string $buffer
*
* @return Packet
* @throws BadPacketException
* @return DataPacket
*/
public static function getPacket(string $buffer) : Packet{
public static function getPacket(string $buffer) : DataPacket{
$offset = 0;
try{
$pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
}catch(BinaryDataException $e){
throw new BadPacketException("Packet is too short");
}
$pk = static::getPacketById(Binary::readUnsignedVarInt($buffer, $offset));
$pk->setBuffer($buffer, $offset);
return $pk;

View File

@ -39,15 +39,15 @@ interface ProtocolInfo{
/**
* Actual Minecraft: PE protocol version
*/
public const CURRENT_PROTOCOL = 313;
public const CURRENT_PROTOCOL = 332;
/**
* Current Minecraft PE version reported by the server. This is usually the earliest currently supported version.
*/
public const MINECRAFT_VERSION = 'v1.8.0';
public const MINECRAFT_VERSION = 'v1.9.0';
/**
* Version number sent to clients in ping responses.
*/
public const MINECRAFT_VERSION_NETWORK = '1.8.0';
public const MINECRAFT_VERSION_NETWORK = '1.9.0';
public const LOGIN_PACKET = 0x01;
public const PLAY_STATUS_PACKET = 0x02;
@ -64,7 +64,7 @@ interface ProtocolInfo{
public const ADD_ENTITY_PACKET = 0x0d;
public const REMOVE_ENTITY_PACKET = 0x0e;
public const ADD_ITEM_ENTITY_PACKET = 0x0f;
public const ADD_HANGING_ENTITY_PACKET = 0x10;
public const TAKE_ITEM_ENTITY_PACKET = 0x11;
public const MOVE_ENTITY_ABSOLUTE_PACKET = 0x12;
public const MOVE_PLAYER_PACKET = 0x13;
@ -168,8 +168,9 @@ interface ProtocolInfo{
public const SCRIPT_CUSTOM_EVENT_PACKET = 0x75;
public const SPAWN_PARTICLE_EFFECT_PACKET = 0x76;
public const AVAILABLE_ENTITY_IDENTIFIERS_PACKET = 0x77;
public const LEVEL_SOUND_EVENT_PACKET = 0x78;
public const LEVEL_SOUND_EVENT_PACKET_V2 = 0x78;
public const NETWORK_CHUNK_PUBLISHER_UPDATE_PACKET = 0x79;
public const BIOME_DEFINITION_LIST_PACKET = 0x7a;
public const LEVEL_SOUND_EVENT_PACKET = 0x7b;
}

View File

@ -35,6 +35,8 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
/** @var bool */
public $mustAccept = false; //if true, forces client to use selected resource packs
/** @var bool */
public $hasScripts = false; //if true, causes disconnect for any platform that doesn't support scripts yet
/** @var ResourcePack[] */
public $behaviorPackEntries = [];
/** @var ResourcePack[] */
@ -42,6 +44,7 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
protected function decodePayload() : void{
$this->mustAccept = $this->getBool();
$this->hasScripts = $this->getBool();
$behaviorPackCount = $this->getLShort();
while($behaviorPackCount-- > 0){
$this->getString();
@ -50,6 +53,7 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
$this->getString();
$this->getString();
$this->getString();
$this->getBool();
}
$resourcePackCount = $this->getLShort();
@ -60,12 +64,13 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
$this->getString();
$this->getString();
$this->getString();
$this->getBool();
}
}
protected function encodePayload() : void{
$this->putBool($this->mustAccept);
$this->putBool($this->hasScripts);
$this->putLShort(count($this->behaviorPackEntries));
foreach($this->behaviorPackEntries as $entry){
$this->putString($entry->getPackId());
@ -74,6 +79,7 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
$this->putString(""); //TODO: encryption key
$this->putString(""); //TODO: subpack name
$this->putString(""); //TODO: content identity
$this->putBool(false); //TODO: has scripts (?)
}
$this->putLShort(count($this->resourcePackEntries));
foreach($this->resourcePackEntries as $entry){
@ -83,6 +89,7 @@ class ResourcePacksInfoPacket extends DataPacket implements ClientboundPacket{
$this->putString(""); //TODO: encryption key
$this->putString(""); //TODO: subpack name
$this->putString(""); //TODO: content identity
$this->putBool(false); //TODO: seems useless for resource packs
}
}

View File

@ -34,6 +34,8 @@ class SpawnParticleEffectPacket extends DataPacket implements ClientboundPacket{
/** @var int */
public $dimensionId = DimensionIds::OVERWORLD; //wtf mojang
/** @var int */
public $entityUniqueId = -1; //default none
/** @var Vector3 */
public $position;
/** @var string */
@ -41,12 +43,14 @@ class SpawnParticleEffectPacket extends DataPacket implements ClientboundPacket{
protected function decodePayload() : void{
$this->dimensionId = $this->getByte();
$this->entityUniqueId = $this->getEntityUniqueId();
$this->position = $this->getVector3();
$this->particleName = $this->getString();
}
protected function encodePayload() : void{
$this->putByte($this->dimensionId);
$this->putEntityUniqueId($this->entityUniqueId);
$this->putVector3($this->position);
$this->putString($this->particleName);
}

View File

@ -84,11 +84,15 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
/** @var float */
public $lightningLevel;
/** @var bool */
public $hasConfirmedPlatformLockedContent = false;
/** @var bool */
public $isMultiplayerGame = true;
/** @var bool */
public $hasLANBroadcast = true;
/** @var bool */
public $hasXboxLiveBroadcast = false;
/** @var int */
public $xboxLiveBroadcastMode = 0; //TODO: find values
/** @var int */
public $platformBroadcastMode = 0;
/** @var bool */
public $commandsEnabled;
/** @var bool */
@ -101,20 +105,12 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
public $hasBonusChestEnabled = false;
/** @var bool */
public $hasStartWithMapEnabled = false;
/** @var bool */
public $hasTrustPlayersEnabled = false;
/** @var int */
public $defaultPlayerPermission = PlayerPermissions::MEMBER; //TODO
/** @var int */
public $xboxLiveBroadcastMode = 0; //TODO: find values
/** @var int */
public $serverChunkTickRadius = 4; //TODO (leave as default for now)
/** @var bool */
public $hasPlatformBroadcast = false;
/** @var int */
public $platformBroadcastMode = 0;
/** @var bool */
public $xboxLiveBroadcastIntent = false;
/** @var bool */
public $hasLockedBehaviorPack = false;
/** @var bool */
@ -166,21 +162,18 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
$this->hasEduFeaturesEnabled = $this->getBool();
$this->rainLevel = $this->getLFloat();
$this->lightningLevel = $this->getLFloat();
$this->hasConfirmedPlatformLockedContent = $this->getBool();
$this->isMultiplayerGame = $this->getBool();
$this->hasLANBroadcast = $this->getBool();
$this->hasXboxLiveBroadcast = $this->getBool();
$this->xboxLiveBroadcastMode = $this->getVarInt();
$this->platformBroadcastMode = $this->getVarInt();
$this->commandsEnabled = $this->getBool();
$this->isTexturePacksRequired = $this->getBool();
$this->gameRules = $this->getGameRules();
$this->hasBonusChestEnabled = $this->getBool();
$this->hasStartWithMapEnabled = $this->getBool();
$this->hasTrustPlayersEnabled = $this->getBool();
$this->defaultPlayerPermission = $this->getVarInt();
$this->xboxLiveBroadcastMode = $this->getVarInt();
$this->serverChunkTickRadius = $this->getLInt();
$this->hasPlatformBroadcast = $this->getBool();
$this->platformBroadcastMode = $this->getVarInt();
$this->xboxLiveBroadcastIntent = $this->getBool();
$this->hasLockedBehaviorPack = $this->getBool();
$this->hasLockedResourcePack = $this->getBool();
$this->isFromLockedWorldTemplate = $this->getBool();
@ -228,21 +221,18 @@ class StartGamePacket extends DataPacket implements ClientboundPacket{
$this->putBool($this->hasEduFeaturesEnabled);
$this->putLFloat($this->rainLevel);
$this->putLFloat($this->lightningLevel);
$this->putBool($this->hasConfirmedPlatformLockedContent);
$this->putBool($this->isMultiplayerGame);
$this->putBool($this->hasLANBroadcast);
$this->putBool($this->hasXboxLiveBroadcast);
$this->putVarInt($this->xboxLiveBroadcastMode);
$this->putVarInt($this->platformBroadcastMode);
$this->putBool($this->commandsEnabled);
$this->putBool($this->isTexturePacksRequired);
$this->putGameRules($this->gameRules);
$this->putBool($this->hasBonusChestEnabled);
$this->putBool($this->hasStartWithMapEnabled);
$this->putBool($this->hasTrustPlayersEnabled);
$this->putVarInt($this->defaultPlayerPermission);
$this->putVarInt($this->xboxLiveBroadcastMode);
$this->putLInt($this->serverChunkTickRadius);
$this->putBool($this->hasPlatformBroadcast);
$this->putVarInt($this->platformBroadcastMode);
$this->putBool($this->xboxLiveBroadcastIntent);
$this->putBool($this->hasLockedBehaviorPack);
$this->putBool($this->hasLockedResourcePack);
$this->putBool($this->isFromLockedWorldTemplate);

View File

@ -41,6 +41,7 @@ class TextPacket extends DataPacket implements ClientboundPacket, ServerboundPac
public const TYPE_SYSTEM = 6;
public const TYPE_WHISPER = 7;
public const TYPE_ANNOUNCEMENT = 8;
public const TYPE_JSON = 9;
/** @var int */
public $type;
@ -69,6 +70,7 @@ class TextPacket extends DataPacket implements ClientboundPacket, ServerboundPac
case self::TYPE_RAW:
case self::TYPE_TIP:
case self::TYPE_SYSTEM:
case self::TYPE_JSON:
$this->message = $this->getString();
break;
@ -99,6 +101,7 @@ class TextPacket extends DataPacket implements ClientboundPacket, ServerboundPac
case self::TYPE_RAW:
case self::TYPE_TIP:
case self::TYPE_SYSTEM:
case self::TYPE_JSON:
$this->putString($this->message);
break;