// Path: src/main/java/uk/kihira/tails/common/LibraryEntryData.java
// public class LibraryEntryData {
//     @Expose public final Outfit outfit;
//     @Expose public String entryName = "";
//     @Expose public final String comment = "";
//     @Expose public boolean favourite;
//     @Expose public final long creationDate;
//     @Expose public final UUID creatorUUID;
//     /**
//      * Name is used purely for display purposes.
//      */
//     @Expose public String creatorName;
//     public boolean remoteEntry = false;
// 
//     public LibraryEntryData(UUID creatorUUID, String creatorName, String name, Outfit outfit) {
//         this.entryName = name;
//         this.outfit = outfit;
//         this.creationDate = Calendar.getInstance().getTimeInMillis();
//         this.creatorUUID = creatorUUID;
//         this.creatorName = creatorName;
//     }
// 
//     @SuppressWarnings("RedundantIfStatement")
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         LibraryEntryData data = (LibraryEntryData) o;
// 
//         if (creationDate != data.creationDate) return false;
//         if (favourite != data.favourite) return false;
//         if (!comment.equals(data.comment)) return false;
//         if (!creatorUUID.equals(data.creatorUUID)) return false;
//         if (entryName != null ? !entryName.equals(data.entryName) : data.entryName != null) return false;
//         if (outfit != null ? !outfit.equals(data.outfit) : data.outfit != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = outfit != null ? outfit.hashCode() : 0;
//         result = 31 * result + (entryName != null ? entryName.hashCode() : 0);
//         result = 31 * result + comment.hashCode();
//         result = 31 * result + creatorUUID.hashCode();
//         result = 31 * result + (favourite ? 1 : 0);
//         result = 31 * result + (int) (creationDate ^ (creationDate >>> 32));
//         return result;
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/Tails.java
// @Mod(Tails.MOD_ID)
// public class Tails 
// {
//     public static final String MOD_ID = "tails";
//     public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
//     public static final Gson GSON = new GsonBuilder().create();
//     public static final boolean DEBUG = true;
// 
//     public static boolean hasRemote;
// 
//     public static CommonProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
// 
//     public Tails()
//     {
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onConfigChange);
//         MinecraftForge.EVENT_BUS.addListener(this::addReloadListener);
//     }
// 
//     private void setup(final FMLCommonSetupEvent event)
//     {
//         proxy.preInit();
//         Config.loadConfig();
// 
//         PartRegistry.loadAllPartsFromResources();
//     }
// 
//     private void addReloadListener(final AddReloadListenerEvent event)
//     {
//         event.addListener((stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor) ->
//                 CompletableFuture.runAsync(() -> proxy.onResourceManagerReload()));
//     }
// 
//     public void onConfigChange(final ModConfigEvent event)
//     {
//         if (event.getConfig().getModId().equals(Tails.MOD_ID)) 
//         {
//             Config.loadConfig();
//         }
//     }
// 
//     public static void setLocalOutfit(final Outfit outfit)
//     {
//         Config.localOutfit.set(outfit);
//         Config.configuration.save();
//     }
// }


