Skip to content

Commit

Permalink
PocketMine-MP v5.0.0 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Muqsit committed Jun 1, 2023
1 parent af6cc4e commit d6e6b63
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 18 deletions.
3 changes: 2 additions & 1 deletion .poggit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,6 @@ projects:
path: ""
libs:
- src: poggit/libasynql/libasynql
version: 4.1.6
branch: pm5
version: ^4.1.1
...
4 changes: 2 additions & 2 deletions plugin.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: FloatingText
main: cosmicpe\floatingtext\Loader
api: 4.0.0
version: 0.1.1
api: 5.0.0
version: 0.1.2
commands:
floatingtext:
aliases: [ft]
Expand Down
10 changes: 5 additions & 5 deletions src/cosmicpe/floatingtext/FloatingText.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
final class FloatingText{

public function __construct(
/** @readonly */ public string $world,
/** @readonly */ public float $x,
/** @readonly */ public float $y,
/** @readonly */ public float $z,
/** @readonly */ public string $line
readonly public string $world,
readonly public float $x,
readonly public float $y,
readonly public float $z,
readonly public string $line
){}
}
26 changes: 16 additions & 10 deletions src/cosmicpe/floatingtext/FloatingTextEntity.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use pocketmine\event\entity\EntityDamageEvent;
use pocketmine\math\Vector3;
use pocketmine\nbt\tag\CompoundTag;
use pocketmine\network\mcpe\convert\RuntimeBlockMapping;
use pocketmine\network\mcpe\convert\TypeConverter;
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection;
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataProperties;
Expand All @@ -24,13 +24,6 @@ public static function getNetworkTypeId() : string{
return EntityIds::FALLING_BLOCK;
}

public $gravity = 0.0;
public $canCollide = false;
public $keepMovement = true;
protected $gravityEnabled = false;
protected $drag = 0.0;
protected $immobile = true;

private int $floating_text_id;
private FloatingText $floating_text;

Expand All @@ -41,13 +34,18 @@ public function __construct(World $world, int $text_id, FloatingText $text){
$this->setCanSaveWithChunk(false);
$this->floating_text_id = $text_id;
$this->floating_text = $text;
$this->keepMovement = true;
$this->gravity = 0.0;
$this->gravityEnabled = false;
$this->drag = 0.0;
$this->noClientPredictions = true;
parent::__construct(new Location($text->x, $text->y, $text->z, $world, 0.0, 0.0));
}

protected function initEntity(CompoundTag $nbt) : void{
parent::initEntity($nbt);
$this->setNameTag($this->floating_text->line);
$this->setNameTagAlwaysVisible(true);
$this->setNameTagAlwaysVisible();
}

protected function getInitialSizeInfo() : EntitySizeInfo{
Expand All @@ -56,7 +54,7 @@ protected function getInitialSizeInfo() : EntitySizeInfo{

protected function syncNetworkData(EntityMetadataCollection $properties) : void{
parent::syncNetworkData($properties);
$properties->setInt(EntityMetadataProperties::VARIANT, RuntimeBlockMapping::getInstance()->toRuntimeId(VanillaBlocks::AIR()->getFullId()));
$properties->setInt(EntityMetadataProperties::VARIANT, TypeConverter::getInstance()->getBlockTranslator()->internalIdToNetworkId(VanillaBlocks::AIR()->getStateId()));
}

public function addDespawnCallback(Closure $callback) : void{
Expand Down Expand Up @@ -90,6 +88,14 @@ public function canBeMovedByCurrents() : bool{
return false;
}

protected function getInitialDragMultiplier() : float{
return 0.0;
}

protected function getInitialGravity() : float{
return 0.0;
}

public function getOffsetPosition(Vector3 $vector3) : Vector3{
return parent::getOffsetPosition($vector3)->add(0.0, 0.49, 0.0);
}
Expand Down

0 comments on commit d6e6b63

Please sign in to comment.