Advertisement
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Solved Sliding block

Comments in 'Plugin Development' started by Praxthisnovcht, Nov 1, 2015.

  1. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    hi guys, I wonder if it is possible for example.

    BlockHunt, when the player moves the block that slides on the ground instead of jumping from block to block?

    if it is possible how?


    [​IMG]

    Thank you
    Last edited by a moderator: Nov 1, 2015
  2. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    Use PlayerMoveEvent and setBlock() to wherever the player is and remove the previously set block. Idk how smooth this would look, it was just a quick idea.
  3. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    Could you give an example?
  4. Praxthisnovcht
    Offline

    Praxthisnovcht Notable Member Plugin Developer

    Joined:
    Mar 10, 2014
    Posts:
    699
    Plugins:
    4
    Minecraft User:
    PraxHellTag
    It would take an example to understand x (
  5. Hotshot_9930
    Offline

    Hotshot_9930 Notable Member Plugin Developer

    Joined:
    May 26, 2014
    Posts:
    665
    Plugins:
    2
    Minecraft User:
    HotshotHD
    This is what i had in mind:
    PHP:
    public function onEnable() {
        @
    mkdir($this->getDataFolder() . "Players/");
    }

    public function 
    getLastX($playerName) {
        
    $this->lastX = new Config($this->getDataFolder() . "Players/" strtolower($playerName) . ".yml"Config::YAML, array(
        
    "Last.X" => 0,
        ));
        return 
    $this->lastX->get("Last.X");
    }

    public function 
    getLastY($playerName) {
        
    $this->lastY = new Config($this->getDataFolder() . "Players/" strtolower($playerName) . ".yml"Config::YAML, array(
        
    "Last.Y" => 0,
        ));
        return 
    $this->lastY->get("Last.Y");
    }

    public function 
    getLastZ($playerName) {
        
    $this->lastZ = new Config($this->getDataFolder() . "Players/" strtolower($playerName) . ".yml"Config::YAML, array(
        
    "Last.Z" => 0,
        ));
        return 
    $this->lastZ->get("Last.Z");
    }

    public function 
    setLastX($playerName$x) {
        
    $this->lastX = new Config($this->getDataFolder() . "Players/" strtolower($playerName) . ".yml"Config::YAML, array(
        
    "Last.X" => 0,
        ));
        
    $this->lastX->set("Last.X"$x);
        
    $this->lastX->save();
    }

    public function 
    setLastY($playerName$y) {
        
    $this->lastY = new Config($this->getDataFolder() . "Players/" strtolower($playerName) . ".yml"Config::YAML, array(
        
    "Last.Y" => 0,
        ));
        
    $this->lastY->set("Last.Y"$y);
        
    $this->lastY->save();
    }

    public function 
    setLastZ($playerName$z) {
        
    $this->lastZ = new Config($this->getDataFolder() . "Players/" strtolower($playerName) . ".yml"Config::YAML, array(
        
    "Last.Z" => 0,
        ));
        
    $this->lastZ->set("Last.X"$z);
        
    $this->lastZ->save();
    }

    public function 
    onMove(PlayerMoveEvent $event) {
        
    $player $event->getPlayer();
        
    $block //Whatever block you want;
     
        
    $this->setLastX($player->getName(), $player->getX());//
        
    $this->setLastY($player->getName(), $player->getY());// Saves the players last coordinates
        
    $this->setLastZ($player->getName(), $player->getZ());//
     
        
    $player->getLevel()->setBlock(new Vector3($this->getLastX($player->getName()), $this->getLastY($player->getName()), $this->getLastZ($player->getName())), Block::get(Block::AIR)); // Unsets the block from players last position
        
    $player->getLevel()->setBlock(new Vector3($player), $block); //Moves the block to the player's current coordinates
    }
    Last edited: Nov 1, 2015
    Praxthisnovcht likes this.
  6. CrazedMiner
    Offline

    CrazedMiner Notable Member Plugin Developer

    Joined:
    Jan 31, 2015
    Posts:
    348
    Plugins:
    2
    Minecraft User:
    CrazedMinerYT
    Or you could make the player "invisible" and spawn a falling sand entity that moves like the player would.
    thebigsmileXD likes this.
  7. Vaivez66
    Offline

    Vaivez66 Notable Member Plugin Developer

    Joined:
    Jun 10, 2015
    Posts:
    402
    Plugins:
    2
    Lol,... That Panda makes me laugh xD :D

Share This Page

Advertisement