Cancel Sand/gravel falling event?

Discussion in 'Plugin Development' started by Nitnelave, Nov 28, 2011.

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

    Nitnelave

    Hello!
    Do you know of a way to prevent gravel/sand from falling? I tried to cancel the BlockPhysics event, but it does not work when I place a sand block over empty space...
     
  2. Offline

    bleachisback

    On the BlockPlaceEvent, do this:

    Code:JAVA
    1.  
    2. event.setCancelled(true);
    3. event.getPlacedBlock().setTypeId(event.getPlacedBlock().getTypeId,false);
    4.  


    Now that I think about it, it looks really weird. Try it out, and maybe it works...
     
  3. Offline

    Nitnelave

    Nope, doesn't work... I also tried to place a block with setTypeId(id_of_gravel, false); and cancel all of the blockphysics events, to no avail. It just doesn't care... I think when you place the block, it doesn't go to the "Block" state, but as it sees that there's a space under, it starts dropping immediately... A solution may that if the block under is "empty" (or a fluid) replace it with a "solid" block, put the gravel, then delete the "solid" block? I'll try that.
     
  4. Offline

    bleachisback

    oh the fixes plugin devs can think of. Reminds me of when I made a plugin to turn chests into cobblestone when pushed by a piston, and then back afterwards XD
     
  5. Offline

    Nitnelave

    Ok! For posterity, I fixed it by placing a rock block under if the block under was air, water or lava, and 2 TICKS LATER (not right after, nor 1 tick) I replaced it by the block it was before (air, water or lava).
    Once the blocks are set, it's not a problem cancelling their fall, cancelling the blockPhysics event does it.
     
  6. Offline

    bleachisback

    Glad to see you got it working ^^
    Just to make it look better, I suggest doing this:

    Code:JAVA
    1.  
    2. for(Player player:server.getOnlinePlayers())
    3. {
    4. player.sendBlockChange(blockUnderSand.getLocation(), 0, 0);
    5. }
    6.  


    That way they won't see a blinking stone block
     
  7. Offline

    Nitnelave

    Well, I don't think they see one, I tested and didn't see it. But I will bear that in mind, if the issue arises.
     
Thread Status:
Not open for further replies.

Share This Page