Skip to content

Commit

Permalink
Protocol changes for 1.20.50
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Dec 6, 2023
1 parent 3cb5300 commit 2a98eb7
Show file tree
Hide file tree
Showing 18 changed files with 334 additions and 99 deletions.
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 @@ -805,4 +801,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 @@ -118,8 +118,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 @@ -409,4 +407,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 BlockActorDataPacket());
$this->registerPacket(new PlayerInputPacket());
Expand Down Expand Up @@ -229,6 +228,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
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 LOGIN_PACKET = 0x01;
public const PLAY_STATUS_PACKET = 0x02;
Expand Down Expand Up @@ -90,7 +90,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 BLOCK_ACTOR_DATA_PACKET = 0x38;
Expand Down Expand Up @@ -243,5 +243,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;

}
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);
}
}
7 changes: 4 additions & 3 deletions src/ShowStoreOfferPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
namespace pocketmine\network\mcpe\protocol;

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

class ShowStoreOfferPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::SHOW_STORE_OFFER_PACKET;

public string $offerId;
public bool $showAll;
public ShowStoreOfferRedirectType $redirectType;

/**
* @generate-create-func
Expand All @@ -34,12 +35,12 @@ public static function create(string $offerId, bool $showAll) : self{

protected function decodePayload(PacketSerializer $in) : void{
$this->offerId = $in->getString();
$this->showAll = $in->getBool();
$this->redirectType = ShowStoreOfferRedirectType::fromPacket($in->getByte());
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putString($this->offerId);
$out->putBool($this->showAll);
$out->putByte($this->redirectType->value);
}

public function handle(PacketHandlerInterface $handler) : bool{
Expand Down
3 changes: 3 additions & 0 deletions src/types/LevelEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private function __construct(){
public const PARTICLE_SCULK_SHRIEK = 2035;
public const PARTICLE_SCULK_CATALYST_BLOOM = 2036;

public const PARTICLE_DUST_PLUME = 2040;

public const START_RAIN = 3001;
public const START_THUNDER = 3002;
public const STOP_RAIN = 3003;
Expand Down Expand Up @@ -135,6 +137,7 @@ private function __construct(){
public const PARTICLE_PUNCH_BLOCK_SOUTH = 3606;
public const PARTICLE_PUNCH_BLOCK_WEST = 3607;
public const PARTICLE_PUNCH_BLOCK_EAST = 3608;
public const PARTICLE_SHOOT_WHITE_SMOKE = 3609;

public const SET_DATA = 4000;

Expand Down
10 changes: 10 additions & 0 deletions src/types/LevelSoundEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,16 @@ private function __construct(){
public const MOB_HOGLIN_CONVERTED_TO_ZOMBIFIED = 474;
public const AMBIENT_UNDERWATER_ENTER = 475;
public const AMBIENT_UNDERWATER_EXIT = 476;
public const BOTTLE_FILL = 477;
public const BOTTLE_EMPTY = 478;
public const CRAFTER_CRAFT = 479;
public const CRAFTER_FAIL = 480;
public const BLOCK_DECORATED_POT_INSERT = 481;
public const BLOCK_DECORATED_POT_INSERT_FAIL = 482;
public const CRAFTER_DISABLE_SLOT = 483;

public const BLOCK_COPPER_BULB_TURN_ON = 490;
public const BLOCK_COPPER_BULB_TURN_OFF = 491;

//The following aliases are kept for backwards compatibility only
public const SCULK_SENSOR_POWER_ON = self::POWER_ON_SCULK_SENSOR;
Expand Down
Loading

0 comments on commit 2a98eb7

Please sign in to comment.