if (crowbar.canLink(thePlayer, stack, cart)) {
boolean linkable = cart instanceof ILinkableCart;
if (!linkable || (linkable && ((ILinkableCart) cart).isLinkable()))
if (linkMap.containsKey(thePlayer)) {
ILinkageManager lm = LinkageManager.instance();
EntityMinecart last = linkMap.remove(thePlayer);
if (lm.areLinked(cart, last)) {
lm.breakLink(cart, last);
used = true;
ChatPlugin.sendLocalizedChat(thePlayer, "railcraft.gui.link.broken");
LinkageManager.printDebug("Reason For Broken Link: User removed link.");
} else {
used = lm.createLink((EntityMinecart) entity, (EntityMinecart) last);
if (used)
ChatPlugin.sendLocalizedChat(thePlayer, "railcraft.gui.link.created");
}
if (!used)
ChatPlugin.sendLocalizedChat(thePlayer, "railcraft.gui.link.failed");