Source:
public Sprite copyForCloneBrick(Sprite spriteToCopy) { Sprite sprite = new Sprite(spriteToCopy.getName() + "-c" + StageActivity .getAndIncrementNumberOfClonedSprites()); Project currentProject = ProjectManager.getInstance().getCurrentProject(); Scene currentScene = ProjectManager.getInstance().getCurrentlyEditedScene(); ScriptController scriptController = new ScriptController(); sprite.isClone = true; sprite.setActionFactory(spriteToCopy.getActionFactory()); for (LookData look : spriteToCopy.getLookList()) { sprite.getLookList().add(new LookData(look.getName(), look.getFile())); } sprite.getSoundList().addAll(spriteToCopy.getSoundList()); sprite.getNfcTagList().addAll(spriteToCopy.getNfcTagList()); DeviceVariableAccessor accessor = new DeviceVariableAccessor(currentProject.getDirectory()); for (UserVariable originalVariable : spriteToCopy.getUserVariables()) { if (checkDeviceVariableKeyEmpty(originalVariable)) { accessor.addKeyToUserVariable(originalVariable); } UserVariable copyVariable = new UserVariable(originalVariable); copyVariable.setDeviceValueKey(originalVariable.getDeviceValueKey()); sprite.getUserVariables().add(copyVariable); } for (UserList userList : spriteToCopy.getUserLists()) { sprite.getUserLists().add(new UserList(userList)); } for (Script script : spriteToCopy.getScriptList()) { try { sprite.addScript(scriptController.copy(script, currentProject, currentScene, sprite)); } catch (CloneNotSupportedException | IOException e) { Log.e(TAG, Log.getStackTraceString(e)); } } sprite.resetSprite(); int currentLookDataIndex = spriteToCopy.getLookList().indexOf(spriteToCopy.look.getLookData()); if (currentLookDataIndex != -1) { sprite.look.setLookData(sprite.getLookList().get(currentLookDataIndex)); } spriteToCopy.look.copyTo(sprite.look); return sprite; }

Target:
public Sprite copyForCloneBrick(Sprite spriteToCopy) { Sprite sprite = new Sprite(spriteToCopy.getName() + "-c" + StageActivity .getAndIncrementNumberOfClonedSprites()); Project currentProject = ProjectManager.getInstance().getCurrentProject(); Scene currentScene = ProjectManager.getInstance().getCurrentlyEditedScene(); ScriptController scriptController = new ScriptController(); sprite.isClone = true; sprite.setActionFactory(spriteToCopy.getActionFactory()); for (LookData look : spriteToCopy.getLookList()) { sprite.getLookList().add(new LookData(look.getName(), look.getFile())); } sprite.getSoundList().addAll(spriteToCopy.getSoundList()); sprite.getNfcTagList().addAll(spriteToCopy.getNfcTagList()); for (UserVariable originalVariable : spriteToCopy.getUserVariables()) { UserVariable copyVariable = new UserVariable(originalVariable); copyVariable.setDeviceValueKey(originalVariable.getDeviceValueKey()); sprite.getUserVariables().add(copyVariable); } for (UserList userList : spriteToCopy.getUserLists()) { sprite.getUserLists().add(new UserList(userList)); } for (Script script : spriteToCopy.getScriptList()) { try { sprite.addScript(scriptController.copy(script, currentProject, currentScene, sprite)); } catch (CloneNotSupportedException | IOException e) { Log.e(TAG, Log.getStackTraceString(e)); } } sprite.resetSprite(); int currentLookDataIndex = spriteToCopy.getLookList().indexOf(spriteToCopy.look.getLookData()); if (currentLookDataIndex != -1) { sprite.look.setLookData(sprite.getLookList().get(currentLookDataIndex)); } spriteToCopy.look.copyTo(sprite.look); return sprite; }