fixed position reset if player got moved when switching gm or when dead

This commit is contained in:
GameHerobrine 2024-04-01 12:45:35 +03:00
parent 093efa0f2e
commit 4e67c96574

View file

@ -974,7 +974,7 @@ class Player{
return false; return false;
} }
$inv =& $this->inventory; $inv = &$this->inventory;
if($gm === VIEW){ if($gm === VIEW){
$this->armor = []; $this->armor = [];
$this->sendArmor(); $this->sendArmor();
@ -997,6 +997,7 @@ class Player{
foreach($this->inventory as $slot => $item){ foreach($this->inventory as $slot => $item){
$inv[$slot] = BlockAPI::getItem(AIR, 0, 0); $inv[$slot] = BlockAPI::getItem(AIR, 0, 0);
} }
$this->lastCorrect = $this->entity->copy();
$this->blocked = true; $this->blocked = true;
$this->gamemode = $gm; $this->gamemode = $gm;
$this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n"); $this->sendChat("Your gamemode has been changed to " . $this->getGamemode() . ", you've to do a forced reconnect.\n");
@ -1654,7 +1655,7 @@ class Player{
} }
if(($this->entity instanceof Entity)){ if(($this->entity instanceof Entity)){
if($this->blocked === true or $this->server->api->handle("player.move", $this->entity) === false){ if($this->blocked === true or $this->server->api->handle("player.move", $this->entity) === false){
if($this->lastCorrect instanceof Vector3){ if($this->lastCorrect instanceof Vector3 && !$this->entity->dead){
$this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
} }
}else{ }else{
@ -1680,7 +1681,7 @@ class Player{
} }
$speed = $this->entity->getSpeedMeasure(); $speed = $this->entity->getSpeedMeasure();
if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){ if($this->blocked === true or ($this->server->api->getProperty("allow-flight") !== true and (($speed > 9 and ($this->gamemode & 0x01) === 0x00) or $speed > 20 or $this->entity->distance($newPos) > 7)) or $this->server->api->handle("player.move", $this->entity) === false){
if($this->lastCorrect instanceof Vector3){ if($this->lastCorrect instanceof Vector3 && !$this->entity->dead){
$this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false); $this->teleport($this->lastCorrect, $this->entity->yaw, $this->entity->pitch, false);
} }
}else{ }else{