From f16c7f1591c0c166af4d18d887326afcbd437ed4 Mon Sep 17 00:00:00 2001 From: EmreTr1 Date: Tue, 30 Jul 2019 17:02:06 +0300 Subject: [PATCH 1/2] some fixes --- .../behavior/NearestAttackableTargetBehavior.php | 3 ++- src/pocketmine/entity/hostile/Slime.php | 6 +++--- src/pocketmine/entity/passive/Wolf.php | 1 - .../network/mcpe/PlayerNetworkSessionAdapter.php | 10 ++++++---- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/pocketmine/entity/behavior/NearestAttackableTargetBehavior.php b/src/pocketmine/entity/behavior/NearestAttackableTargetBehavior.php index cb2d67d63db..bf19617a9f4 100644 --- a/src/pocketmine/entity/behavior/NearestAttackableTargetBehavior.php +++ b/src/pocketmine/entity/behavior/NearestAttackableTargetBehavior.php @@ -25,6 +25,7 @@ namespace pocketmine\entity\behavior; use pocketmine\entity\Entity; +use pocketmine\entity\Living; use pocketmine\entity\Mob; use pocketmine\Player; @@ -71,7 +72,7 @@ public function __construct(Mob $mob, string $classTarget, bool $checkSight, int } } - return $this->isSuitableTargetLocal($entity, false); + return $entity instanceof Living and $this->isSuitableTargetLocal($entity, false); } }; } diff --git a/src/pocketmine/entity/hostile/Slime.php b/src/pocketmine/entity/hostile/Slime.php index 68436cb1f73..0bedabebcad 100644 --- a/src/pocketmine/entity/hostile/Slime.php +++ b/src/pocketmine/entity/hostile/Slime.php @@ -53,9 +53,9 @@ class Slime extends Monster{ public $height = 0; public $width = 0; - public $squishAmount; - public $squishFactor; - public $prevSquishFactor; + public $squishAmount = 0; + public $squishFactor = 0; + public $prevSquishFactor = 0; /** @var EntitySlimeMoveHelper */ protected $moveHelper; diff --git a/src/pocketmine/entity/passive/Wolf.php b/src/pocketmine/entity/passive/Wolf.php index cdeffb8acbd..f790a264ea4 100644 --- a/src/pocketmine/entity/passive/Wolf.php +++ b/src/pocketmine/entity/passive/Wolf.php @@ -24,7 +24,6 @@ namespace pocketmine\entity\passive; -use pocketmine\entity\behavior\FindAttackableTargetBehavior; use pocketmine\entity\behavior\FloatBehavior; use pocketmine\entity\behavior\FollowOwnerBehavior; use pocketmine\entity\behavior\HurtByTargetBehavior; diff --git a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php index c9fd80cffb9..8bbf0f00fc3 100644 --- a/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php +++ b/src/pocketmine/network/mcpe/PlayerNetworkSessionAdapter.php @@ -54,6 +54,7 @@ use pocketmine\network\mcpe\protocol\MobArmorEquipmentPacket; use pocketmine\network\mcpe\protocol\MobEquipmentPacket; use pocketmine\network\mcpe\protocol\ModalFormResponsePacket; +use pocketmine\network\mcpe\protocol\MoveActorAbsolutePacket; use pocketmine\network\mcpe\protocol\MovePlayerPacket; use pocketmine\network\mcpe\protocol\NetworkStackLatencyPacket; use pocketmine\network\mcpe\protocol\PlayerActionPacket; @@ -65,6 +66,7 @@ use pocketmine\network\mcpe\protocol\ResourcePackClientResponsePacket; use pocketmine\network\mcpe\protocol\RiderJumpPacket; use pocketmine\network\mcpe\protocol\ServerSettingsRequestPacket; +use pocketmine\network\mcpe\protocol\SetActorMotionPacket; use pocketmine\network\mcpe\protocol\SetLocalPlayerAsInitializedPacket; use pocketmine\network\mcpe\protocol\SetPlayerGameTypePacket; use pocketmine\network\mcpe\protocol\ShowCreditsPacket; @@ -339,11 +341,11 @@ public function handleLevelSoundEvent(LevelSoundEventPacket $packet) : bool{ return $this->player->handleLevelSoundEvent($packet); } - public function handleMoveEntityAbsolute(MoveEntityAbsolutePacket $packet) : bool{ + public function handleMoveActorAbsolute(MoveActorAbsolutePacket $packet) : bool{ $target = $this->player->getServer()->findEntity($packet->entityRuntimeId); if($target !== null){ - $target->setClientPositionAndRotation($packet->position, $packet->yRot, $packet->xRot, 3, ($packet->flags & MoveEntityAbsolutePacket::FLAG_TELEPORT) !== 0); - $target->onGround = ($packet->flags & MoveEntityAbsolutePacket::FLAG_GROUND) !== 0; + $target->setClientPositionAndRotation($packet->position, $packet->yRot, $packet->xRot, 3, ($packet->flags & MoveActorAbsolutePacket::FLAG_TELEPORT) !== 0); + $target->onGround = ($packet->flags & MoveActorAbsolutePacket::FLAG_GROUND) !== 0; return true; } @@ -351,7 +353,7 @@ public function handleMoveEntityAbsolute(MoveEntityAbsolutePacket $packet) : boo return false; } - public function handleSetEntityMotion(SetEntityMotionPacket $packet) : bool{ + public function handleSetActorMotion(SetActorMotionPacket $packet) : bool{ $target = $this->player->getServer()->findEntity($packet->entityRuntimeId); if($target !== null){ $target->setClientMotion($packet->motion); From 3d99024cb824b79a610f1796436988efe9d0fee3 Mon Sep 17 00:00:00 2001 From: EmreTr1 Date: Tue, 30 Jul 2019 17:03:02 +0300 Subject: [PATCH 2/2] Fixed skeleton bug Close #157 --- src/pocketmine/entity/pathfinder/EntityNavigator.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/pocketmine/entity/pathfinder/EntityNavigator.php b/src/pocketmine/entity/pathfinder/EntityNavigator.php index 8718dc062e6..fd434b35928 100644 --- a/src/pocketmine/entity/pathfinder/EntityNavigator.php +++ b/src/pocketmine/entity/pathfinder/EntityNavigator.php @@ -423,6 +423,10 @@ public function isBlocked(Vector3 $coord) : bool{ */ public function removeSunnyPath() : void{ if($this->avoidsSun and $this->mob->level->isDayTime()){ + if($this->mob->level->canSeeSky($this->mob)){ + return; + } + $temp = new Vector3(); foreach($this->currentPath->getPoints() as $i => $point){ if($this->mob->level->canSeeSky($temp->setComponents($point->x, $point->height, $point->y))){