Solved Giving blocks gravity?

Discussion in 'Spigot Plugin Development' started by Fredashay, Jan 19, 2020.

  1. I know it's possible to test if a block has gravity.

    But is it possible to set gravity to true or false on a particular block?

    For example, if I wanted to give a block of dirt gravity like sand and gravel?
  2. Always those "Minecraft but (some stupid stuff)"

    You can create a > FallingBlock of every BlockData you want.
    Code (Java):
    location.getWorld().spawnFallingBlock(location, Material.BEDROCK, 0);
    Returns the falling block. Just make sure you set the BlockData of that block before deleting the old one so everything with metadata doesn't get reset to the default state.
    • Like Like x 2
  3. Okay. So I have to check every time someone places a block or removes a block under a block? Even removes a block, under a block, under a block, under a block... Grrr! That's gonna be super complex. I was hoping I could just set gravity to true to a whole bunch of blocks in a given area (like sand and gravel) and then let the game deal with what happens if players interact with those blocks. Nothing is ever simple :-(
  4. Maybe there is some stuff you can do with reflections... Never tried.
  5. it's actually easy, break the block then check with a loop the blocks above it and give them the same treatment like this:
    for (int i = blockYloc; i < 256; i++) {
    Block above = world.getBlockAt(x, i, z);
    //do what you want
    • Like Like x 1
  6. Okay. Thanks for the help :)