"Smash" Block Manipulation

Discussion in 'Plugin Development' started by sparta417, Aug 18, 2014.

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

    sparta417

    I've always pondered how the minigame "Smash" has achieved the ability to manipulate blocks in the way where you are able to change the x, y, and z of a block/entity without "grid-snapping".

    Is there a "hack-erish" way to achieve this, or is this described in the Bukkit API to be achieved?

    I thought editing the NBTTag of blocks would enable this, but sadly it seemed to have not.
     
  2. Offline

    Garris0n

    Falling block entities.
     
  3. Offline

    SilentThief

    It isn't that hard really, you have to create a falling block entity as Garris0n said.

    Code:java
    1. @EventHandler
    2. public void onPlayerMove(PlayerMoveEvent event)
    3. {
    4. Location loc = player.getLocation().add(0, -1.0, 0);
    5. Block block = loc.getBlock();
    6.  
    7. FallingBlock fall = block.getWorld().spawnFallingBlock(block.getLocation(), block.getType(), block.getData());
    8. Vector veloc = fall.getVelocity();
    9. veloc.setY(veloc.getY() + 2);
    10. fall.setVelocity(veloc);
    11. block.setType(Material.AIR);
    12. }
    13. }

    This is my class for the mechanic. What this does is if a player stands on a block, the block will fly up and then land back down, it's used for a Spleef type mini-game I created.

    Hope this gives you a good idea of how to use it.
     
Thread Status:
Not open for further replies.

Share This Page