Skip to content

Commit

Permalink
feat: 1.21.0 support (#278)
Browse files Browse the repository at this point in the history
Co-authored-by: JoseLuisHD <joseluis.herrejon.developer@gmail.com>
  • Loading branch information
Benedikt05 and JoseLuisHD committed Jun 15, 2024
1 parent 5b3b987 commit 7e6b0ab
Show file tree
Hide file tree
Showing 24 changed files with 798 additions and 630 deletions.
31 changes: 31 additions & 0 deletions .idea/php.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<p align="center">
<img src="https://github.com/Benedikt05/BetterAltay/blob/master/.github/logo.png"></img><br>
<b>A feature-rich server software for Minecraft: BE. This is a Fork of </b><a href="https://github.com/pmmp/PocketMine-MP/tree/3.28.0">PocketMine-MP</a><b> and </b><a href="https://github.com/unresolved3169/Altay">Altay</a><br><br>This fork was created due to the inactivity of Altay.
It currently supports Minecraft: Bedrock Edition v1.20.80<br><br><br>
It currently supports Minecraft: Bedrock Edition v1.21.0<br><br><br>
</p>
<p align="center">
<a href="https://discord.gg/spquK3Q66W"><img src="https://img.shields.io/discord/930544524655202317?logo=Discord" alt="Discord" /></a>
Expand Down
43 changes: 22 additions & 21 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/pocketmine/VersionInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@

const NAME = "BetterAltay";
const BASE_VERSION = "3.28.0"; //Don't change this anymore. Change the FORK_VERSION instead.
const FORK_VERSION = "1.21.1";
const FORK_VERSION = "1.22.0";
const IS_DEVELOPMENT_BUILD = false;
const BUILD_CHANNEL = "master";
10 changes: 5 additions & 5 deletions src/pocketmine/network/mcpe/NetworkSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
use pocketmine\network\mcpe\protocol\AutomationClientConnectPacket;
use pocketmine\network\mcpe\protocol\AvailableActorIdentifiersPacket;
use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
use pocketmine\network\mcpe\protocol\AwardAchievementPacket;
use pocketmine\network\mcpe\protocol\BiomeDefinitionListPacket;
use pocketmine\network\mcpe\protocol\BlockActorDataPacket;
use pocketmine\network\mcpe\protocol\BlockEventPacket;
Expand Down Expand Up @@ -188,7 +189,6 @@
use pocketmine\network\mcpe\protocol\SyncActorPropertyPacket;
use pocketmine\network\mcpe\protocol\TakeItemActorPacket;
use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\TickSyncPacket;
use pocketmine\network\mcpe\protocol\ToastRequestPacket;
use pocketmine\network\mcpe\protocol\TransferPacket;
use pocketmine\network\mcpe\protocol\UpdateAbilitiesPacket;
Expand Down Expand Up @@ -294,10 +294,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 @@ -926,4 +922,8 @@ public function handleSetHud(SetHudPacket $packet) : bool{
return false;
}

public function handleAwardAchievement(AwardAchievementPacket $packet) : bool{
return false;
}

}
7 changes: 0 additions & 7 deletions src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
use pocketmine\network\mcpe\protocol\ShowCreditsPacket;
use pocketmine\network\mcpe\protocol\SpawnExperienceOrbPacket;
use pocketmine\network\mcpe\protocol\TextPacket;
use pocketmine\network\mcpe\protocol\TickSyncPacket;
use pocketmine\network\mcpe\protocol\types\RequestAbilityType;
use pocketmine\network\mcpe\protocol\types\SkinAdapterSingleton;
use pocketmine\network\mcpe\protocol\UpdateAdventureSettingsPacket;
Expand Down Expand Up @@ -373,12 +372,6 @@ public function handleSetLocalPlayerAsInitialized(SetLocalPlayerAsInitializedPac
return true;
}

public function handleTickSync(TickSyncPacket $packet) : bool{
$this->player->sendDataPacket(TickSyncPacket::response($packet->getClientSendTime(), time()));

return true;
}

