Placing saplings on blocks other than dirt or grass

Discussion in 'Plugin Development' started by BeMacized, Mar 23, 2014.

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

    BeMacized

    Hi there,

    I'm developing a plugin in which I need the player to be able to place saplings on any block, other than just dirt or grass, which it's originally limited to.
    I tried working around this, by checking the action + the blockface in the playerinteractevent, and removing the item from the players inventory, and putting the block in the world manually.
    Code:java
    1. if (evt.getAction().equals(Action.RIGHT_CLICK_BLOCK) && evt.getBlockFace().equals(BlockFace.UP)) {

    But every time I right click a non dirt/grass block with a sapling in my hand, getAction() returns RIGHT_CLICK_AIR.
    Any way I could work around this?

    - BeMacized
     
  2. Offline

    xTrollxDudex

    BeMacized
    By the way, I believe that setting t manually will just break it and drop the sapling as an item.
     
  3. Offline

    BeMacized

    Not as long as there are no block updates. Once the block is there, it's not that hard to keep it there. The problem i'm having is the placing of the block.
     
  4. Offline

    xTrollxDudex

    BeMacized
    Interesting.... Try using that action and get the block anyways?
     
  5. Offline

    bennie3211

    Isn't it when you want to compare the action that you need to compare it with '=='? Like event.getAction() == Action.RIGHT_CLICK_BLOCK ?
     
  6. Offline

    BeMacized

    getClickedBlock() returns null when the Action is involving air.



    Afaik, it's an enum, and therefore should work just fine both ways.
     
  7. Offline

    xTrollxDudex

    BeMacized
    You're clicking a block and it says right click air. Get the block anyways, see what happens.
     
  8. Offline

    BeMacized

    As I said in my previous post:
    "getClickedBlock() returns null when the Action is involving air."
    Even though I right click a block with a sapling in my hand, it still counts it as a right click air action, and therefore that function seems to return null.
     
  9. Offline

    xTrollxDudex

    BeMacized
    I figured it probably would return click air if the item in your hand is not valid for the block you put it on, or it is a Bukkit bug...
     
Thread Status:
Not open for further replies.

Share This Page