Preventing someone from opening Storage Minecart

Discussion in 'Plugin Development' started by Ribesg, Oct 25, 2011.

Thread Status:
Not open for further replies.
  1. Hi !
    I can't figure out how to prevent somebody to open a storage minecart.
    This doesn't work :
    Code:java
    1. if (action.equals(Action.RIGHT_CLICK_BLOCK)) {
    2. if (block.getType().equals(Material.STORAGE_MINECART)) {
    3. event.setCancelled(true);
    4. }

    Where block is event.getClickedBlock() and action is event.getAction(), this is in onPlayerInteract.
    Help ?
     
  2. A Storage Minecart isn't a block. It's an Entity. So you could listen for a PlayerInteractEntityEvent and check if the Entity that is rightclicked is instanceof a Storage Minecart.
     
  3. Oh.
    Thank you ! ^^
     
Thread Status:
Not open for further replies.

Share This Page