mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-14 01:39:52 +00:00
Entity: some cleanup of network position hacks
This commit is contained in:
parent
1f0ea0c2c7
commit
87ce92d87e
@ -128,9 +128,6 @@ abstract class Entity{
|
|||||||
/** @var float */
|
/** @var float */
|
||||||
public $width;
|
public $width;
|
||||||
|
|
||||||
/** @var float */
|
|
||||||
protected $baseOffset = 0.0;
|
|
||||||
|
|
||||||
/** @var float */
|
/** @var float */
|
||||||
private $health = 20.0;
|
private $health = 20.0;
|
||||||
/** @var int */
|
/** @var int */
|
||||||
@ -724,7 +721,7 @@ abstract class Entity{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
||||||
return new Vector3($vector3->x, $vector3->y + $this->baseOffset, $vector3->z);
|
return $vector3;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function broadcastMovement(bool $teleport = false) : void{
|
protected function broadcastMovement(bool $teleport = false) : void{
|
||||||
|
@ -37,6 +37,7 @@ use pocketmine\item\enchantment\Enchantment;
|
|||||||
use pocketmine\item\FoodSource;
|
use pocketmine\item\FoodSource;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
use pocketmine\item\Totem;
|
use pocketmine\item\Totem;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\NBT;
|
use pocketmine\nbt\NBT;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\IntTag;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
@ -90,8 +91,6 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
protected $xpSeed;
|
protected $xpSeed;
|
||||||
|
|
||||||
protected $baseOffset = 1.62;
|
|
||||||
|
|
||||||
public function __construct(Location $location, Skin $skin, ?CompoundTag $nbt = null){
|
public function __construct(Location $location, Skin $skin, ?CompoundTag $nbt = null){
|
||||||
$this->skin = $skin;
|
$this->skin = $skin;
|
||||||
parent::__construct($location, $nbt);
|
parent::__construct($location, $nbt);
|
||||||
@ -414,6 +413,10 @@ class Human extends Living implements ProjectileSource, InventoryHolder{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
||||||
|
return $vector3->add(0, 1.621, 0); //TODO: +0.001 hack for MCPE falling underground
|
||||||
|
}
|
||||||
|
|
||||||
public function broadcastMovement(bool $teleport = false) : void{
|
public function broadcastMovement(bool $teleport = false) : void{
|
||||||
//TODO: workaround 1.14.30 bug: MoveActor(Absolute|Delta)Packet don't work on players anymore :(
|
//TODO: workaround 1.14.30 bug: MoveActor(Absolute|Delta)Packet don't work on players anymore :(
|
||||||
$pk = new MovePlayerPacket();
|
$pk = new MovePlayerPacket();
|
||||||
|
@ -30,6 +30,7 @@ use pocketmine\entity\Entity;
|
|||||||
use pocketmine\entity\Location;
|
use pocketmine\entity\Location;
|
||||||
use pocketmine\event\entity\EntityBlockChangeEvent;
|
use pocketmine\event\entity\EntityBlockChangeEvent;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\tag\ByteTag;
|
use pocketmine\nbt\tag\ByteTag;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\nbt\tag\IntTag;
|
use pocketmine\nbt\tag\IntTag;
|
||||||
@ -45,8 +46,6 @@ class FallingBlock extends Entity{
|
|||||||
public $width = 0.98;
|
public $width = 0.98;
|
||||||
public $height = 0.98;
|
public $height = 0.98;
|
||||||
|
|
||||||
protected $baseOffset = 0.49;
|
|
||||||
|
|
||||||
protected $gravity = 0.04;
|
protected $gravity = 0.04;
|
||||||
protected $drag = 0.02;
|
protected $drag = 0.02;
|
||||||
|
|
||||||
@ -149,4 +148,8 @@ class FallingBlock extends Entity{
|
|||||||
|
|
||||||
$properties->setInt(EntityMetadataProperties::VARIANT, $this->block->getRuntimeId());
|
$properties->setInt(EntityMetadataProperties::VARIANT, $this->block->getRuntimeId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
||||||
|
return $vector3->add(0, 0.49, 0); //TODO: check if height affects this
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ use pocketmine\event\entity\ItemDespawnEvent;
|
|||||||
use pocketmine\event\entity\ItemSpawnEvent;
|
use pocketmine\event\entity\ItemSpawnEvent;
|
||||||
use pocketmine\event\inventory\InventoryPickupItemEvent;
|
use pocketmine\event\inventory\InventoryPickupItemEvent;
|
||||||
use pocketmine\item\Item;
|
use pocketmine\item\Item;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\network\mcpe\convert\TypeConverter;
|
use pocketmine\network\mcpe\convert\TypeConverter;
|
||||||
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
|
use pocketmine\network\mcpe\protocol\AddItemActorPacket;
|
||||||
@ -55,7 +56,6 @@ class ItemEntity extends Entity{
|
|||||||
|
|
||||||
public $width = 0.25;
|
public $width = 0.25;
|
||||||
public $height = 0.25;
|
public $height = 0.25;
|
||||||
protected $baseOffset = 0.125;
|
|
||||||
|
|
||||||
protected $gravity = 0.04;
|
protected $gravity = 0.04;
|
||||||
protected $drag = 0.02;
|
protected $drag = 0.02;
|
||||||
@ -215,6 +215,10 @@ class ItemEntity extends Entity{
|
|||||||
$player->getNetworkSession()->sendDataPacket($pk);
|
$player->getNetworkSession()->sendDataPacket($pk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
||||||
|
return $vector3->add(0, 0.125, 0);
|
||||||
|
}
|
||||||
|
|
||||||
public function onCollideWithPlayer(Player $player) : void{
|
public function onCollideWithPlayer(Player $player) : void{
|
||||||
if($this->getPickupDelay() !== 0){
|
if($this->getPickupDelay() !== 0){
|
||||||
return;
|
return;
|
||||||
|
@ -27,6 +27,7 @@ use pocketmine\entity\Entity;
|
|||||||
use pocketmine\entity\Explosive;
|
use pocketmine\entity\Explosive;
|
||||||
use pocketmine\event\entity\EntityDamageEvent;
|
use pocketmine\event\entity\EntityDamageEvent;
|
||||||
use pocketmine\event\entity\ExplosionPrimeEvent;
|
use pocketmine\event\entity\ExplosionPrimeEvent;
|
||||||
|
use pocketmine\math\Vector3;
|
||||||
use pocketmine\nbt\tag\CompoundTag;
|
use pocketmine\nbt\tag\CompoundTag;
|
||||||
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
|
use pocketmine\network\mcpe\protocol\types\entity\EntityIds;
|
||||||
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection;
|
use pocketmine\network\mcpe\protocol\types\entity\EntityMetadataCollection;
|
||||||
@ -43,8 +44,6 @@ class PrimedTNT extends Entity implements Explosive{
|
|||||||
public $width = 0.98;
|
public $width = 0.98;
|
||||||
public $height = 0.98;
|
public $height = 0.98;
|
||||||
|
|
||||||
protected $baseOffset = 0.49;
|
|
||||||
|
|
||||||
protected $gravity = 0.04;
|
protected $gravity = 0.04;
|
||||||
protected $drag = 0.02;
|
protected $drag = 0.02;
|
||||||
|
|
||||||
@ -126,4 +125,8 @@ class PrimedTNT extends Entity implements Explosive{
|
|||||||
$properties->setGenericFlag(EntityMetadataFlags::IGNITED, true);
|
$properties->setGenericFlag(EntityMetadataFlags::IGNITED, true);
|
||||||
$properties->setInt(EntityMetadataProperties::FUSE_LENGTH, $this->fuse);
|
$properties->setInt(EntityMetadataProperties::FUSE_LENGTH, $this->fuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
||||||
|
return $vector3->add(0, 0.49, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -2219,12 +2219,6 @@ class Player extends Human implements CommandSender, ChunkLoader, ChunkListener,
|
|||||||
parent::broadcastAnimation($animation, $targets);
|
parent::broadcastAnimation($animation, $targets);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getOffsetPosition(Vector3 $vector3) : Vector3{
|
|
||||||
$result = parent::getOffsetPosition($vector3);
|
|
||||||
$result->y += 0.001; //Hack for MCPE falling underground for no good reason (TODO: find out why it's doing this)
|
|
||||||
return $result;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO: remove this
|
* TODO: remove this
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user