try {
Minecart cart = (Minecart) event.getVehicle();
Block block = event.getVehicle().getLocation().getBlock();
CartMechanismBlocks cmb = CartMechanismBlocks.findByRail(block);
cmb.setFromBlock(block); // WAI
CartBlockEnterEvent ev = new CartBlockEnterEvent(cart, event.getEntered(), cmb);
CraftBookPlugin.inst().getServer().getPluginManager().callEvent(ev);
if(ev.isCancelled())
event.setCancelled(true);
} catch (InvalidMechanismException ignored) {
}
}
}