How TO Detect Mine cart with Chest [Help Needed]

Discussion in 'Plugin Development' started by footy, May 31, 2014.

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

    footy

    Code:java
    1. if (block.getTypeId() == 342)
    2. {
    3. player.sendMessage("BLock is" + block);
    4. }//block detector
    5. {


    Ok that my code, for some reason it wont detect if the block Chest Cart is planted.

    I tried using by detecting my Material but Chest Cart isnt in the list.

    How can i detect is a player has planted a Chest Cart ?

    Please ignore the { symbol Facing ---->

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jul 1, 2016
  2. Offline

    Antybarrel

    Use playerinteractevent, then check if action is right click then check the item in players hand if its a Minecart with chest.
     
  3. Offline

    footy

    Hmm , i dont want to detect if playerinteracted with the item, i want to detect if a block is placed ontop of the chest cart
     
  4. Offline

    Zupsub

    All minecarts are entities (like players, npc, mobs, ...) and not blocks.
     
  5. Offline

    footy

    Code:java
    1. Minecart minecart = (Minecart) Event.getBlockAgainst();


    THink this will work ? but that minecart i need chest cart
     
  6. Offline

    Antybarrel

    Code:java
    1. StorageMinecart minecart = (StorageMinecart) Event.getBlockAgainst();
     
  7. Offline

    footy

    OK got that bit, What im trying to do know is detect is a block is on top of the Chest Cart,
     
  8. Offline

    iTornado1234

  9. Offline

    Antybarrel

    Code:java
    1. event.getBlockAgainst().getRelative(BlockFace.UP);
     
  10. Offline

    footy

    Ok im having bit troble of mathcing the block aginest the chest cart.

    if(block = minecart)
     
  11. Offline

    iTornado1234

    Code:java
    1. if(event.getBlock() == Block.MINECART)

    Its something like that footy
     
  12. Offline

    Zupsub

    iTornado1234 footy

    That's wrong in serveral things:
    if (event.getBlock() == Block.MINECART)
    1. There isn't any enum Block or any static MINECART for Block. You might want to say Material.MINECART
    2. A block isn't a material (like sand) it is an object *with* a material (and a location, ...)
    So you have to use event.getBlock().getType() == Material.MINECART
    (3.) I'm convinced (as mentioned above) that this DOES NOT work, since an (chest) minecart is NOT an block. It is an entity like a player.

    So what I would do: Loop threw all entites (World#getEntities()) and check, whether their location is below the (/ an) chest.
     
  13. Offline

    iTornado1234

    Zupsub Yea, thanks for fixing my errors. I noticed it after I posted it.
     
Thread Status:
Not open for further replies.

Share This Page