Commit 1c500159 authored by Realm's avatar Realm Committed by GitHub
Browse files

Merge pull request #816 from erkam2002/master

Fix Levitation effect
parents 6b1ef89c 0ec8cc98
......@@ -2034,6 +2034,9 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
}
if(!$this->isSpectator() and $this->speed !== null){
if($this->hasEffect(Effect::LEVITATION)){
$this->inAirTicks = 0;
}
if($this->onGround){
if($this->inAirTicks !== 0){
$this->startAirTicks = 5;
......@@ -2048,7 +2051,7 @@ class Player extends Human implements CommandSender, InventoryHolder, ChunkLoade
$expectedVelocity = (-$this->gravity) / $this->drag - ((-$this->gravity) / $this->drag) * exp(-$this->drag * ($this->inAirTicks - $this->startAirTicks));
$diff = ($this->speed->y - $expectedVelocity) ** 2;
if(!$this->hasEffect(Effect::JUMP) and !$this->hasEffect(Effect::LEVITATION) and $diff > 0.6 and $expectedVelocity < $this->speed->y and !$this->server->getAllowFlight()){
if(!$this->hasEffect(Effect::JUMP) and $diff > 0.6 and $expectedVelocity < $this->speed->y and !$this->server->getAllowFlight()){
if($this->inAirTicks < 1000){
$this->setMotion(new Vector3(0, $expectedVelocity, 0));
}elseif($this->kick("Flying is not enabled on this server")){
......
......@@ -92,7 +92,7 @@ class Effect {
self::$effects[Effect::ABSORPTION] = new Effect(Effect::ABSORPTION, "%potion.absorption", 36, 107, 251);
self::$effects[Effect::SATURATION] = new Effect(Effect::SATURATION, "%potion.saturation", 255, 0, 255);
self::$effects[Effect::LEVITATION] = new Effect(Effect::LEVITATION, "%potion.levitation", 206, 255, 255, true);
self::$effects[Effect::LEVITATION] = new Effect(Effect::LEVITATION, "%potion.levitation", 206, 255, 255);
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment