Improved Vector3 and Block handling, less allocation on Positions

This commit is contained in:
Shoghi Cervantes
2014-10-28 10:03:10 +01:00
parent 69492474e4
commit 144a871c07
18 changed files with 85 additions and 35 deletions

View File

@@ -70,14 +70,14 @@ class SpawnpointCommand extends VanillaCommand{
$x = (int) $this->getRelativeDouble($pos->x, $sender, $args[1]);
$y = $this->getRelativeDouble($pos->y, $sender, $args[2], 0, 128);
$z = $this->getRelativeDouble($pos->z, $sender, $args[3]);
$target->setSpawn(new Position($x, $y, $z, $level));
$target->setSpawn(Position::createPosition($x, $y, $z, $level));
Command::broadcastCommandMessage($sender, "Set " . $target->getDisplayName() . "'s spawnpoint to " . $x . ", " . $y . ", " . $z);
return true;
}
}elseif(count($args) <= 1){
if($sender instanceof Player){
$pos = new Position((int) $sender->x, (int) $sender->y, (int) $sender->z, $sender->getLevel());
$pos = Position::createPosition((int) $sender->x, (int) $sender->y, (int) $sender->z, $sender->getLevel());
$target->setSpawn($pos);
Command::broadcastCommandMessage($sender, "Set " . $target->getDisplayName() . "'s spawnpoint to " . $pos->x . ", " . $pos->y . ", " . $pos->z);

View File

@@ -88,7 +88,7 @@ class TeleportCommand extends VanillaCommand{
}
if(count($args) < 3){
$pos = new Position($target->x, $target->y, $target->z, $target->getLevel());
$pos = Position::clonePosition($target);
$origin->teleport($pos);
Command::broadcastCommandMessage($sender, "Teleported " . $origin->getDisplayName() . " to " . $target->getDisplayName());