public void onPrepareDialog(int dialogId, Dialog dialog) {
   switch (dialogId) {
     case DIALOG_CHANGE_GAME_MODE:
       int levelType = EditorActivity.level.getGameType() == 1 ? 1 : 0;
       ((AlertDialog) dialog).getListView().setSelection(levelType);
       break;
     case DIALOG_MOVE_PLAYER:
       Player player = EditorActivity.level.getPlayer();
       Vector3f playerLoc = player.getLocation();
       ((EditText) dialog.findViewById(R.id.entities_spawn_x))
           .setText(Float.toString(playerLoc.getX()));
       ((EditText) dialog.findViewById(R.id.entities_spawn_y))
           .setText(Float.toString(playerLoc.getY()));
       ((EditText) dialog.findViewById(R.id.entities_spawn_z))
           .setText(Float.toString(playerLoc.getZ()));
       break;
     default:
       super.onPrepareDialog(dialogId, dialog);
   }
 }
 public void onClick(View v) {
   if (v == gameModeChangeButton) {
     showDialog(DIALOG_CHANGE_GAME_MODE);
   } else if (v == spawnToPlayerButton) {
     setSpawnToPlayerPosition();
     EditorActivity.save(this);
   } else if (v == timeToMorningButton) {
     setTimeToMorning();
     updateTimeText();
   } else if (v == timeToNightButton) {
     setTimeToNight();
     updateTimeText();
   } else if (v == fullHealthButton) {
     setPlayerHealthToFull();
   } else if (v == infiniteHealthButton) {
     setPlayerHealthToInfinite();
   } else if (v == warpToSpawnButton) {
     warpPlayerToSpawn();
   } else if (v == sidewaysOnButton) {
     playerSideways(true);
   } else if (v == sidewaysOffButton) {
     playerSideways(false);
   } else if (v == movePlayerButton) {
     showDialog(DIALOG_MOVE_PLAYER);
   } else if (v == flyingBox) {
     Player player = EditorActivity.level.getPlayer();
     player.getAbilities().flying = flyingBox.isChecked();
     EditorActivity.save(this);
   } else if (v == invulnerableBox) {
     Player player = EditorActivity.level.getPlayer();
     player.getAbilities().invulnerable = invulnerableBox.isChecked();
     EditorActivity.save(this);
   } else if (v == instaBuildBox) {
     Player player = EditorActivity.level.getPlayer();
     player.getAbilities().instabuild = instaBuildBox.isChecked();
     EditorActivity.save(this);
   } else if (v == mayFlyBox) {
     Player player = EditorActivity.level.getPlayer();
     player.getAbilities().mayFly = mayFlyBox.isChecked();
     EditorActivity.save(this);
   } else if (v == spawnMobsBox) {
     EditorActivity.level.setSpawnMobs(instaBuildBox.isChecked());
     EditorActivity.save(this);
   }
 }
 private void setSpawnToPlayerPosition() {
   Level level = EditorActivity.level;
   Vector3f loc = level.getPlayer().getLocation();
   level.setSpawnX((int) loc.getX());
   level.setSpawnY((int) loc.getY());
   level.setSpawnZ((int) loc.getZ());
   Player player = level.getPlayer();
   player.setSpawnX((int) loc.getX());
   player.setSpawnY((int) loc.getY());
   player.setSpawnZ((int) loc.getZ());
   player.setBedPositionX((int) loc.getX());
   player.setBedPositionY((int) loc.getY());
   player.setBedPositionZ((int) loc.getZ());
 }