Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dries-c committed Aug 16, 2024
1 parent f47772b commit a9af3ce
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/types/camera/CameraSetInstruction.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use pocketmine\nbt\tag\DoubleTag;
use pocketmine\nbt\tag\FloatTag;
use pocketmine\nbt\tag\ListTag;
use pocketmine\network\mcpe\protocol\ProtocolInfo;
use pocketmine\network\mcpe\protocol\serializer\PacketSerializer;
use function count;
use function is_infinite;
Expand Down Expand Up @@ -58,7 +59,9 @@ public static function read(PacketSerializer $in) : self{
$cameraPosition = $in->readOptional($in->getVector3(...));
$rotation = $in->readOptional(fn() => CameraSetInstructionRotation::read($in));
$facingPosition = $in->readOptional($in->getVector3(...));
$viewOffset = $in->readOptional($in->getVector2(...));
if($in->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){
$viewOffset = $in->readOptional($in->getVector2(...));
}
$default = $in->readOptional($in->getBool(...));

return new self(
Expand All @@ -67,7 +70,7 @@ public static function read(PacketSerializer $in) : self{
$cameraPosition,
$rotation,
$facingPosition,
$viewOffset,
$viewOffset ?? null,
$default
);
}
Expand Down Expand Up @@ -96,6 +99,7 @@ public static function fromNBT(CompoundTag $nbt) : self{
$cameraPosition,
$rotation,
$facingPosition,
null,
$default
);
}
Expand All @@ -106,7 +110,9 @@ public function write(PacketSerializer $out) : void{
$out->writeOptional($this->cameraPosition, $out->putVector3(...));
$out->writeOptional($this->rotation, fn(CameraSetInstructionRotation $v) => $v->write($out));
$out->writeOptional($this->facingPosition, $out->putVector3(...));
$out->writeOptional($this->viewOffset, $out->putVector2(...));
if($out->getProtocolId() >= ProtocolInfo::PROTOCOL_1_21_20){
$out->writeOptional($this->viewOffset, $out->putVector2(...));
}
$out->writeOptional($this->default, $out->putBool(...));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ final public function __construct(

public function getRecipeId() : int{ return $this->recipeId; }

public function getRepetitions() : int { return $this->repetitions; }
public function getRepetitions() : int{ return $this->repetitions; }

public function getRepetitions2() : int{ return $this->repetitions2; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ final public function __construct(

public function getRecipeId() : int{ return $this->recipeId; }

public function getRepetitions() : int { return $this->repetitions; }
public function getRepetitions() : int{ return $this->repetitions; }

public static function read(PacketSerializer $in) : self{
$recipeId = $in->readRecipeNetId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function __construct(

public function getCreativeItemId() : int{ return $this->creativeItemId; }

public function getRepetitions() : int { return $this->repetitions; }
public function getRepetitions() : int{ return $this->repetitions; }

public static function read(PacketSerializer $in) : self{
$creativeItemId = $in->readCreativeItemNetId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function getRecipeId() : int{ return $this->recipeId; }
/** WARNING: This may be negative */
public function getRepairCost() : int{ return $this->repairCost; }

public function getRepetitions() : int { return $this->repetitions; }
public function getRepetitions() : int{ return $this->repetitions; }

public static function read(PacketSerializer $in) : self{
$recipeId = $in->readRecipeNetId();
Expand Down
2 changes: 2 additions & 0 deletions src/types/inventory/stackrequest/ItemStackRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ private static function readAction(PacketSerializer $in, int $typeId) : ItemStac
DestroyStackRequestAction::ID => DestroyStackRequestAction::read($in),
CraftingConsumeInputStackRequestAction::ID => CraftingConsumeInputStackRequestAction::read($in),
CraftingCreateSpecificResultStackRequestAction::ID => CraftingCreateSpecificResultStackRequestAction::read($in),
PlaceIntoBundleStackRequestAction::ID => PlaceIntoBundleStackRequestAction::read($in),
TakeFromBundleStackRequestAction::ID => TakeFromBundleStackRequestAction::read($in),
LabTableCombineStackRequestAction::ID => LabTableCombineStackRequestAction::read($in),
BeaconPaymentStackRequestAction::ID => BeaconPaymentStackRequestAction::read($in),
MineBlockStackRequestAction::ID => MineBlockStackRequestAction::read($in),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ private function __construct(){
public const DESTROY = 4;
public const CRAFTING_CONSUME_INPUT = 5;
public const CRAFTING_CREATE_SPECIFIC_RESULT = 6;
public const PLACE_INTO_BUNDLE = 7;
public const TAKE_FROM_BUNDLE = 8;
public const LAB_TABLE_COMBINE = 9;
public const BEACON_PAYMENT = 10;
public const MINE_BLOCK = 11;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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\types\inventory\stackrequest;

use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait;

/**
* Insert an item into a bundle.
*/
final class PlaceIntoBundleStackRequestAction extends ItemStackRequestAction{
use GetTypeIdFromConstTrait;
use TakeOrPlaceStackRequestActionTrait;

public const ID = ItemStackRequestActionType::PLACE_INTO_BUNDLE;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?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\types\inventory\stackrequest;

use pocketmine\network\mcpe\protocol\types\GetTypeIdFromConstTrait;

/**
* Take an item out of a bundle.
*/
final class TakeFromBundleStackRequestAction extends ItemStackRequestAction{
use GetTypeIdFromConstTrait;
use TakeOrPlaceStackRequestActionTrait;

public const ID = ItemStackRequestActionType::TAKE_FROM_BUNDLE;
}

0 comments on commit a9af3ce

Please sign in to comment.