FallingBlock - Move my Rocket :D

Discussion in 'Plugin Development' started by TimBone, Oct 1, 2013.

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

    TimBone

    Hey Community,
    I try to move a cuboid of blocks. I want to move my rocket up :D
    So I get all blocks from the selection and reset them to a FallingBlock. I set the y of the violicity higher, but the block isn't moving up.

    Code:java
    1. if (selection != null) {
    2. World w = p.getWorld();
    3. Location min = selection.getMinimumPoint();
    4. Location max = selection.getMaximumPoint();
    5. for (int x = min.getBlockX(); x <= max.getBlockX(); x++) {
    6. for (int y = min.getBlockY(); y <= max.getBlockY(); y++) {
    7. for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
    8. Block block = w.getBlockAt(x, y, z);
    9. Location loc = new Location(w,x,y,z);
    10. FallingBlock fb = w.spawnFallingBlock(loc, block.getType(), (byte) 0);
    11. fb.setVelocity(new Vector(x,y + Integer.valueOf(args[0]),z));
    12. block.setType(Material.AIR);
    13. }
    14. }
    15. }
    16. }


    What did I wrong?
     
  2. Offline

    Chinwe

    Try setting the block to air before spawning the FallingBlock, and/or spawn the block slightly above the block, so it doesn't spawn and get stuck in the block :oops:

    Oh, and you're getting the location at the specific location (0, 0, 0), (1, 0, 0) etc, I expect you want to get a relative block instead?

    Code:
    block.getRelative(x,y,z);
     
  3. Offline

    TimBone

    Okay, thanks - Work fine
     
Thread Status:
Not open for further replies.

Share This Page