Skip to content

Commit

Permalink
Bow: Improve consistency with vanilla (JE at least), closes #2660
Browse files Browse the repository at this point in the history
This change causes the existing test I did to now report ~55-60 blocks, which is much closer to parity with vanilla.
  • Loading branch information
dktapps committed Jan 15, 2019
1 parent 1c2ed08 commit 0f545c4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/pocketmine/item/Bow.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ public function onReleaseUsing(Player $player) : bool{

$diff = $player->getItemUseDuration();
$p = $diff / 20;
$force = min((($p ** 2) + $p * 2) / 3, 1) * 2;
$baseForce = min((($p ** 2) + $p * 2) / 3, 1);


$entity = Entity::createEntity("Arrow", $player->getLevel(), $nbt, $player, $force == 2);
$entity = Entity::createEntity("Arrow", $player->getLevel(), $nbt, $player, $baseForce >= 1);
if($entity instanceof Projectile){
$infinity = $this->hasEnchantment(Enchantment::INFINITY);
if($entity instanceof ArrowEntity){
Expand All @@ -83,9 +83,9 @@ public function onReleaseUsing(Player $player) : bool{
if($this->hasEnchantment(Enchantment::FLAME)){
$entity->setOnFire(intdiv($entity->getFireTicks(), 20) + 100);
}
$ev = new EntityShootBowEvent($player, $this, $entity, $force);
$ev = new EntityShootBowEvent($player, $this, $entity, $baseForce * 3);

if($force < 0.1 or $diff < 5){
if($baseForce < 0.1 or $diff < 5){
$ev->setCancelled();
}

Expand Down

0 comments on commit 0f545c4

Please # to comment.