Skip to content

Commit

Permalink
first work on 1.21.20: waiting for upstream to release all dependecies
Browse files Browse the repository at this point in the history
  • Loading branch information
ShockedPlot7560 committed Aug 14, 2024
1 parent e9bb93f commit 87a3e1f
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 47 deletions.
14 changes: 9 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
"composer-runtime-api": "^2.0",
"adhocore/json-comment": "~1.2.0",
"fgrosse/phpasn1": "~2.5.0",
"pocketmine/bedrock-block-upgrade-schema": "~4.2.0+bedrock-1.21.0",
"pocketmine/bedrock-data": "~2.11.0+bedrock-1.21.0",
"pocketmine/bedrock-item-upgrade-schema": "~1.10.0+bedrock-1.21.0",
"pocketmine/bedrock-protocol": "~32.1.0+bedrock-1.21.2",
"pocketmine/bedrock-block-upgrade-schema": "~4.3.0+bedrock-1.21.20",
"pocketmine/bedrock-data": "dev-feature/1.21.20",
"pocketmine/bedrock-item-upgrade-schema": "~1.11.0+bedrock-1.21.20",
"pocketmine/bedrock-protocol": "dev-master",
"pocketmine/binaryutils": "^0.2.1",
"pocketmine/callback-validator": "^1.0.2",
"pocketmine/classloader": "^0.2.0",
Expand Down Expand Up @@ -93,5 +93,9 @@
"update-translation-apis": [
"@php build/generate-known-translation-apis.php"
]
}
},
"repositories": [{
"type": "vcs",
"url": "[email protected]:dries-c/BedrockProtocol.git"
}]
}
72 changes: 42 additions & 30 deletions composer.lock

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

11 changes: 7 additions & 4 deletions src/network/mcpe/InventoryManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -451,14 +451,16 @@ private function sendInventorySlotPackets(int $windowId, int $netSlot, ItemStack
$this->session->sendDataPacket(InventorySlotPacket::create(
$windowId,
$netSlot,
new ItemStackWrapper(0, ItemStack::null())
new ItemStackWrapper(0, ItemStack::null()),
0
));
}
//now send the real contents
$this->session->sendDataPacket(InventorySlotPacket::create(
$windowId,
$netSlot,
$itemStackWrapper
$itemStackWrapper,
0
));
}

Expand All @@ -476,10 +478,11 @@ private function sendInventoryContentPackets(int $windowId, array $itemStackWrap
*/
$this->session->sendDataPacket(InventoryContentPacket::create(
$windowId,
array_fill_keys(array_keys($itemStackWrappers), new ItemStackWrapper(0, ItemStack::null()))
array_fill_keys(array_keys($itemStackWrappers), new ItemStackWrapper(0, ItemStack::null())),
0
));
//now send the real contents
$this->session->sendDataPacket(InventoryContentPacket::create($windowId, $itemStackWrappers));
$this->session->sendDataPacket(InventoryContentPacket::create($windowId, $itemStackWrappers, 0));
}

public function syncSlot(Inventory $inventory, int $slot, ItemStack $itemStack) : void{
Expand Down
4 changes: 2 additions & 2 deletions src/network/mcpe/NetworkSession.php
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ private function dispose() : void{
public function disconnect(string $reason, bool $notify = true) : void{
$this->tryDisconnect(function() use ($reason, $notify) : void{
if($notify){
$this->sendDataPacket(DisconnectPacket::create(0, $reason));
$this->sendDataPacket(DisconnectPacket::create(0, $reason, ""));
}
if($this->player !== null){
$this->player->onPostDisconnect($reason, null);
Expand All @@ -658,7 +658,7 @@ public function transfer(string $ip, int $port, string $reason = "transfer") : v
*/
public function onPlayerDestroyed(string $reason) : void{
$this->tryDisconnect(function() use ($reason) : void{
$this->sendDataPacket(DisconnectPacket::create(0, $reason));
$this->sendDataPacket(DisconnectPacket::create(0, $reason, ""));
}, $reason);
}

Expand Down
4 changes: 3 additions & 1 deletion src/network/mcpe/StandardEntityEventBroadcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
use pocketmine\network\mcpe\protocol\types\entity\Attribute as NetworkAttribute;
use pocketmine\network\mcpe\protocol\types\entity\PropertySyncData;
use pocketmine\network\mcpe\protocol\types\inventory\ContainerIds;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStack;
use pocketmine\network\mcpe\protocol\types\inventory\ItemStackWrapper;
use pocketmine\network\mcpe\protocol\UpdateAttributesPacket;
use function array_map;
Expand Down Expand Up @@ -130,7 +131,8 @@ public function onMobArmorChange(array $recipients, Living $mob) : void{
ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getHelmet())),
ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getChestplate())),
ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getLeggings())),
ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getBoots()))
ItemStackWrapper::legacy($converter->coreItemStackToNet($inv->getBoots())),
new ItemStackWrapper(0, ItemStack::null())
));
}

