mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 08:17:34 +00:00
Merge branch 'master' into api3/network
This commit is contained in:
commit
08cd944e5d
1
.github/ISSUE_TEMPLATE.md
vendored
1
.github/ISSUE_TEMPLATE.md
vendored
@ -1,5 +1,6 @@
|
||||
### Issue description
|
||||
<!--- use our forum https://forums.pmmp.io for questions -->
|
||||
<!--- Any issues requesting updates to new versions of MCPE will be treated as spam. We do not need issues to tell us that there is a new version available. -->
|
||||
Write a short description about the issue
|
||||
|
||||
### Steps to reproduce the issue
|
||||
|
@ -183,6 +183,7 @@ use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\UnknownPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\UseItemPacket;
|
||||
use pocketmine\network\SourceInterface;
|
||||
use pocketmine\permission\PermissibleBase;
|
||||
@ -771,21 +772,12 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
$level = $level === null ? $this->level : $level;
|
||||
$index = Level::chunkHash($x, $z);
|
||||
if(isset($this->usedChunks[$index])){
|
||||
$chunk = $level->getChunk($x, $z);
|
||||
foreach($chunk->getEntities() as $entity){
|
||||
foreach($level->getChunkEntities($x, $z) as $entity){
|
||||
if($entity !== $this){
|
||||
$entity->despawnFrom($this);
|
||||
}
|
||||
}
|
||||
|
||||
if($level !== $this->level){
|
||||
$pk = new FullChunkDataPacket();
|
||||
$pk->chunkX = $x;
|
||||
$pk->chunkZ = $z;
|
||||
$pk->data = chr($chunk->getSubChunkSendCount());
|
||||
$this->dataPacket($pk);
|
||||
}
|
||||
|
||||
unset($this->usedChunks[$index]);
|
||||
}
|
||||
$level->unregisterChunkLoader($this, $x, $z);
|
||||
@ -3287,6 +3279,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return true;
|
||||
}
|
||||
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool{
|
||||
return false;
|
||||
}
|
||||
|
@ -109,6 +109,14 @@ abstract class Entity extends Location implements Metadatable{
|
||||
* 58 (byte)
|
||||
* 59 (float)
|
||||
* 60 (float) */
|
||||
const DATA_AREA_EFFECT_CLOUD_RADIUS = 61; //float
|
||||
const DATA_AREA_EFFECT_CLOUD_WAITING = 62; //int
|
||||
const DATA_AREA_EFFECT_CLOUD_PARTICLE_ID = 63; //int
|
||||
/* 64 (int), shulker-related
|
||||
* 65 (byte), shulker-related
|
||||
* 66 (short) shulker-related
|
||||
* 67 (unknown), shulker-related */
|
||||
const DATA_TRADING_PLAYER_EID = 68; //long
|
||||
|
||||
|
||||
const DATA_FLAG_ONFIRE = 0;
|
||||
|
@ -21,10 +21,14 @@
|
||||
|
||||
namespace pocketmine\inventory;
|
||||
|
||||
use pocketmine\network\mcpe\protocol\types\InventoryNetworkIds;
|
||||
|
||||
/**
|
||||
* Saves all the information regarding default inventory sizes and types
|
||||
*/
|
||||
class InventoryType{
|
||||
|
||||
//NOTE: Do not confuse these with the network IDs.
|
||||
const CHEST = 0;
|
||||
const DOUBLE_CHEST = 1;
|
||||
const PLAYER = 2;
|
||||
@ -56,19 +60,19 @@ class InventoryType{
|
||||
return;
|
||||
}
|
||||
|
||||
static::$default[static::CHEST] = new InventoryType(27, "Chest", 0);
|
||||
static::$default[static::DOUBLE_CHEST] = new InventoryType(27 + 27, "Double Chest", 0);
|
||||
static::$default[static::PLAYER] = new InventoryType(36 + 4, "Player", 0); //36 CONTAINER, 4 ARMOR
|
||||
static::$default[static::CRAFTING] = new InventoryType(5, "Crafting", 1); //4 CRAFTING slots, 1 RESULT
|
||||
static::$default[static::WORKBENCH] = new InventoryType(10, "Crafting", 1); //9 CRAFTING slots, 1 RESULT
|
||||
static::$default[static::FURNACE] = new InventoryType(3, "Furnace", 2); //2 INPUT, 1 OUTPUT
|
||||
static::$default[static::ENCHANT_TABLE] = new InventoryType(2, "Enchant", 3); //1 INPUT/OUTPUT, 1 LAPIS
|
||||
static::$default[static::BREWING_STAND] = new InventoryType(4, "Brewing", 4); //1 INPUT, 3 POTION
|
||||
static::$default[static::ANVIL] = new InventoryType(3, "Anvil", 5); //2 INPUT, 1 OUTPUT
|
||||
//TODO: add the below
|
||||
//6: dispenser
|
||||
//7: dropper
|
||||
//8: hopper
|
||||
//TODO: move network stuff out of here
|
||||
//TODO: move inventory data to json
|
||||
static::$default = [
|
||||
static::CHEST => new InventoryType(27, "Chest", InventoryNetworkIds::CONTAINER),
|
||||
static::DOUBLE_CHEST => new InventoryType(27 + 27, "Double Chest", InventoryNetworkIds::CONTAINER),
|
||||
static::PLAYER => new InventoryType(36 + 4, "Player", InventoryNetworkIds::INVENTORY), //36 CONTAINER, 4 ARMOR
|
||||
static::CRAFTING => new InventoryType(5, "Crafting", InventoryNetworkIds::INVENTORY), //yes, the use of INVENTORY is intended! 4 CRAFTING slots, 1 RESULT
|
||||
static::WORKBENCH => new InventoryType(10, "Crafting", InventoryNetworkIds::WORKBENCH), //9 CRAFTING slots, 1 RESULT
|
||||
static::FURNACE => new InventoryType(3, "Furnace", InventoryNetworkIds::FURNACE), //2 INPUT, 1 OUTPUT
|
||||
static::ENCHANT_TABLE => new InventoryType(2, "Enchant", InventoryNetworkIds::ENCHANTMENT), //1 INPUT/OUTPUT, 1 LAPIS
|
||||
static::BREWING_STAND => new InventoryType(4, "Brewing", InventoryNetworkIds::BREWING_STAND), //1 INPUT, 3 POTION
|
||||
static::ANVIL => new InventoryType(3, "Anvil", InventoryNetworkIds::ANVIL) //2 INPUT, 1 OUTP
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -101,6 +101,7 @@ use pocketmine\network\mcpe\protocol\TextPacket;
|
||||
use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\UnknownPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\UseItemPacket;
|
||||
use pocketmine\Player;
|
||||
use pocketmine\Server;
|
||||
@ -381,6 +382,7 @@ class Network{
|
||||
$this->registerPacket(ProtocolInfo::TEXT_PACKET, TextPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::TRANSFER_PACKET, TransferPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::UPDATE_BLOCK_PACKET, UpdateBlockPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::UPDATE_TRADE_PACKET, UpdateTradePacket::class);
|
||||
$this->registerPacket(ProtocolInfo::USE_ITEM_PACKET, UseItemPacket::class);
|
||||
}
|
||||
}
|
||||
|
@ -101,6 +101,7 @@ use pocketmine\network\mcpe\protocol\TransferPacket;
|
||||
use pocketmine\network\mcpe\protocol\UnknownPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateBlockPacket;
|
||||
use pocketmine\network\mcpe\protocol\UpdateTradePacket;
|
||||
use pocketmine\network\mcpe\protocol\UseItemPacket;
|
||||
|
||||
interface NetworkSession{
|
||||
@ -261,6 +262,8 @@ interface NetworkSession{
|
||||
|
||||
public function handleCommandStep(CommandStepPacket $packet) : bool;
|
||||
|
||||
public function handleUpdateTrade(UpdateTradePacket $packet) : bool;
|
||||
|
||||
public function handleResourcePackDataInfo(ResourcePackDataInfoPacket $packet) : bool;
|
||||
|
||||
public function handleResourcePackChunkData(ResourcePackChunkDataPacket $packet) : bool;
|
||||
|
@ -49,7 +49,7 @@ class LevelSoundEventPacket extends DataPacket{
|
||||
const SOUND_MAD = 18;
|
||||
const SOUND_BOOST = 19;
|
||||
const SOUND_BOW = 20;
|
||||
const SOUND_SQUISH_BIG = 21;
|
||||
const SOUND_SQUISH_BIG = 21;
|
||||
const SOUND_SQUISH_SMALL = 22;
|
||||
const SOUND_FALL_BIG = 23;
|
||||
const SOUND_FALL_SMALL = 24;
|
||||
@ -112,14 +112,18 @@ class LevelSoundEventPacket extends DataPacket{
|
||||
const SOUND_BUCKET_EMPTY_WATER = 81;
|
||||
const SOUND_BUCKET_EMPTY_LAVA = 82;
|
||||
const SOUND_GUARDIAN_FLOP = 83;
|
||||
const SOUND_ELDERGUARDIAN_CURSE = 84;
|
||||
const SOUND_MOB_ELDERGUARDIAN_CURSE = 84;
|
||||
const SOUND_MOB_WARNING = 85;
|
||||
const SOUND_MOB_WARNING_BABY = 86;
|
||||
const SOUND_TELEPORT = 87;
|
||||
const SOUND_SHULKER_OPEN = 88;
|
||||
const SOUND_SHULKER_CLOSE = 89;
|
||||
const SOUND_DEFAULT = 90;
|
||||
const SOUND_UNDEFINED = 91;
|
||||
const SOUND_HAGGLE = 90;
|
||||
const SOUND_HAGGLE_YES = 91;
|
||||
const SOUND_HAGGLE_NO = 92;
|
||||
const SOUND_HAGGLE_IDLE = 93;
|
||||
const SOUND_DEFAULT = 94;
|
||||
const SOUND_UNDEFINED = 95;
|
||||
|
||||
public $sound;
|
||||
public $x;
|
||||
|
@ -30,9 +30,9 @@ interface ProtocolInfo{
|
||||
/**
|
||||
* Actual Minecraft: PE protocol version
|
||||
*/
|
||||
const CURRENT_PROTOCOL = 101;
|
||||
const MINECRAFT_VERSION = "v1.0.3.0";
|
||||
const MINECRAFT_VERSION_NETWORK = "1.0.3.0";
|
||||
const CURRENT_PROTOCOL = 102;
|
||||
const MINECRAFT_VERSION = "v1.0.4.1 beta";
|
||||
const MINECRAFT_VERSION_NETWORK = "1.0.4.1";
|
||||
|
||||
const LOGIN_PACKET = 0x01;
|
||||
const PLAY_STATUS_PACKET = 0x02;
|
||||
@ -112,9 +112,10 @@ interface ProtocolInfo{
|
||||
const SHOW_CREDITS_PACKET = 0x4c;
|
||||
const AVAILABLE_COMMANDS_PACKET = 0x4d;
|
||||
const COMMAND_STEP_PACKET = 0x4e;
|
||||
const RESOURCE_PACK_DATA_INFO_PACKET = 0x4f;
|
||||
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x50;
|
||||
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x51;
|
||||
const TRANSFER_PACKET = 0x52;
|
||||
const UPDATE_TRADE_PACKET = 0x4f;
|
||||
const RESOURCE_PACK_DATA_INFO_PACKET = 0x50;
|
||||
const RESOURCE_PACK_CHUNK_DATA_PACKET = 0x51;
|
||||
const RESOURCE_PACK_CHUNK_REQUEST_PACKET = 0x52;
|
||||
const TRANSFER_PACKET = 0x53;
|
||||
|
||||
}
|
||||
|
72
src/pocketmine/network/mcpe/protocol/UpdateTradePacket.php
Normal file
72
src/pocketmine/network/mcpe/protocol/UpdateTradePacket.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class UpdateTradePacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::UPDATE_TRADE_PACKET;
|
||||
|
||||
//TODO: find fields
|
||||
public $byte1;
|
||||
public $byte2;
|
||||
public $varint1;
|
||||
public $varint2;
|
||||
public $isWilling;
|
||||
public $traderEid;
|
||||
public $playerEid;
|
||||
public $displayName;
|
||||
public $offers;
|
||||
|
||||
public function decode(){
|
||||
$this->byte1 = $this->getByte();
|
||||
$this->byte2 = $this->getByte();
|
||||
$this->varint1 = $this->getVarInt();
|
||||
$this->varint2 = $this->getVarInt();
|
||||
$this->isWilling = $this->getBool();
|
||||
$this->traderEid = $this->getEntityUniqueId();
|
||||
$this->playerEid = $this->getEntityUniqueId();
|
||||
$this->displayName = $this->getString();
|
||||
$this->offers = $this->get(true);
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putByte($this->byte1);
|
||||
$this->putByte($this->byte2);
|
||||
$this->putVarInt($this->varint1);
|
||||
$this->putVarInt($this->varint2);
|
||||
$this->putBool($this->isWilling);
|
||||
$this->putEntityUniqueId($this->traderEid);
|
||||
$this->putEntityUniqueId($this->playerEid);
|
||||
$this->putString($this->displayName);
|
||||
$this->put($this->offers);
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleUpdateTrade($this);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol\types;
|
||||
|
||||
|
||||
interface InventoryNetworkIds{
|
||||
|
||||
const INVENTORY = -1;
|
||||
const CONTAINER = 0;
|
||||
const WORKBENCH = 1;
|
||||
const FURNACE = 2;
|
||||
const ENCHANTMENT = 3;
|
||||
const BREWING_STAND = 4;
|
||||
const ANVIL = 5;
|
||||
const DISPENSER = 6;
|
||||
const DROPPER = 7;
|
||||
const HOPPER = 8;
|
||||
const CAULDRON = 9;
|
||||
const MINECART_CHEST = 10;
|
||||
const MINECART_HOPPER = 11;
|
||||
const HORSE = 12;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user