mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-04-21 16:24:05 +00:00
Allow input of relative coordinates to setworldspawn command (#4575)
This commit is contained in:
parent
f2d5455c5e
commit
4cad552909
@ -31,6 +31,7 @@ use pocketmine\math\Vector3;
|
||||
use pocketmine\permission\DefaultPermissionNames;
|
||||
use pocketmine\player\Player;
|
||||
use pocketmine\utils\TextFormat;
|
||||
use pocketmine\world\World;
|
||||
use function count;
|
||||
|
||||
class SetWorldSpawnCommand extends VanillaCommand{
|
||||
@ -60,8 +61,18 @@ class SetWorldSpawnCommand extends VanillaCommand{
|
||||
return true;
|
||||
}
|
||||
}elseif(count($args) === 3){
|
||||
$world = $sender->getServer()->getWorldManager()->getDefaultWorld();
|
||||
$pos = new Vector3($this->getInteger($sender, $args[0]), $this->getInteger($sender, $args[1]), $this->getInteger($sender, $args[2]));
|
||||
if($sender instanceof Player){
|
||||
$base = $sender->getPosition();
|
||||
$world = $base->getWorld();
|
||||
}else{
|
||||
$base = new Vector3(0.0, 0.0, 0.0);
|
||||
$world = $sender->getServer()->getWorldManager()->getDefaultWorld();
|
||||
}
|
||||
$pos = (new Vector3(
|
||||
$this->getRelativeDouble($base->x, $sender, $args[0]),
|
||||
$this->getRelativeDouble($base->y, $sender, $args[1], World::Y_MIN, World::Y_MAX),
|
||||
$this->getRelativeDouble($base->z, $sender, $args[2]),
|
||||
))->floor();
|
||||
}else{
|
||||
throw new InvalidCommandSyntaxException();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user