Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/pmmp/BedrockProtocol
Browse files Browse the repository at this point in the history
  • Loading branch information
AkmalFairuz committed Dec 8, 2023
2 parents 5045157 + 0106eab commit 5141129
Show file tree
Hide file tree
Showing 24 changed files with 342 additions and 113 deletions.
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
strategy:
matrix:
php: ['8.1', '8.2']
php: ['8.1', '8.2', '8.3']
name: Tests (PHP ${{ matrix.php }})
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@2.25.5
uses: shivammathur/setup-php@2.28.0
with:
php-version: ${{ matrix.php }}
ini-values: xdebug.max_nesting_level=3000
Expand All @@ -41,10 +41,10 @@ jobs:
needs: codestyle #to avoid false positives
name: Generated Code consistency checks
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@2.25.5
uses: shivammathur/setup-php@2.28.0
with:
php-version: 8.1
ini-values: xdebug.max_nesting_level=3000
Expand Down Expand Up @@ -74,12 +74,12 @@ jobs:
if: "!contains(github.event.head_commit.message, '[ci skip]')"
name: Code Style checks
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup PHP
uses: shivammathur/setup-php@2.25.5
uses: shivammathur/setup-php@2.28.0
with:
php-version: 8.1
php-version: 8.2
ini-values: xdebug.max_nesting_level=3000
tools: php-cs-fixer:3
env:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"phpstan/phpstan": "1.10.39",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.0.0",
"phpunit/phpunit": "^9.5"
"phpunit/phpunit": "^9.5 || ^10.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/AgentAnimationPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;