import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import net.minecraftforge.fml.client.gui.widget.ExtendedButton;
import uk.kihira.tails.common.LibraryEntryData;
import uk.kihira.tails.common.Tails;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

    @Override
    public boolean charTyped(char codePoint, int modifiers)
    {
        this.searchField.charTyped(codePoint, codePoint);
        if (this.searchField.getVisible() && this.searchField.isFocused())
        {
            List<LibraryListEntry> newEntries = filterListEntries(this.searchField.getText().toLowerCase());
            newEntries.add(0, new LibraryListEntry.NewLibraryListEntry(this, null));
            // todo
            ///this.list.getEntries().clear();
            //this.list.getEntries().addAll(newEntries);
        }
        return super.charTyped(codePoint, modifiers);
    }

    @Override
    public boolean onEntrySelected(GuiList<LibraryListEntry> guiList, int index, LibraryListEntry entry)
    {
        if (!(entry instanceof LibraryListEntry.NewLibraryListEntry))
        {
            this.parent.libraryInfoPanel.setEntry(entry);
            this.parent.setOutfit(entry.data.outfit);
        }
        return true;
    }

    public void initList()
    {
        List<LibraryListEntry> libraryEntries = new ArrayList<>();
// Path: src/main/java/uk/kihira/tails/common/LibraryEntryData.java
// public class LibraryEntryData {
//     @Expose public final Outfit outfit;
//     @Expose public String entryName = "";
//     @Expose public final String comment = "";
//     @Expose public boolean favourite;
//     @Expose public final long creationDate;
//     @Expose public final UUID creatorUUID;
//     /**
//      * Name is used purely for display purposes.
//      */
//     @Expose public String creatorName;
//     public boolean remoteEntry = false;
// 
//     public LibraryEntryData(UUID creatorUUID, String creatorName, String name, Outfit outfit) {
//         this.entryName = name;
//         this.outfit = outfit;
//         this.creationDate = Calendar.getInstance().getTimeInMillis();
//         this.creatorUUID = creatorUUID;
//         this.creatorName = creatorName;
//     }
// 
//     @SuppressWarnings("RedundantIfStatement")
//     @Override
//     public boolean equals(Object o) {
//         if (this == o) return true;
//         if (o == null || getClass() != o.getClass()) return false;
// 
//         LibraryEntryData data = (LibraryEntryData) o;
// 
//         if (creationDate != data.creationDate) return false;
//         if (favourite != data.favourite) return false;
//         if (!comment.equals(data.comment)) return false;
//         if (!creatorUUID.equals(data.creatorUUID)) return false;
//         if (entryName != null ? !entryName.equals(data.entryName) : data.entryName != null) return false;
//         if (outfit != null ? !outfit.equals(data.outfit) : data.outfit != null) return false;
// 
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         int result = outfit != null ? outfit.hashCode() : 0;
//         result = 31 * result + (entryName != null ? entryName.hashCode() : 0);
//         result = 31 * result + comment.hashCode();
//         result = 31 * result + creatorUUID.hashCode();
//         result = 31 * result + (favourite ? 1 : 0);
//         result = 31 * result + (int) (creationDate ^ (creationDate >>> 32));
//         return result;
//     }
// }
// 
// Path: src/main/java/uk/kihira/tails/common/Tails.java
// @Mod(Tails.MOD_ID)
// public class Tails 
// {
//     public static final String MOD_ID = "tails";
//     public static final Logger LOGGER = LogManager.getLogger(MOD_ID);
//     public static final Gson GSON = new GsonBuilder().create();
//     public static final boolean DEBUG = true;
// 
//     public static boolean hasRemote;
// 
//     public static CommonProxy proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new);
// 
//     public Tails()
//     {
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup);
//         FMLJavaModLoadingContext.get().getModEventBus().addListener(this::onConfigChange);
//         MinecraftForge.EVENT_BUS.addListener(this::addReloadListener);
//     }
// 
//     private void setup(final FMLCommonSetupEvent event)
//     {
//         proxy.preInit();
//         Config.loadConfig();
// 
//         PartRegistry.loadAllPartsFromResources();
//     }
// 
//     private void addReloadListener(final AddReloadListenerEvent event)
//     {
//         event.addListener((stage, resourceManager, preparationsProfiler, reloadProfiler, backgroundExecutor, gameExecutor) ->
//                 CompletableFuture.runAsync(() -> proxy.onResourceManagerReload()));
//     }
// 
//     public void onConfigChange(final ModConfigEvent event)
//     {
//         if (event.getConfig().getModId().equals(Tails.MOD_ID)) 
//         {
//             Config.loadConfig();
//         }
//     }
// 
//     public static void setLocalOutfit(final Outfit outfit)
//     {
//         Config.localOutfit.set(outfit);
//         Config.configuration.save();
//     }
// }


// Path: src/main/java/uk/kihira/tails/client/gui/LibraryPanel.java
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.platform.GlStateManager;
import net.minecraft.client.gui.widget.TextFieldWidget;
import net.minecraft.client.gui.widget.button.Button;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TranslationTextComponent;
import net.minecraftforge.fml.client.gui.GuiUtils;
import net.minecraftforge.fml.client.gui.widget.ExtendedButton;
import uk.kihira.tails.common.LibraryEntryData;
import uk.kihira.tails.common.Tails;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;


    @Override
    public boolean charTyped(char codePoint, int modifiers)
    {
        this.searchField.charTyped(codePoint, codePoint);
        if (this.searchField.getVisible() && this.searchField.isFocused())
        {
            List<LibraryListEntry> newEntries = filterListEntries(this.searchField.getText().toLowerCase());
            newEntries.add(0, new LibraryListEntry.NewLibraryListEntry(this, null));
            // todo
            ///this.list.getEntries().clear();
            //this.list.getEntries().addAll(newEntries);
        }
        return super.charTyped(codePoint, modifiers);
    }

    @Override
    public boolean onEntrySelected(GuiList<LibraryListEntry> guiList, int index, LibraryListEntry entry)
    {
        if (!(entry instanceof LibraryListEntry.NewLibraryListEntry))
        {
            this.parent.libraryInfoPanel.setEntry(entry);
            this.parent.setOutfit(entry.data.outfit);
        }
        return true;
    }

    public void initList()
    {
        List<LibraryListEntry> libraryEntries = new ArrayList<>();
        for (LibraryEntryData data : Tails.proxy.getLibraryManager().libraryEntries)