private void SaveTileEntity(bool save) { if (save) { if (SelectedItemFrame != null) { var worldFrame = CurrentWorld.GetTileEntityAtTile(SelectedItemFrame.PosX, SelectedItemFrame.PosY); if (worldFrame != null) { int index = CurrentWorld.TileEntities.IndexOf(worldFrame); CurrentWorld.TileEntities[index] = SelectedItemFrame.Copy(); } } } else { SelectedItemFrame = null; SelectedSpecialTile = 0; } }