How to stop sand/gravel from falling

Discussion in 'Facepalm' started by DonSpiderLord, Aug 26, 2020.

  1. DonSpiderLord

    DonSpiderLord Silverfish

    Messages:
    15
    GitHub:
    EEHoveckis
    Hello!

    How do I stop sand and gravel from falling when no blocks are under? I want them to float.
    Is there somekind of plugin for it?
    Thanks in advance!
     
  2. xLeakDev Enzo

    xLeakDev Enzo Spider Jockey

    Messages:
    38
    GitHub:
    nya-enzo
    What you would do is setImmobile() on your entity. If you want it whenever an Falling Block entity spawns, you could make a task, loop trough all entities an check if FallingBlock and if not immobile set immobile (not the best way but still working)
     
  3. xLeakDev Enzo

    xLeakDev Enzo Spider Jockey

    Messages:
    38
    GitHub:
    nya-enzo
    Correction: i checked and theres an event, the way of doing could be (not tested):

    PHP:
    //In your listener class

    public function onEntitySpawn(EntitySpawnEvent $e)
    {
          if(
    $e->getType() === Entity::FALLING_BLOCK)
          {
                 
    $e->setImmobile(true);
           }
    }
     
  4. minijaham

    minijaham Zombie Pigman

    Messages:
    687
    GitHub:
    minijaham
    .....why??
     
  5. xLeakDev Enzo

    xLeakDev Enzo Spider Jockey

    Messages:
    38
    GitHub:
    nya-enzo
    Well he wanted to stop sand/gravel to fall. So i just made a code that automatically stops gravel/sand from falling when it appears
     
  6. minijaham

    minijaham Zombie Pigman

    Messages:
    687
    GitHub:
    minijaham
    Wouldn't your code make the sand uncollidable?
     
  7. xLeakDev Enzo

    xLeakDev Enzo Spider Jockey

    Messages:
    38
    GitHub:
    nya-enzo
    setImmobile() is like cancelling playermoveevent. It prevents an entity from moving or falling. Tho you can still pass trhough the entity
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.