public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{
return $this->player->handleLevelSoundEvent($packet);
}
Expand Down
1 change: 1 addition & 0 deletions src/pocketmine/network/mcpe/convert/ItemTranslator.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ private static function make() : self{
if(!is_numeric($meta) || !is_string($newId)){
throw new AssumptionFailedError("Invalid item table format");
}
$legacyStringToIntMap["minecraft:stone_block_slab"] = 44;
$complexMappings[$newId] = [$legacyStringToIntMap[$oldId], (int) $meta];
}
}
Expand Down
27 changes: 27 additions & 0 deletions src/pocketmine/network/mcpe/protocol/AwardAchievementPacket.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace pocketmine\network\mcpe\protocol;

#include <rules/DataPacket.h>

use pocketmine\network\mcpe\NetworkSession;

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

public int $achievementId;

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

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

public function handle(NetworkSession $session) : bool{
return $session->handleAwardAchievement($this);
}
}
12 changes: 6 additions & 6 deletions src/pocketmine/network/mcpe/protocol/CodeBuilderSourcePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,35 +30,35 @@ class CodeBuilderSourcePacket extends DataPacket{

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() : void{
$this->operation = $this->getByte();
$this->category = $this->getByte();
$this->value = $this->getString();
$this->codeStatus = $this->getByte();
}

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

public function handle(NetworkSession $session) : bool{
Expand Down
14 changes: 8 additions & 6 deletions src/pocketmine/network/mcpe/protocol/ContainerClosePacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,24 @@
#include <rules/DataPacket.h>

use pocketmine\network\mcpe\NetworkSession;
use pocketmine\network\mcpe\protocol\types\WindowTypes;

class ContainerClosePacket extends DataPacket{
public const NETWORK_ID = ProtocolInfo::CONTAINER_CLOSE_PACKET;

/** @var int */
public $windowId;
/** @var bool */
public $server = false;
public int $windowId;
public int $type = WindowTypes::CONTAINER;
public bool $server = false;

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

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

Expand Down
4 changes: 4 additions & 0 deletions src/pocketmine/network/mcpe/protocol/CraftingDataPacket.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ class CraftingDataPacket extends DataPacket{
public const ENTRY_SHULKER_BOX = 5; //TODO
public const ENTRY_SHAPELESS_CHEMISTRY = 6; //TODO
public const ENTRY_SHAPED_CHEMISTRY = 7; //TODO
public const ENTRY_SMITHING_TRANSFORM = 8; //TODO
public const ENTRY_SMITHING_TRIM = 9; //TODO

/** @var object[] */
public array $entries = [];
Expand Down Expand Up @@ -221,6 +223,7 @@ private static function writeShapelessRecipe(ShapelessRecipe $recipe, NetworkBin
$stream->put(str_repeat("\x00", 16)); //Null UUID
$stream->putString("crafting_table"); //TODO: blocktype (no prefix) (this might require internal API breaks)
$stream->putVarInt(50); //TODO: priority
$stream->putByte(1); //TODO: recipe unlocking requirement - always unlocked
$stream->putUnsignedVarInt($pos); //TODO: ANOTHER recipe ID, only used on the network

return CraftingDataPacket::ENTRY_SHAPELESS;
Expand All @@ -247,6 +250,7 @@ private static function writeShapedRecipe(ShapedRecipe $recipe, NetworkBinaryStr
$stream->putString("crafting_table"); //TODO: blocktype (no prefix) (this might require internal API breaks)
$stream->putVarInt(50); //TODO: priority
$stream->putBool(true); //TODO: assume symmetry
$stream->putByte(1); //TODO: recipe unlocking requirement - always unlocked
$stream->putUnsignedVarInt($pos); //TODO: ANOTHER recipe ID, only used on the network

return CraftingDataPacket::ENTRY_SHAPED;
Expand Down
2 changes: 1 addition & 1 deletion src/pocketmine/network/mcpe/protocol/PacketPool.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ public static function init(){
static::registerPacket(new PassengerJumpPacket());
static::registerPacket(new UpdateBlockPacket());
static::registerPacket(new AddPaintingPacket());
static::registerPacket(new TickSyncPacket());
static::registerPacket(new LevelSoundEventPacketV1());
static::registerPacket(new LevelEventPacket());
static::registerPacket(new BlockEventPacket());
Expand Down Expand Up @@ -216,6 +215,7 @@ public static function init(){
static::registerPacket(new UnlockedRecipesPacket());
static::registerPacket(new OpenSignPacket());
static::registerPacket(new SetHudPacket());
static::registerPacket(new AwardAchievementPacket());
}

/**
Expand Down
Loading

0 comments on commit 7e6b0ab

Please sign in to comment.