mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Inline EntityDataHelper::createBaseNBT()
this is only used for saving entity data now, and its presence here is allowing plugin devs to keep abusing it.
This commit is contained in:
parent
745f455bd2
commit
11b483f2dc
@ -40,6 +40,9 @@ use pocketmine\math\Facing;
|
||||
use pocketmine\math\Vector2;
|
||||
use pocketmine\math\Vector3;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\nbt\tag\DoubleTag;
|
||||
use pocketmine\nbt\tag\FloatTag;
|
||||
use pocketmine\nbt\tag\ListTag;
|
||||
use pocketmine\nbt\tag\StringTag;
|
||||
use pocketmine\network\mcpe\protocol\AddActorPacket;
|
||||
use pocketmine\network\mcpe\protocol\MoveActorAbsolutePacket;
|
||||
@ -459,7 +462,21 @@ abstract class Entity{
|
||||
}
|
||||
|
||||
public function saveNBT() : CompoundTag{
|
||||
$nbt = EntityDataHelper::createBaseNBT($this->location, $this->motion, $this->location->yaw, $this->location->pitch);
|
||||
$nbt = CompoundTag::create()
|
||||
->setTag("Pos", new ListTag([
|
||||
new DoubleTag($this->location->x),
|
||||
new DoubleTag($this->location->y),
|
||||
new DoubleTag($this->location->z)
|
||||
]))
|
||||
->setTag("Motion", new ListTag([
|
||||
new DoubleTag($this->motion->x),
|
||||
new DoubleTag($this->motion->y),
|
||||
new DoubleTag($this->motion->z)
|
||||
]))
|
||||
->setTag("Rotation", new ListTag([
|
||||
new FloatTag($this->location->yaw),
|
||||
new FloatTag($this->location->pitch)
|
||||
]));
|
||||
|
||||
if(!($this instanceof Player)){
|
||||
EntityFactory::getInstance()->injectSaveId(get_class($this), $nbt);
|
||||
|
@ -69,25 +69,4 @@ final class EntityDataHelper{
|
||||
}
|
||||
return new Vector3($values[0]->getValue(), $values[1]->getValue(), $values[2]->getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function which creates minimal NBT needed to spawn an entity.
|
||||
*/
|
||||
public static function createBaseNBT(Vector3 $pos, ?Vector3 $motion = null, float $yaw = 0.0, float $pitch = 0.0) : CompoundTag{
|
||||
return CompoundTag::create()
|
||||
->setTag("Pos", new ListTag([
|
||||
new DoubleTag($pos->x),
|
||||
new DoubleTag($pos->y),
|
||||
new DoubleTag($pos->z)
|
||||
]))
|
||||
->setTag("Motion", new ListTag([
|
||||
new DoubleTag($motion !== null ? $motion->x : 0.0),
|
||||
new DoubleTag($motion !== null ? $motion->y : 0.0),
|
||||
new DoubleTag($motion !== null ? $motion->z : 0.0)
|
||||
]))
|
||||
->setTag("Rotation", new ListTag([
|
||||
new FloatTag($yaw),
|
||||
new FloatTag($pitch)
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user