mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-13 17:29:44 +00:00
BossEventPacket
lots of stuff doesn't work (not implemented in MCPE, bug, or are we doing something wrong???)
This commit is contained in:
parent
11169b0777
commit
69f64dd802
@ -115,6 +115,7 @@ use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
@ -3303,6 +3304,10 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
|
||||
return false;
|
||||
}
|
||||
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool{
|
||||
return false; //TODO
|
||||
}
|
||||
|
||||
public function handleShowCredits(ShowCreditsPacket $packet) : bool{
|
||||
return false; //TODO: handle resume
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ use pocketmine\network\mcpe\protocol\BatchPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
@ -289,6 +290,7 @@ class Network{
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_ENTITY_DATA_PACKET, BlockEntityDataPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_EVENT_PACKET, BlockEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BLOCK_PICK_REQUEST_PACKET, BlockPickRequestPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::BOSS_EVENT_PACKET, BossEventPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHANGE_DIMENSION_PACKET, ChangeDimensionPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CHUNK_RADIUS_UPDATED_PACKET, ChunkRadiusUpdatedPacket::class);
|
||||
$this->registerPacket(ProtocolInfo::CLIENTBOUND_MAP_ITEM_DATA_PACKET, ClientboundMapItemDataPacket::class);
|
||||
|
@ -35,6 +35,7 @@ use pocketmine\network\mcpe\protocol\AvailableCommandsPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEntityDataPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\BlockPickRequestPacket;
|
||||
use pocketmine\network\mcpe\protocol\BossEventPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChangeDimensionPacket;
|
||||
use pocketmine\network\mcpe\protocol\ChunkRadiusUpdatedPacket;
|
||||
use pocketmine\network\mcpe\protocol\ClientboundMapItemDataPacket;
|
||||
@ -266,7 +267,7 @@ interface NetworkSession{
|
||||
|
||||
public function handleAddItem(AddItemPacket $packet) : bool;
|
||||
|
||||
//public function handleBossEvent(BossEventPacket $packet) : bool;
|
||||
public function handleBossEvent(BossEventPacket $packet) : bool;
|
||||
|
||||
public function handleShowCredits(ShowCreditsPacket $packet) : bool;
|
||||
|
||||
|
125
src/pocketmine/network/mcpe/protocol/BossEventPacket.php
Normal file
125
src/pocketmine/network/mcpe/protocol/BossEventPacket.php
Normal file
@ -0,0 +1,125 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
*
|
||||
* ____ _ _ __ __ _ __ __ ____
|
||||
* | _ \ ___ ___| | _____| |_| \/ (_)_ __ ___ | \/ | _ \
|
||||
* | |_) / _ \ / __| |/ / _ \ __| |\/| | | '_ \ / _ \_____| |\/| | |_) |
|
||||
* | __/ (_) | (__| < __/ |_| | | | | | | | __/_____| | | | __/
|
||||
* |_| \___/ \___|_|\_\___|\__|_| |_|_|_| |_|\___| |_| |_|_|
|
||||
*
|
||||
* This program 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.
|
||||
*
|
||||
* @author PocketMine Team
|
||||
* @link http://www.pocketmine.net/
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
namespace pocketmine\network\mcpe\protocol;
|
||||
|
||||
#include <rules/DataPacket.h>
|
||||
|
||||
|
||||
use pocketmine\network\mcpe\NetworkSession;
|
||||
|
||||
class BossEventPacket extends DataPacket{
|
||||
const NETWORK_ID = ProtocolInfo::BOSS_EVENT_PACKET;
|
||||
|
||||
/* S2C: Shows the boss-bar to the player. */
|
||||
const TYPE_SHOW = 0;
|
||||
/* C2S: Registers a player to a boss fight. */
|
||||
const TYPE_REGISTER_PLAYER = 1;
|
||||
/* S2C: Removes the boss-bar from the client. */
|
||||
const TYPE_HIDE = 2;
|
||||
/* C2S: Unregisters a player from a boss fight. */
|
||||
const TYPE_UNREGISTER_PLAYER = 3;
|
||||
/* S2C: Appears not to be implemented. Currently bar percentage only appears to change in response to the target entity's health. */
|
||||
const TYPE_HEALTH_PERCENT = 4;
|
||||
/* S2C: Also appears to not be implemented. Title client-side sticks as the target entity's nametag, or their entity type name if not set. */
|
||||
const TYPE_TITLE = 5;
|
||||
/* S2C: Not sure on this. Includes color and overlay fields, plus an unknown short. TODO: check this */
|
||||
const TYPE_UNKNOWN_6 = 6;
|
||||
/* S2C: Not implemented :( Intended to alter bar appearance, but these currently produce no effect on client-side whatsoever. */
|
||||
const TYPE_TEXTURE = 7;
|
||||
|
||||
public $bossEid;
|
||||
public $eventType;
|
||||
|
||||
/** @var int (long) */
|
||||
public $playerEid;
|
||||
/** @var float */
|
||||
public $healthPercent;
|
||||
/** @var string */
|
||||
public $title;
|
||||
/** @var int */
|
||||
public $unknownShort;
|
||||
/** @var int */
|
||||
public $color;
|
||||
/** @var int */
|
||||
public $overlay;
|
||||
|
||||
public function decode(){
|
||||
$this->bossEid = $this->getEntityUniqueId();
|
||||
$this->eventType = $this->getUnsignedVarInt();
|
||||
switch($this->eventType){
|
||||
case self::TYPE_REGISTER_PLAYER:
|
||||
case self::TYPE_UNREGISTER_PLAYER:
|
||||
$this->playerEid = $this->getEntityUniqueId();
|
||||
break;
|
||||
case self::TYPE_SHOW:
|
||||
$this->title = $this->getString();
|
||||
$this->healthPercent = $this->getLFloat();
|
||||
case self::TYPE_UNKNOWN_6:
|
||||
$this->unknownShort = $this->getLShort();
|
||||
case self::TYPE_TEXTURE:
|
||||
$this->color = $this->getUnsignedVarInt();
|
||||
$this->overlay = $this->getUnsignedVarInt();
|
||||
break;
|
||||
case self::TYPE_HEALTH_PERCENT:
|
||||
$this->healthPercent = $this->getLFloat();
|
||||
break;
|
||||
case self::TYPE_TITLE:
|
||||
$this->title = $this->getString();
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function encode(){
|
||||
$this->reset();
|
||||
$this->putEntityUniqueId($this->bossEid);
|
||||
$this->putUnsignedVarInt($this->eventType);
|
||||
switch($this->eventType){
|
||||
case self::TYPE_REGISTER_PLAYER:
|
||||
case self::TYPE_UNREGISTER_PLAYER:
|
||||
$this->putEntityUniqueId($this->playerEid);
|
||||
break;
|
||||
case self::TYPE_SHOW:
|
||||
$this->putString($this->title);
|
||||
$this->putLFloat($this->healthPercent);
|
||||
case self::TYPE_UNKNOWN_6:
|
||||
$this->putLShort($this->unknownShort);
|
||||
case self::TYPE_TEXTURE:
|
||||
$this->putUnsignedVarInt($this->color);
|
||||
$this->putUnsignedVarInt($this->overlay);
|
||||
break;
|
||||
case self::TYPE_HEALTH_PERCENT:
|
||||
$this->putLFloat($this->healthPercent);
|
||||
break;
|
||||
case self::TYPE_TITLE:
|
||||
$this->putString($this->title);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public function handle(NetworkSession $session) : bool{
|
||||
return $session->handleBossEvent($this);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user