This commit is contained in:
Ad5001 2017-02-04 16:18:43 +01:00
parent 032775f0a8
commit ee50d504ff
5 changed files with 76 additions and 12 deletions

20
README.md Normal file
View file

@ -0,0 +1,20 @@
# FastTravel
Travel in MCPE faster and easier than you ever tought !
Discover brand new way of traveling that this plugin brings:
- Elevators
- BoostBlocks
- FlyBlocks
### Elevators
Elevators are blocks that allows you to change floors by sneaking to go down / jumping to go up.
Create a floor by adding an elevator block (defined in the config, noteblock by default) and then create some another ones by adding an other elevator block at different height.
ProTip: Try making squares of 2x2 to make sure the user get tp when sneaking/jumping.
### BoostBlocks
BoostBlocks are blocks that allows you to go super fast for 2 seconds after steping on them.
Just place one (defined in the config, ice by default) on the ground and step on it to see how fast can you go and regulate the amplifier in the config (10 by default).
### FlyBlocks (aka JumpBlocks)
FlyBlocks throws you in the air which allows you a great start for your elytras or to jump to high platforms.
Place one (defined in the config, hay bale by default) on the ground and step on it to see how high can you go and regulate the amplifier in the config (2 by default).

BIN
releases/FastTravel_v1.phar Normal file

Binary file not shown.

View file

@ -11,8 +11,20 @@
# Website: http://github.com/Ad5001/FastTravel
#
# Put here the block you want to be an elevetor.
# Put here the block you want to have as an elevetor.
ElevatorBlock: note_block
SpeedBlock: ice
# Put here the block you want to have as a booster block
BoostBlock: ice
# Put here how much do you want the amplifier of the speed of the boost to be.
BoostAmplifier: 10
# Put here the block you want to have as a jump to sky block.
JumpBlock: hay_bale
# Put here the amplifier of the jump when steping on the block set above.
JumpAmplifier: 2
...

View file

@ -27,6 +27,8 @@ use pocketmine\plugin\PluginBase;
use pocketmine\Server;
use pocketmine\entity\Entity;
use pocketmine\Player;
@ -45,7 +47,8 @@ class Main extends PluginBase implements Listener {
protected $elevator;
protected $speed;
protected $boost;
protected $jump;
public $cancelUpAfterDown = [];
@ -60,11 +63,16 @@ class Main extends PluginBase implements Listener {
$this->getLogger()->warning("Invalid block provided as elevator.");
$this->elevator = Item::get(139);
}
$this->speed = Item::fromString($this->getConfig()->get("SpeedBlock"));
$this->boost = Item::fromString($this->getConfig()->get("BoostBlock"));
if(!($this->elevator instanceof ItemBlock)) {
$this->getLogger()->warning("Invalid block provided as speed block.");
$this->getLogger()->warning("Invalid block provided as boost block.");
$this->elevator = Item::get(79);
}
$this->jump = Item::fromString($this->getConfig()->get("JumpBlock"));
if(!($this->elevator instanceof ItemBlock)) {
$this->getLogger()->warning("Invalid block provided as jump block.");
$this->elevator = Item::get(170);
}
$this->getServer()->getScheduler()->scheduleRepeatingTask(new tasks\FastingTask($this), 5);
}
@ -93,7 +101,6 @@ class Main extends PluginBase implements Listener {
}
}
if(!is_null($bl)) { // A elevator under exists
// $this->getLogger()->debug("Down " . $bl->y);
$event->getPlayer()->teleport(new \pocketmine\math\Vector3($bl->x, $bl->y + 1.5, $bl->z));
$this->setCooldown($event->getPlayer());
$event->getPlayer()->getLevel()->addSound(new \pocketmine\level\sound\EndermanTeleportSound($event->getPlayer()));
@ -109,7 +116,7 @@ class Main extends PluginBase implements Listener {
public function onPlayerMove(PlayerMoveEvent $event) {
$b = $event->getPlayer()->getLevel()->getBlock(new \pocketmine\math\Vector3(round($event->getFrom()->x), floor($event->getFrom()->y - 1), round($event->getFrom()->z)));
if($b->getId() == $this->elevator->getId() && $b->getDamage() == $this->elevator->getDamage() && $event->getTo()->y > $event->getFrom()->y) { // Checking if the player is sneaking on the block set as elevator.
$this->getLogger()->debug($event->getFrom() . "/" . $event->getTo());
// $this->getLogger()->debug($event->getFrom() . "/" . $event->getTo());
$bl = $this->getBlockAbove($b);
if(!is_null($bl) && !$this->hasFreeSpace($bl)) {
while(!is_null($bl) && !$this->hasFreeSpace($bl)) {
@ -183,16 +190,25 @@ class Main extends PluginBase implements Listener {
@return \pocketmine\block\Block
*/
public function getElevatorBlock() : \pocketmine\block\Block {
return clone $this->elevator;
return clone $this->elevator->getBlock();
}
/*
Return a clone of the speeding block
Return a clone of the boosting block
@return \pocketmine\block\Block
*/
public function getSpeedBlock() : \pocketmine\block\Block {
return clone $this->speed;
public function getBoostBlock() : \pocketmine\block\Block {
return clone $this->boost->getBlock();
}
/*
Return a clone of the jumpig block block
@return \pocketmine\block\Block
*/
public function getJumpBlock() : \pocketmine\block\Block {
return clone $this->jump->getBlock();
}

View file

@ -37,6 +37,7 @@ class FastingTask extends PluginTask {
parent::__construct($main);
$this->main = $main;
$this->server = $main->getServer();
$this->boostPlayers = [];
}
@ -45,7 +46,22 @@ class FastingTask extends PluginTask {
public function onRun($tick) {
foreach($this->server->getOnlinePlayers() as $p) {
$r = $p->round();
$r->y = $p->getFloorY() - 1;
if($p->getLevel()->getBlock($r)->getId() == $this->main->getBoostBlock()->getId() && $p->getLevel()->getBlock($r)->getDamage() == $this->main->getBoostBlock()->getDamage()) {
$attr = $p->getAttributeMap()->getAttribute(\pocketmine\entity\Attribute::MOVEMENT_SPEED);
$attr->setValue(0.11 * $this->main->getConfig()->get("BoostAmplifier"));
$this->boostPlayers[$p->getName()] = 8; // 2 seconds.
} elseif(isset($this->boostPlayers[$p->getName()])) {
$this->boostPlayers[$p->getName()]--;
if($this->boostPlayers[$p->getName()] <= 0) {
$attr = $p->getAttributeMap()->getAttribute(\pocketmine\entity\Attribute::MOVEMENT_SPEED);
$attr->setValue(0.11);
}
}
if($p->getLevel()->getBlock($r)->getId() == $this->main->getJumpBlock()->getId() && $p->getLevel()->getBlock($r)->getDamage() == $this->main->getJumpBlock()->getDamage()) {
$p->setMotion(new \pocketmine\math\Vector3($p->getMotion()->x, $this->main->getConfig()->get("JumpAmplifier"), $p->getMotion()->x));
}
}
}