Issue with BlockGrowEvent [Melons]

Discussion in 'Plugin Development' started by slayr288, Jun 17, 2013.

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

    slayr288

    I'm trying to modify the melon that grows from a melon stem, but I can't seem to get when a melon is grown, and where the melon block will be.

    I've done a debug code:
    Code:
            Block block = e.getBlock();
            Block newBlock = e.getNewState().getBlock();
            plugin.getLogger().info("blockgrowevent:"+block.getType().toString()+"-"+block.getData()+":"+newBlock.getType().toString());
    And it returns:
    Code:
    blockgrowevent:AIR-0:AIR
    when a melon grows.


    Edit:
    Note when a new melon seed grows, it returns:
    Code:
    blockgrowevent:MELON_STEM-0:MELON_STEM
    So, the debug log is working, but returns air to air when a melon is grown?
     
  2. Offline

    slayr288

    Bump.
    Is it a bukkit issue or just me?
     
  3. Offline

    chasechocolate

    Try running that code 1 tick later.
     
  4. Hmm, What happens if you get the material dirtectly from the new block state instead of the block?

    Code:
    Material new mat = e.getNewState().getType();
    
    I have a feeling getBlock gets the actual physical block (air) in world, rather than a "future" block.

    Edit:
    Quote from the BlockState page
    This confirms my suspicison, Block only exists in the now (before the melon)
     
  5. Offline

    slayr288

    chasechocolate
    It returns the melon when ran a tick later, so that would explain what tehbeard said.
    Now, is their anyway to know 100% what block is the source of the melon? I was thinking of using blockfaces, but what if the melon is in between two melon stems?
     
Thread Status:
Not open for further replies.

Share This Page