package de.comeight.crystallogy.tabs;

import java.util.Collections;
import java.util.List;

import de.comeight.crystallogy.handler.BlockHandler;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class CrystallogyMainTab extends CreativeTabs{
	//-----------------------------------------------Variabeln:---------------------------------------------


	//-----------------------------------------------Constructor:-------------------------------------------
	public CrystallogyMainTab() {
		super(CreativeTabs.getNextID(), "crystallogy");
		
		setBackgroundImageName("item_search.png");
		
	}

	//-----------------------------------------------Set-, Get-Methoden:------------------------------------
	@SideOnly(Side.CLIENT)
	public Item getTabIconItem()
    {
		return Item.getItemFromBlock(BlockHandler.crystall_green);
    }
	
	@Override
	public boolean hasSearchBar() {
		return true;
	}
	
	@Override
	public void displayAllRelevantItems(List<ItemStack> list) {
		super.displayAllRelevantItems(sortList(list));
	}

	//-----------------------------------------------Sonstige Methoden:-------------------------------------
	private List<ItemStack> sortList(List<ItemStack> list){
		while(!sorted(list)){
		}
		return list;
	}
	
	private boolean sorted(List<ItemStack> list){
		boolean sorted = true;
		//System.out.println(list.size());
		for (int i = 0; i < list.size() - 1; i++) {
			String name1 = list.get(i).getDisplayName();
			String name2 = list.get(i + 1).getDisplayName();
			if(name1.compareTo(name2) < 0){
				System.out.println("sort");
				ItemStack temp1 = list.get(i);
				ItemStack temp2 = list.get(i + 1);
				
				list.set(i, temp2);
				list.set(i + 1, temp1);
				sorted = false;
			}
		}
		return sorted;
	}
	
	public int compare(String str1, String str2) {
        int res = String.CASE_INSENSITIVE_ORDER.compare(str1, str2);
        if (res == 0) {
            res = str1.compareTo(str2);
        }
        return res;
    }
	
}

@@ -38,65 +38,8 @@
 %0D%0A%0D%0A
-import java.util.Collections;%0D%0Aimport java.util.List;%0D%0A%0D%0A
 impo
@@ -173,46 +173,8 @@
 m;%0D%0A
-import net.minecraft.item.ItemStack;%0D%0A
 impo
@@ -999,1104 +999,115 @@
 %09%7D%0D%0A
-%09%0D%0A%09@Override%0D%0A%09public void displayAllRelevantItems(List%3CItemStack%3E list) %7B%0D%0A%09%09super.displayAllRelevantItems(sortList(list));%0D%0A%09%7D%0D%0A%0D%0A%09//-----------------------------------------------Sonstige Methoden:-------------------------------------%0D%0A%09private List%3CItemStack%3E sortList(List%3CItemStack%3E list)%7B%0D%0A%09%09while(!sorted(list))%7B%0D%0A%09%09%7D%0D%0A%09%09return list;%0D%0A%09%7D%0D%0A%09%0D%0A%09private boolean sorted(List%3CItemStack%3E list)%7B%0D%0A%09%09boolean sorted = true;%0D%0A%09%09//System.out.println(list.size());%0D%0A%09%09for (int i = 0; i %3C list.size() - 1; i++) %7B%0D%0A%09%09%09String name1 = list.get(i).getDisplayName();%0D%0A%09%09%09String name2 = list.get(i + 1).getDisplayName();%0D%0A%09%09%09if(name1.compareTo(name2) %3C 0)%7B%0D%0A%09%09%09%09System.out.println(%22sort%22);%0D%0A%09%09%09%09ItemStack temp1 = list.get(i);%0D%0A%09%09%09%09ItemStack temp2 = list.get(i + 1);%0D%0A%09%09%09%09%0D%0A%09%09%09%09list.set(i, temp2);%0D%0A%09%09%09%09list.set(i + 1, temp1);%0D%0A%09%09%09%09sorted = false;%0D%0A%09%09%09%7D%0D%0A%09%09%7D%0D%0A%09%09return sorted;%0D%0A%09%7D%0D%0A%09%0D%0A%09public int compare(String str1, String str2) %7B%0D%0A        int res = String.CASE_INSENSITIVE_ORDER.compare(str1, str2);%0D%0A        if (res == 0) %7B%0D%0A            res = str1.compareTo(str2);%0D%0A        %7D%0D%0A        return res;%0D%0A    %7D
+%0D%0A%09//-----------------------------------------------Sonstige Methoden:-------------------------------------
 %0D%0A%09%0D

clean up