Solved Stop crops from breaking on bock update

Discussion in 'Plugin Development' started by Tacodude, Aug 10, 2020.

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


    I have made it so you can place wheat crops on sand. The placing works fine but when I place a block next to the crops and they get updated, the game realizes that crops are not supposed to be growing on sand, so they break. I don't know what event gets called when they break like this (not BlockBreakEvent because no player is responsible for the breaking).

    How do I stop the crops from breaking?
  2. Offline


    Maybe BlockPhysicsEvent?
  3. Offline


    Worked like a charm, thanks! [I feel like this event could have a better name] The code for this encase anybody who finds this in the future:

        if (e.getBlock().getType() == Material.WHEAT) {
           Location l = e.getBlock().getLocation();
           if (e.getBlock().getWorld().getBlockAt(l.getBlockX(), l.getBlockY() - 1, l.getBlockZ())
               .getType() == Material.SAND) {
    Last edited by a moderator: Aug 10, 2020
  4. Offline


    @Tacodude just remember that the BlockPhysicsEvent is called often thousands of times per second, so if you don't want lag don't do any heavy processing in it (this should be just fine I think).
  5. Offline

    timtower Moderator Moderator

    You sure you are not confused with the PlayerMoveEvent?
  6. Offline


    pietermantel likes this.
  7. Offline

    timtower Moderator Moderator

    Yeah, can't argue with that one XD
    KarimAKL likes this.
Thread Status:
Not open for further replies.

Share This Page