mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-09-06 17:59:48 +00:00
Extract mandatory parameters into constructor parameters
the goal is obviously to ditch NBT entirely here, but there's more work to be done before that becomes possible.
This commit is contained in:
@ -23,12 +23,13 @@ declare(strict_types=1);
|
||||
|
||||
namespace pocketmine\item;
|
||||
|
||||
use pocketmine\entity\EntityFactory;
|
||||
use pocketmine\entity\Location;
|
||||
use pocketmine\entity\projectile\Arrow as ArrowEntity;
|
||||
use pocketmine\entity\projectile\Projectile;
|
||||
use pocketmine\event\entity\EntityShootBowEvent;
|
||||
use pocketmine\event\entity\ProjectileLaunchEvent;
|
||||
use pocketmine\item\enchantment\Enchantment;
|
||||
use pocketmine\nbt\tag\CompoundTag;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\world\sound\BowShootSound;
|
||||
use function intdiv;
|
||||
@ -51,18 +52,18 @@ class Bow extends Tool{
|
||||
}
|
||||
|
||||
$location = $player->getLocation();
|
||||
$nbt = EntityFactory::createBaseNBT(
|
||||
$player->getEyePos(),
|
||||
$player->getDirectionVector(),
|
||||
($location->yaw > 180 ? 360 : 0) - $location->yaw,
|
||||
-$location->pitch
|
||||
);
|
||||
|
||||
$diff = $player->getItemUseDuration();
|
||||
$p = $diff / 20;
|
||||
$baseForce = min((($p ** 2) + $p * 2) / 3, 1);
|
||||
|
||||
$entity = new ArrowEntity($location->getWorldNonNull(), $nbt, $player, $baseForce >= 1);
|
||||
$entity = new ArrowEntity(Location::fromObject(
|
||||
$player->getEyePos(),
|
||||
$player->getWorld(),
|
||||
($location->yaw > 180 ? 360 : 0) - $location->yaw,
|
||||
-$location->pitch
|
||||
), $player, $baseForce >= 1, new CompoundTag());
|
||||
$entity->setMotion($player->getDirectionVector());
|
||||
|
||||
$infinity = $this->hasEnchantment(Enchantment::INFINITY());
|
||||
if($infinity){
|
||||
|
Reference in New Issue
Block a user