public Packet250ServerSelectionGeneration handlePacket( Packet250ServerSelectionGeneration packet, MessageContext ctx) { final float ERROR_STATUS = -10.0F; EntityPlayerMP entityPlayerMP = ctx.getServerHandler().playerEntity; int uniqueID = packet.getUniqueID(); if (!players.containsKey(entityPlayerMP)) { ErrorLog.defaultLog() .info("ServerVoxelSelections:: Packet received from player not in players"); Packet250Base message = Packet250ServerSelectionGeneration.replyFractionCompleted(uniqueID, ERROR_STATUS); sendReplyMessageToClient(message, entityPlayerMP); return null; } Integer lastCommandID = playerLastCommandID.get(entityPlayerMP); if (lastCommandID == null) lastCommandID = Integer.MIN_VALUE; if (uniqueID < lastCommandID) return null; // discard old commands switch (packet.getCommand()) { case STATUS_REQUEST: { if (uniqueID != lastCommandID) return null; // discard old or too-new commands CommandStatus commandStatus = playerCommandStatus.get(entityPlayerMP); if (commandStatus == null) return Packet250ServerSelectionGeneration.replyFractionCompleted( uniqueID, ERROR_STATUS); final float JUST_STARTED_VALUE = 0.01F; Packet250Base message = null; switch (commandStatus) { case QUEUED: { message = Packet250ServerSelectionGeneration.replyFractionCompleted( uniqueID, JUST_STARTED_VALUE); break; } case COMPLETED: { message = Packet250ServerSelectionGeneration.replyFractionCompleted(uniqueID, 1.0F); break; } case EXECUTING: { BlockVoxelMultiSelector blockVoxelMultiSelector = playerBlockVoxelMultiSelectors.get(entityPlayerMP); if (blockVoxelMultiSelector == null) { message = Packet250ServerSelectionGeneration.replyFractionCompleted( uniqueID, ERROR_STATUS); } else { message = Packet250ServerSelectionGeneration.replyFractionCompleted( uniqueID, blockVoxelMultiSelector.getEstimatedFractionComplete()); } break; } default: assert false : "Invalid commandStatus in ServerVoxelSelections:" + commandStatus; } if (message != null) { sendReplyMessageToClient(message, entityPlayerMP); } return null; } case ABORT: { if (uniqueID == lastCommandID) { abortCurrentCommand(entityPlayerMP); } return null; } case ALL_IN_BOX: case UNBOUND_FILL: case BOUND_FILL: { if (uniqueID < lastCommandID) return null; // discard old commands if (uniqueID == lastCommandID) { CommandStatus commandStatus = playerCommandStatus.get(entityPlayerMP); if (commandStatus != CommandStatus.COMPLETED) return null; // ignore this command if we're currently processing it } boolean success = enqueueSelectionCommand(entityPlayerMP, packet); if (success) { playerLastCommandID.put(entityPlayerMP, uniqueID); } Packet250Base message = Packet250ServerSelectionGeneration.replyFractionCompleted( uniqueID, success ? 0.0F : ERROR_STATUS); sendReplyMessageToClient(message, entityPlayerMP); return null; } default: { ErrorLog.defaultLog() .severe("Invalid command received in ServerVoxelSelections:" + packet.getCommand()); return null; } } }