-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
266 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<?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\MovementEffectType; | ||
|
||
class MovementEffectPacket extends DataPacket implements ClientboundPacket{ | ||
public const NETWORK_ID = ProtocolInfo::MOVEMENT_EFFECT_PACKET; | ||
|
||
private int $actorRuntimeId; | ||
private MovementEffectType $effectType; | ||
private int $duration; | ||
private int $tick; | ||
|
||
/** | ||
* @generate-create-func | ||
*/ | ||
public static function create(int $actorRuntimeId, MovementEffectType $effectType, int $duration, int $tick) : self{ | ||
$result = new self; | ||
$result->actorRuntimeId = $actorRuntimeId; | ||
$result->effectType = $effectType; | ||
$result->duration = $duration; | ||
$result->tick = $tick; | ||
return $result; | ||
} | ||
|
||
public function getActorRuntimeId() : int{ return $this->actorRuntimeId; } | ||
|
||
public function getEffectType() : MovementEffectType{ return $this->effectType; } | ||
|
||
public function getDuration() : int{ return $this->duration; } | ||
|
||
public function getTick() : int{ return $this->tick; } | ||
|
||
protected function decodePayload(PacketSerializer $in) : void{ | ||
$this->actorRuntimeId = $in->getActorRuntimeId(); | ||
$this->effectType = MovementEffectType::fromPacket($in->getUnsignedVarInt()); | ||
$this->duration = $in->getUnsignedVarInt(); | ||
$this->tick = $in->getUnsignedVarLong(); | ||
} | ||
|
||
protected function encodePayload(PacketSerializer $out) : void{ | ||
$out->putActorRuntimeId($this->actorRuntimeId); | ||
$out->putUnsignedVarInt($this->effectType->value); | ||
$out->putUnsignedVarInt($this->duration); | ||
$out->putUnsignedVarLong($this->tick); | ||
} | ||
|
||
public function handle(PacketHandlerInterface $handler) : bool{ | ||
return $handler->handleMovementEffect($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.