Skip to content

Commit

Permalink
Protocol changes for 1.21.0.25 beta
Browse files Browse the repository at this point in the history
  • Loading branch information
dktapps committed Jun 13, 2024
1 parent c26a50a commit 972373b
Show file tree
Hide file tree
Showing 18 changed files with 173 additions and 88 deletions.
2 changes: 1 addition & 1 deletion src/AvailableCommandsPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class AvailableCommandsPacket extends DataPacket implements ClientboundPacket{

public const ARG_TYPE_BLOCK_STATES = ArgTypes::BLOCK_STATE_ARRAY;

public const ARG_TYPE_COMMAND = ArgTypes::SLASHCOMMAND;
public const ARG_TYPE_COMMAND = ArgTypes::CODEBUILDERARGS;

/**
* Enums are a little different: they are composed as follows:
Expand Down
46 changes: 46 additions & 0 deletions src/AwardAchievementPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?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;

class AwardAchievementPacket extends DataPacket implements ClientboundPacket{
public const NETWORK_ID = ProtocolInfo::AWARD_ACHIEVEMENT_PACKET;

private int $achievementId;

/**
* @generate-create-func
*/
public static function create(int $achievementId) : self{
$result = new self;
$result->achievementId = $achievementId;
return $result;
}

public function getAchievementId() : int{ return $this->achievementId; }

protected function decodePayload(PacketSerializer $in) : void{
$this->achievementId = $in->getLInt();
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putLInt($this->achievementId);
}

public function handle(PacketHandlerInterface $handler) : bool{
return $handler->handleAwardAchievement($this);
}
}
12 changes: 6 additions & 6 deletions src/CodeBuilderSourcePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,35 @@ class CodeBuilderSourcePacket extends DataPacket implements ServerboundPacket{

private int $operation;
private int $category;
private string $value;
private int $codeStatus;

/**
* @generate-create-func
*/
public static function create(int $operation, int $category, string $value) : self{
public static function create(int $operation, int $category, int $codeStatus) : self{
$result = new self;
$result->operation = $operation;
$result->category = $category;
$result->value = $value;
$result->codeStatus = $codeStatus;
return $result;
}

public function getOperation() : int{ return $this->operation; }

public function getCategory() : int{ return $this->category; }

public function getValue() : string{ return $this->value; }
public function getCodeStatus() : int{ return $this->codeStatus; }

protected function decodePayload(PacketSerializer $in) : void{
$this->operation = $in->getByte();
$this->category = $in->getByte();
$this->value = $in->getString();
$this->codeStatus = $in->getByte();
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->operation);
$out->putByte($this->category);
$out->putString($this->value);
$out->putByte($this->codeStatus);
}

public function handle(PacketHandlerInterface $handler) : bool{
Expand Down
6 changes: 5 additions & 1 deletion src/ContainerClosePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,29 @@ class ContainerClosePacket extends DataPacket implements ClientboundPacket, Serv
public const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET;

public int $windowId;
public int $windowType;
public bool $server = false;

/**
* @generate-create-func
*/
public static function create(int $windowId, bool $server) : self{
public static function create(int $windowId, int $windowType, bool $server) : self{
$result = new self;
$result->windowId = $windowId;
$result->windowType = $windowType;
$result->server = $server;
return $result;
}

protected function decodePayload(PacketSerializer $in) : void{
$this->windowId = $in->getByte();
$this->windowType = $in->getByte();
$this->server = $in->getBool();
}

protected function encodePayload(PacketSerializer $out) : void{
$out->putByte($this->windowId);
$out->putByte($this->windowType);
$out->putBool($this->server);
}

Expand Down
4 changes: 3 additions & 1 deletion src/CraftingDataPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public static function create(array $recipesWithTypeIds, array $potionTypeRecipe

protected function decodePayload(PacketSerializer $in) : void{
$recipeCount = $in->getUnsignedVarInt();
$previousType = "none";
for($i = 0; $i < $recipeCount; ++$i){
$recipeType = $in->getVarInt();

Expand All @@ -81,8 +82,9 @@ protected function decodePayload(PacketSerializer $in) : void{
self::ENTRY_MULTI => MultiRecipe::decode($recipeType, $in),
self::ENTRY_SMITHING_TRANSFORM => SmithingTransformRecipe::decode($recipeType, $in),
self::ENTRY_SMITHING_TRIM => SmithingTrimRecipe::decode($recipeType, $in),
default => throw new PacketDecodeException("Unhandled recipe type $recipeType!"),
default => throw new PacketDecodeException("Unhandled recipe type $recipeType (previous was $previousType)"),
};
$previousType = $recipeType;
}
for($i = 0, $count = $in->getUnsignedVarInt(); $i < $count; ++$i){
$inputId = $in->getVarInt();
Expand Down
8 changes: 4 additions & 4 deletions src/PacketHandlerDefaultImplTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,6 @@ public function handleAddPainting(AddPaintingPacket $packet) : bool{
return false;
}

public function handleTickSync(TickSyncPacket $packet) : bool{
return false;
}

public function handleLevelSoundEventPacketV1(LevelSoundEventPacketV1 $packet) : bool{
return false;
}
Expand Down Expand Up @@ -801,4 +797,8 @@ public function handleSetPlayerInventoryOptions(SetPlayerInventoryOptionsPacket
public function handleSetHud(SetHudPacket $packet) : bool{
return false;
}

public function handleAwardAchievement(AwardAchievementPacket $packet) : bool{
return false;
}
}
4 changes: 2 additions & 2 deletions src/PacketHandlerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ public function handleUpdateBlock(UpdateBlockPacket $packet) : bool;

public function handleAddPainting(AddPaintingPacket $packet) : bool;

public function handleTickSync(TickSyncPacket $packet) : bool;

public function handleLevelSoundEventPacketV1(LevelSoundEventPacketV1 $packet) : bool;

public function handleLevelEvent(LevelEventPacket $packet) : bool;
Expand Down Expand Up @@ -407,4 +405,6 @@ public function handlePlayerToggleCrafterSlotRequest(PlayerToggleCrafterSlotRequ
public function handleSetPlayerInventoryOptions(SetPlayerInventoryOptionsPacket $packet) : bool;

public function handleSetHud(SetHudPacket $packet) : bool;

public function handleAwardAchievement(AwardAchievementPacket $packet) : bool;
}
2 changes: 1 addition & 1 deletion src/PacketPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ public function __construct(){
$this->registerPacket(new PassengerJumpPacket());
$this->registerPacket(new UpdateBlockPacket());
$this->registerPacket(new AddPaintingPacket());
$this->registerPacket(new TickSyncPacket());
$this->registerPacket(new LevelSoundEventPacketV1());
$this->registerPacket(new LevelEventPacket());
$this->registerPacket(new BlockEventPacket());
Expand Down Expand Up @@ -228,6 +227,7 @@ public function __construct(){
$this->registerPacket(new PlayerToggleCrafterSlotRequestPacket());
$this->registerPacket(new SetPlayerInventoryOptionsPacket());
$this->registerPacket(new SetHudPacket());
$this->registerPacket(new AwardAchievementPacket());
}

public function registerPacket(Packet $packet) : void{
Expand Down
9 changes: 5 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 = 671;
public const CURRENT_PROTOCOL = 685;
/** Current Minecraft PE version reported by the server. This is usually the earliest currently supported version. */
public const MINECRAFT_VERSION = 'v1.20.80';
public const MINECRAFT_VERSION = 'v1.21.0';
/** Version number sent to clients in ping responses. */
public const MINECRAFT_VERSION_NETWORK = '1.20.80';
public const MINECRAFT_VERSION_NETWORK = '1.21.0';

public const LOGIN_PACKET = 0x01;
public const PLAY_STATUS_PACKET = 0x02;
Expand All @@ -60,7 +60,7 @@ private function __construct(){
public const PASSENGER_JUMP_PACKET = 0x14;
public const UPDATE_BLOCK_PACKET = 0x15;
public const ADD_PAINTING_PACKET = 0x16;
public const TICK_SYNC_PACKET = 0x17;

public const LEVEL_SOUND_EVENT_PACKET_V1 = 0x18;
public const LEVEL_EVENT_PACKET = 0x19;
public const BLOCK_EVENT_PACKET = 0x1a;
Expand Down Expand Up @@ -244,5 +244,6 @@ private function __construct(){
public const PLAYER_TOGGLE_CRAFTER_SLOT_REQUEST_PACKET = 0x132;
public const SET_PLAYER_INVENTORY_OPTIONS_PACKET = 0x133;
public const SET_HUD_PACKET = 0x134;
public const AWARD_ACHIEVEMENT_PACKET = 0x135;

}
3 changes: 3 additions & 0 deletions src/TextPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ class TextPacket extends DataPacket implements ClientboundPacket, ServerboundPac
public array $parameters = [];
public string $xboxUserId = "";
public string $platformChatId = "";
public string $filteredMessage = "";

private static function messageOnly(int $type, string $message) : self{
$result = new self;
Expand Down Expand Up @@ -125,6 +126,7 @@ protected function decodePayload(PacketSerializer $in) : void{

$this->xboxUserId = $in->getString();
$this->platformChatId = $in->getString();
$this->filteredMessage = $in->getString();
}

protected function encodePayload(PacketSerializer $out) : void{
Expand Down Expand Up @@ -158,6 +160,7 @@ protected function encodePayload(PacketSerializer $out) : void{

$out->putString($this->xboxUserId);
$out->putString($this->platformChatId);
$out->putString($this->filteredMessage);
}

public function handle(PacketHandlerInterface $handler) : bool{
Expand Down
64 changes: 0 additions & 64 deletions src/TickSyncPacket.php

This file was deleted.

10 changes: 10 additions & 0 deletions src/types/LevelSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ final class LevelSettings{
public int $chatRestrictionLevel = ChatRestrictionLevel::NONE;
public bool $disablePlayerInteractions = false;

public string $serverIdentifier = "";
public string $worldIdentifier = "";
public string $scenarioIdentifier = "";

/**
* @throws BinaryDataException
* @throws PacketDecodeException
Expand Down Expand Up @@ -141,6 +145,9 @@ private function internalRead(PacketSerializer $in) : void{
$this->experimentalGameplayOverride = $in->readOptional($in->getBool(...));
$this->chatRestrictionLevel = $in->getByte();
$this->disablePlayerInteractions = $in->getBool();
$this->serverIdentifier = $in->getString();
$this->worldIdentifier = $in->getString();
$this->scenarioIdentifier = $in->getString();
}

public function write(PacketSerializer $out) : void{
Expand Down Expand Up @@ -192,5 +199,8 @@ public function write(PacketSerializer $out) : void{
$out->writeOptional($this->experimentalGameplayOverride, $out->putBool(...));
$out->putByte($this->chatRestrictionLevel);
$out->putBool($this->disablePlayerInteractions);
$out->putString($this->serverIdentifier);
$out->putString($this->worldIdentifier);
$out->putString($this->scenarioIdentifier);
}
}
14 changes: 13 additions & 1 deletion src/types/LevelSoundEvent.php
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,20 @@ private function __construct(){
public const ARMOR_REPAIR_WOLF = 513;
public const MACE_SMASH_AIR = 514;
public const MACE_SMASH_GROUND = 515;

public const TRIAL_SPAWNER_CHARGE_ACTIVATE = 516;
public const TRIAL_SPAWNER_AMBIENT_OMINOUS = 517;
public const OMINOUS_ITEM_SPAWNER_SPAWN_ITEM = 518;
public const OMINOUS_BOTTLE_END_USE = 519;
public const MACE_HEAVY_SMASH_GROUND = 520;
public const OMINOUS_ITEM_SPAWNER_SPAWN_ITEM_BEGIN = 521;

public const APPLY_EFFECT_BAD_OMEN = 523;
public const APPLY_EFFECT_RAID_OMEN = 524;
public const APPLY_EFFECT_TRIAL_OMEN = 525;
public const OMINOUS_ITEM_SPAWNER_ABOUT_TO_SPAWN_ITEM = 526;
public const RECORD_CREATOR = 527;
public const RECORD_CREATOR_MUSIC_BOX = 528;
public const RECORD_PRECIPICE = 529;

//The following aliases are kept for backwards compatibility only
public const SCULK_SENSOR_POWER_ON = self::POWER_ON_SCULK_SENSOR;
Expand Down
2 changes: 1 addition & 1 deletion src/types/command/CommandParameterTypes.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,5 @@ private function __construct(){
public const RAWTEXT = 70; // text
public const JSON_OBJECT = 74; // json
public const BLOCK_STATE_ARRAY = 84; // block states
public const SLASHCOMMAND = 87; // command
public const CODEBUILDERARGS = 87; // command
}
1 change: 1 addition & 0 deletions src/types/entity/EntityIds.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ private function __construct(){
public const MULE = "minecraft:mule";
public const NPC = "minecraft:npc";
public const OCELOT = "minecraft:ocelot";
public const OMINOUS_ITEM_SPAWNER = "minecraft:ominous_item_spawner";
public const PAINTING = "minecraft:painting";
public const PANDA = "minecraft:panda";
public const PARROT = "minecraft:parrot";
Expand Down
Loading

1 comment on commit 972373b

@CJMustard1452
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Memory of Dylan: A Eulogy

Today, we gather with heavy hearts to bid farewell to a visionary, a leader, and a friend. We come together to honor the life and legacy of Dylan, the head of Minecraft Bedrock Server framework Pocketmine-MP, whose passion and dedication breathed life into digital realms and touched the hearts of many.

Dylan was more than just a developer; he was a guiding light, a driving force behind the evolution of Pocketmine-MP. With his keen intellect and boundless creativity, he transformed mere lines of code into gateways of imagination, empowering players and developers alike to explore, create, and connect in ways previously unimaginable.

But Dylan was more than just a master of his craft; he was a mentor, a friend, and a pillar of support for those fortunate enough to cross paths with him. Whether troubleshooting technical issues or offering words of encouragement, Dylan approached every interaction with kindness, patience, and a genuine desire to help others succeed.

Under Dylan's stewardship, Pocketmine-MP blossomed into a vibrant community, a melting pot of ideas and aspirations united by a common love for Minecraft and the boundless possibilities it offered. Through his leadership, Dylan fostered an environment where creativity thrived, where friendships flourished, and where dreams took flight.

As we mourn the loss of Dylan, let us also celebrate the legacy he leaves behind. Let us remember the countless lives he touched, the countless worlds he helped bring to life, and the countless memories he helped create. Though Dylan may no longer walk among us, his spirit will forever endure in the countless lives he touched and the communities he helped build.

Rest in peace, Dylan. Your journey may have come to an end, but your legacy will live on in the hearts and minds of all who had the privilege of knowing you. Thank you for the memories, the guidance, and the countless moments of joy you brought into our lives. You will be dearly missed, but never forgotten.

Please sign in to comment.