Solved Cancelling pistonextend event.

Discussion in 'Plugin Development' started by kukelekuuk00, Jan 17, 2013.

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



    I have a little snippet of code.
    1. @EventHandler(priority = EventPriority.HIGHEST)
    2. public void ReedPistonExtend(BlockPistonExtendEvent event) {
    3. if (event.isCancelled()) return;
    4. for (Block block : event.getBlocks()) {
    5. if (block.getTypeId() == 83) {
    6. event.setCancelled(true);
    7. break;
    8. }
    9. }

    This is supposed to cancel whenever it moves a SugarCane block.
    But no matter what I try, the piston moves and destroys the sugarcane and I can't figure it out.

    Any idea what I did wrong?

    Thanks in advance,

  2. Offline


  3. Offline


    That would only block it if the reed is directly in front of it, wouldn't it?
    Because I need to check for more blocks.

    Let me illustrate using text.
    [] = stone
    [- = piston
    :: = reed


    It needs to block it in all these kind of situations.

    Edit: your getExtendLocation function is nowhere to be found in the javadocs.
  4. Offline


    debug your code
  5. Offline


    You are completely right, I debugged my code and I found the issue in no time.
    (The problem was that reeds don't show up in event.getBlocks())

Thread Status:
Not open for further replies.

Share This Page