if (Game.isHost(world)) {
SignalReceiver receiver = ((IReceiverTile) tile).getReceiver();
if (i != cPos.x || j != cPos.y || k != cPos.z) {
tile = world.getTileEntity(cPos.x, cPos.y, cPos.z);
if (tile != null && tile instanceof IControllerTile) {
SignalController controller = ((IControllerTile) tile).getController();
if (receiver.getTile() != controller.getTile()) {
controller.registerReceiver(receiver);
controller.endPairing();
ChatPlugin.sendLocalizedChat(player, "railcraft.gui.tuner.success", controller.getName(), receiver.getName());
item.setTagCompound(null);
return true;
}
} else if (world.blockExists(cPos.x, cPos.y, cPos.z)) {
ChatPlugin.sendLocalizedChat(player, "railcraft.gui.tuner.abandon.gone");
item.setTagCompound(null);
} else {
ChatPlugin.sendLocalizedChat(player, "railcraft.gui.tuner.abandon.chunk");
item.setTagCompound(null);
}
}
}
} else if (tile instanceof IControllerTile) {
if (Game.isHost(world)) {
SignalController controller = ((IControllerTile) tile).getController();
if (cPos == null || (i != cPos.x || j != cPos.y || k != cPos.z)) {
ChatPlugin.sendLocalizedChat(player, "railcraft.gui.tuner.start", controller.getName());
setControllerData(item, tile);
controller.startPairing();
} else {
ChatPlugin.sendLocalizedChat(player, "railcraft.gui.tuner.stop", controller.getName());
controller.endPairing();
item.setTagCompound(null);
}
}
} else
return false;