@Override
public void rightClickBlock(GlowPlayer player, GlowBlock target, BlockFace face,
ItemStack holding, Vector clickedLoc, EquipmentSlot hand) {
if (target == null || target.getType() != Material.RAILS) {
return;
}
if (minecartType.getMinecartClass() == null) {
player.sendMessage(
ChatColor.RED + "Minecart type '" + minecartType.getEntityType().getName()
+ "' is not implemented.");
return;
}
Rails rails = (Rails) target.getState().getData();
Location location = target.getLocation().clone()
.add(Math.abs(rails.getDirection().getModX()) * 0.5, 0.1,
Math.abs(rails.getDirection().getModZ()) * 0.5);
location.setYaw(getYaw(rails.getDirection()));
target.getWorld().spawn(location, minecartType.getEntityClass());
if (player.getGameMode() != GameMode.CREATIVE) {
player.getInventory().remove(holding);
}
super.rightClickBlock(player, target, face, holding, clickedLoc, hand);
}