class AgentAnimationPacket extends DataPacket{
class AgentAnimationPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::AGENT_ANIMATION_PACKET;

public const TYPE_ARM_SWING = 0;
Expand Down
83 changes: 0 additions & 83 deletions src/CraftingEventPacket.php

This file was deleted.

12 changes: 8 additions & 4 deletions src/PacketHandlerDefaultImplTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,6 @@ public function handleCraftingData(CraftingDataPacket $packet) : bool{
return false;
}

public function handleCraftingEvent(CraftingEventPacket $packet) : bool{
return false;
}

public function handleGuiDataPickItem(GuiDataPickItemPacket $packet) : bool{
return false;
}
Expand Down Expand Up @@ -809,4 +805,12 @@ public function handleAgentAnimation(AgentAnimationPacket $packet) : bool{
public function handleRefreshEntitlements(RefreshEntitlementsPacket $packet) : bool{
return false;
}

public function handlePlayerToggleCrafterSlotRequest(PlayerToggleCrafterSlotRequestPacket $packet) : bool{
return false;
}

public function handleSetPlayerInventoryOptions(SetPlayerInventoryOptionsPacket $packet) : bool{
return false;
}
}
6 changes: 4 additions & 2 deletions src/PacketHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ public function handleContainerSetData(ContainerSetDataPacket $packet) : bool;

public function handleCraftingData(CraftingDataPacket $packet) : bool;

public function handleCraftingEvent(CraftingEventPacket $packet) : bool;

public function handleGuiDataPickItem(GuiDataPickItemPacket $packet) : bool;

public function handleBlockActorData(BlockActorDataPacket $packet) : bool;
Expand Down Expand Up @@ -411,4 +409,8 @@ public function handleOpenSign(OpenSignPacket $packet) : bool;
public function handleAgentAnimation(AgentAnimationPacket $packet) : bool;

public function handleRefreshEntitlements(RefreshEntitlementsPacket $packet) : bool;

public function handlePlayerToggleCrafterSlotRequest(PlayerToggleCrafterSlotRequestPacket $packet) : bool;

public function handleSetPlayerInventoryOptions(SetPlayerInventoryOptionsPacket $packet) : bool;
}
3 changes: 2 additions & 1 deletion src/PacketPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ public function __construct(){
$this->registerPacket(new InventorySlotPacket());
$this->registerPacket(new ContainerSetDataPacket());
$this->registerPacket(new CraftingDataPacket());
$this->registerPacket(new CraftingEventPacket());
$this->registerPacket(new GuiDataPickItemPacket());
$this->registerPacket(new AdventureSettingsPacket());
$this->registerPacket(new BlockActorDataPacket());
Expand Down Expand Up @@ -230,6 +229,8 @@ public function __construct(){
$this->registerPacket(new OpenSignPacket());
$this->registerPacket(new AgentAnimationPacket());
$this->registerPacket(new RefreshEntitlementsPacket());
$this->registerPacket(new PlayerToggleCrafterSlotRequestPacket());
$this->registerPacket(new SetPlayerInventoryOptionsPacket());
}

public function registerPacket(Packet $packet) : void{
Expand Down
2 changes: 1 addition & 1 deletion src/PlayerAuthInputPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class PlayerAuthInputPacket extends DataPacket implements ServerboundPacket{
private ?Vector3 $vrGazeDirection = null;
private int $tick;
private Vector3 $delta;
public ?ItemInteractionData $itemInteractionData = null;
private ?ItemInteractionData $itemInteractionData = null;
private ?ItemStackRequest $itemStackRequest = null;
/** @var PlayerBlockAction[]|null */
private ?array $blockActions = null;
Expand Down
64 changes: 64 additions & 0 deletions src/PlayerToggleCrafterSlotRequestPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol 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.
*/

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\BlockPosition;

class PlayerToggleCrafterSlotRequestPacket extends DataPacket implements ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::PLAYER_TOGGLE_CRAFTER_SLOT_REQUEST_PACKET;

private BlockPosition $position;
private int $slot;
private bool $disabled;

/**
* @generate-create-func
*/
public static function create(BlockPosition $position, int $slot, bool $disabled) : self{
$result = new self;
$result->position = $position;
$result->slot = $slot;
$result->disabled = $disabled;
return $result;
}

public function getPosition() : BlockPosition{ return $this->position; }

public function getSlot() : int{ return $this->slot; }

public function isDisabled() : bool{ return $this->disabled; }

protected function decodePayload(PacketSerializer $in) : void{
$x = $in->getLInt();
$y = $in->getLInt();
$z = $in->getLInt();
$this->position = new BlockPosition($x, $y, $z);
$this->slot = $in->getByte();
$this->disabled = $in->getBool();
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putLInt($this->position->getX());
$out->putLInt($this->position->getY());
$out->putLInt($this->position->getZ());
$out->putByte($this->slot);
$out->putBool($this->disabled);
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handlePlayerToggleCrafterSlotRequest($this);
}
}
10 changes: 6 additions & 4 deletions src/ProtocolInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ private function __construct(){
*/

/** Actual Minecraft: PE protocol version */
public const CURRENT_PROTOCOL = 622;
public const CURRENT_PROTOCOL = 630;
/** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */
public const MINECRAFT_VERSION = 'v1.20.40';
public const MINECRAFT_VERSION = 'v1.20.50';
/** Version number sent to clients in ping responses. */
public const MINECRAFT_VERSION_NETWORK = '1.20.40';
public const MINECRAFT_VERSION_NETWORK = '1.20.50';

public const BASE_VERSION = '1.18.0';

Expand Down Expand Up @@ -131,7 +131,7 @@ private function __construct(){
public const INVENTORY_SLOT_PACKET = 0x32;
public const CONTAINER_SET_DATA_PACKET = 0x33;
public const CRAFTING_DATA_PACKET = 0x34;
public const CRAFTING_EVENT_PACKET = 0x35;

public const GUI_DATA_PICK_ITEM_PACKET = 0x36;
public const ADVENTURE_SETTINGS_PACKET = 0x37;
public const BLOCK_ACTOR_DATA_PACKET = 0x38;
Expand Down Expand Up @@ -284,5 +284,7 @@ private function __construct(){
public const OPEN_SIGN_PACKET = 0x12f;
public const AGENT_ANIMATION_PACKET = 0x130;
public const REFRESH_ENTITLEMENTS_PACKET = 0x131;
public const PLAYER_TOGGLE_CRAFTER_SLOT_REQUEST_PACKET = 0x132;
public const SET_PLAYER_INVENTORY_OPTIONS_PACKET = 0x133;

}
2 changes: 1 addition & 1 deletion src/RefreshEntitlementsPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;

class RefreshEntitlementsPacket extends DataPacket{
class RefreshEntitlementsPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::REFRESH_ENTITLEMENTS_PACKET;

/**
Expand Down
73 changes: 73 additions & 0 deletions src/SetPlayerInventoryOptionsPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

/*
* This file is part of BedrockProtocol.
* Copyright (C) 2014-2022 PocketMine Team <https://github.com/pmmp/BedrockProtocol>
*
* BedrockProtocol 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.
*/

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use pocketmine\network\mcpe\protocol\types\inventory\InventoryLayout;
use pocketmine\network\mcpe\protocol\types\inventory\InventoryLeftTab;
use pocketmine\network\mcpe\protocol\types\inventory\InventoryRightTab;

class SetPlayerInventoryOptionsPacket extends DataPacket implements ClientboundPacket, ServerboundPacket{
public const NETWORK_ID = ProtocolInfo::SET_PLAYER_INVENTORY_OPTIONS_PACKET;

private InventoryLeftTab $leftTab;
private InventoryRightTab $rightTab;
private bool $filtering;
private InventoryLayout $inventoryLayout;
private InventoryLayout $craftingLayout;

/**
* @generate-create-func
*/
public static function create(InventoryLeftTab $leftTab, InventoryRightTab $rightTab, bool $filtering, InventoryLayout $inventoryLayout, InventoryLayout $craftingLayout) : self{
$result = new self;
$result->leftTab = $leftTab;
$result->rightTab = $rightTab;
$result->filtering = $filtering;
$result->inventoryLayout = $inventoryLayout;
$result->craftingLayout = $craftingLayout;
return $result;
}

public function getLeftTab() : InventoryLeftTab{ return $this->leftTab; }

public function getRightTab() : InventoryRightTab{ return $this->rightTab; }

public function isFiltering() : bool{ return $this->filtering; }

public function getInventoryLayout() : InventoryLayout{ return $this->inventoryLayout; }

public function getCraftingLayout() : InventoryLayout{ return $this->craftingLayout; }

protected function decodePayload(PacketSerializer $in) : void{
$this->leftTab = InventoryLeftTab::fromPacket($in->getVarInt());
$this->rightTab = InventoryRightTab::fromPacket($in->getVarInt());
$this->filtering = $in->getBool();
$this->inventoryLayout = InventoryLayout::fromPacket($in->getVarInt());
$this->craftingLayout = InventoryLayout::fromPacket($in->getVarInt());
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putVarInt($this->leftTab->value);
$out->putVarInt($this->rightTab->value);
$out->putBool($this->filtering);
$out->putVarInt($this->inventoryLayout->value);
$out->putVarInt($this->craftingLayout->value);
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleSetPlayerInventoryOptions($this);
}
}
Loading

0 comments on commit 5141129

Please sign in to comment.