Solved How to summon falling block

Discussion in 'Plugin Development' started by cheeseypotato, Nov 27, 2019.

  1. Offline

    cheeseypotato

    Hello people,
    I have looked around on how to summon a falling block in 1.14.4 and have been unable to find anything other than basic spawn entity -
    Code:
    FallingBlock block = (FallingBlock) player.getWorld().spawnEntity(randomLoc, EntityType.FALLING_BLOCK);
    And when I tried it the block doesn't appear at all, I'm assuming it's got to do with how long it's meant to live for but I have no clue what to do to make the block actually appear. I'd also like to know how to set the falling block to a certain material.
    Thanks, Me
     
  2. Offline

    DerDonut

    Use World#spawnFallingBlock Docs
     
  3. Offline

    cheeseypotato

    Thanks, would there be any way to get a random material that i could set the falling block to?
     
  4. Offline

    DerDonut

    Material.values() returns an array of all materials, get a random number within the range of the array and use it as the index. You should also check if the material is a block

    EDIT: Since there are a lot of materials which aren't blocks, maybe it's more efficient to shuffle the array (convert to arrayList e.g.) and loop over it until there is a block, maybe not
     
    Last edited: Nov 27, 2019
  5. Offline

    cheeseypotato

Share This Page