How to change a normal block to a falling block

Discussion in 'Plugin Development' started by Casinator, Feb 14, 2020.

Thread Status:
Not open for further replies.
  1. Offline


    oldmaterial = block.getType();
                            loc.getWorld().spawnFallingBlock(blockloc, oldmaterial, (byte) 0x0);
    Hello! Im trying to code a plugin which lets specific blocks turn into falling blocks. But when I test this this looks VERY buggy. My idea is to change the block to a falling block. I already tried to check if the Block underneath exists, if not, the block wouldn't change. Plz Help:)
  2. Offline


    This should work:
    1. Block b = player.getTargetBlock(null, 100); //your block
    2. BlockData blockData = b.getBlockData();
    3. b.setType(Material.AIR);
    4. player.getWorld().spawnFallingBlock(b.getLocation().add(0.5, 0, 0.5), blockData); //the .add(0.5, 0, 0.5) is to center the entity to the middle of the block
    MightyOne likes this.
  3. Offline


    Thanks! Now working much better:D


    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Feb 16, 2020
Thread Status:
Not open for further replies.

Share This Page