Expand Down
8 changes: 4 additions & 4 deletions src/network/mcpe/handler/ItemStackRequestExecutor.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ private function matchItemStack(Inventory $inventory, int $slotId, int $clientIt
* @throws ItemStackRequestProcessException
*/
protected function getBuilderInventoryAndSlot(ItemStackRequestSlotInfo $info) : array{
[$windowId, $slotId] = ItemStackContainerIdTranslator::translate($info->getContainerId(), $this->inventoryManager->getCurrentWindowId(), $info->getSlotId());
[$windowId, $slotId] = ItemStackContainerIdTranslator::translate($info->getContainerName()->getContainerId(), $this->inventoryManager->getCurrentWindowId(), $info->getSlotId());
$windowAndSlot = $this->inventoryManager->locateWindowAndSlot($windowId, $slotId);
if($windowAndSlot === null){
throw new ItemStackRequestProcessException("No open inventory matches container UI ID: " . $info->getContainerId() . ", slot ID: " . $info->getSlotId());
throw new ItemStackRequestProcessException("No open inventory matches container UI ID: " . $info->getContainerName()->getContainerId() . ", slot ID: " . $info->getSlotId());
}
[$inventory, $slot] = $windowAndSlot;
if(!$inventory->slotExists($slot)){
Expand All @@ -141,7 +141,7 @@ protected function transferItems(ItemStackRequestSlotInfo $source, ItemStackRequ
* @throws ItemStackRequestProcessException
*/
protected function removeItemFromSlot(ItemStackRequestSlotInfo $slotInfo, int $count) : Item{
if($slotInfo->getContainerId() === ContainerUIIds::CREATED_OUTPUT && $slotInfo->getSlotId() === UIInventorySlotOffset::CREATED_ITEM_OUTPUT){
if($slotInfo->getContainerName()->getContainerId() === ContainerUIIds::CREATED_OUTPUT && $slotInfo->getSlotId() === UIInventorySlotOffset::CREATED_ITEM_OUTPUT){
//special case for the "created item" output slot
//TODO: do we need to send a response for this slot info?
return $this->takeCreatedItem($count);
Expand Down Expand Up @@ -381,7 +381,7 @@ public function generateInventoryTransaction() : InventoryTransaction{
public function buildItemStackResponse() : ItemStackResponse{
$builder = new ItemStackResponseBuilder($this->request->getRequestId(), $this->inventoryManager);
foreach($this->requestSlotInfos as $requestInfo){
$builder->addSlot($requestInfo->getContainerId(), $requestInfo->getSlotId());
$builder->addSlot($requestInfo->getContainerName()->getContainerId(), $requestInfo->getSlotId());
}

return $builder->build();
Expand Down
3 changes: 2 additions & 1 deletion src/network/mcpe/handler/ItemStackResponseBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use pocketmine\item\Durable;
use pocketmine\network\mcpe\InventoryManager;
use pocketmine\network\mcpe\protocol\types\inventory\ContainerUIIds;
use pocketmine\network\mcpe\protocol\types\inventory\FullContainerName;
use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponse;
use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponseContainerInfo;
use pocketmine\network\mcpe\protocol\types\inventory\stackresponse\ItemStackResponseSlotInfo;
Expand Down Expand Up @@ -99,7 +100,7 @@ public function build() : ItemStackResponse{

$responseContainerInfos = [];
foreach($responseInfosByContainer as $containerInterfaceId => $responseInfos){
$responseContainerInfos[] = new ItemStackResponseContainerInfo($containerInterfaceId, $responseInfos);
$responseContainerInfos[] = new ItemStackResponseContainerInfo(new FullContainerName($containerInterfaceId, 0), $responseInfos);
}

return new ItemStackResponse(ItemStackResponse::RESULT_OK, $this->requestId, $responseContainerInfos);
Expand Down

0 comments on commit 87a3e1f

Please sign in to comment.