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

Create fake block

Comments in 'Plugin Development' started by xBeastMode, Jan 14, 2016.

  1. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    How to create a fake block? A visible block that is fake not an entity block.
    Last edited: Jan 14, 2016
  2. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
  3. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
  4. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
    If you want it to float and move fluently, it has to be an entity block (falling block).
    wolfdale likes this.
  5. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    OK, I will try.

    Edit: Where is the falling block in PocketMine src?
  6. PEMapModder
    Offline

    PEMapModder Notable Member Plugin Developer

    Joined:
    Oct 9, 2013
    Posts:
    7,294
    Plugins:
    11
    Minecraft User:
    PEMapModder
  7. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
  8. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
  9. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    You talk about a block like in Hide'n'Seek, right? There are plenty of toppics in this forum, search for hide and seek
  10. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    No. I wan't a block that floats and moves in the air, not moves on the floor.
  11. jojoe77777
    Offline

    jojoe77777 Notable Member Plugin Developer

    Joined:
    May 28, 2015
    Posts:
    653
    Plugins:
    1
    Minecraft User:
    jojoe77777
    I would suggest looking in the code for Slapper; spawn a FallingSand entity with a custom block ID, and the tag NoAI (to make it float)
    PEMapModder likes this.
  12. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Then.. Change the coordinates?! xD
  13. xBeastMode
    Offline

    xBeastMode Active Member

    Joined:
    Nov 27, 2015
    Posts:
    292
    this works but now it sets the block instead of following the player.
    PHP:
    public function onMove(PlayerMoveEvent $e){
            
    $p $e->getPlayer();
            
    $fall Entity::createEntity("FallingSand"$p->getLevel()->getChunk($p->>> 4$p->>> 4), new Compound("", [
                
    "Pos" => new Enum("Pos", [
                    new 
    Double(""$p->0.5),
                    new 
    Double(""$p->y+1),
                    new 
    Double(""$p->0.5)
                ]),
                
    "Motion" => new Enum("Motion", [
                    new 
    Double(""0),
                    new 
    Double(""0),
                    new 
    Double(""0)
                ]),
                
    "Rotation" => new Enum("Rotation", [
                    new 
    Float(""0),
                    new 
    Float(""0)
                ]),
                
    "TileID" => new Int("TileID"57),
                
    "Data" => new Byte("Data"0),
            ]));
            
    $fall->spawnToAll();
        }
  14. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    You have to use packets.
  15. thebigsmileXD
    Offline

    thebigsmileXD Banned

    Joined:
    May 19, 2015
    Posts:
    845
    Plugins:
    1
    Minecraft User:
    XenialDan
    Sorry. I mean: You have to kill the entity after some seconds (the packet) or update its coordinates instead of spawning a new one
  16. wolfdale
    Offline

    wolfdale Active Member Plugin Developer

    Joined:
    Dec 3, 2014
    Posts:
    276
    Plugins:
    1
    Minecraft User:
    ace
    You should spawn the FallingSand first for once (in events like PlayerJoinEvent), then store the FallingSand entityId in an array(for me i use player name as key). Then when player moves, get the FallingSand entity from the stored entityId and setPosition of the FallingSand to the player's position
    Like so
    PHP:
    $this->blocks[$player->getName()] = $fallingsand->getId();//just after spawning

            
    public function onPlayerMove(PlayerMoveEvent $e){
                
    $p $e->getPlayer();
                
    $n $p->getName();
                if (!isset(
    $this->blocks[$n])) return;
                
    $block $p->getLevel()->getEntity($this->blocks[$n]);
                if (
    $block$block->setPosition($p->getPosition()->add(0,0.2,0));
            }

Share This Page

Advertisement