Sfoglia il codice sorgente

Re-add an available keys screen. Close #76

Jared 4 anni fa
parent
commit
44c28e2a76

+ 3 - 2
src/main/java/com/blamejared/controlling/client/gui/GuiCheckBox.java

@@ -30,7 +30,7 @@ public class GuiCheckBox extends Button {
     public void renderButton(MatrixStack stack, int mouseX, int mouseY, float partial) {
         if(this.visible) {
             Minecraft mc = Minecraft.getInstance();
-            this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
+            this.isHovered = active && mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
             if(isHovered()) {
                 GuiUtils.drawContinuousTexturedBox(WIDGETS_LOCATION, this.x, this.y, 0, 86, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, 500);
                 GuiUtils.drawContinuousTexturedBox(WIDGETS_LOCATION, this.x+1, this.y+1, 2, 48, this.boxWidth-2, this.height-2, 200, 20, 1, 0, 1, 0, 500);
@@ -41,7 +41,8 @@ public class GuiCheckBox extends Button {
             
             if(packedFGColor != 0) {
                 color = packedFGColor;
-            } else if(!this.active) {
+            }
+            if(!this.active) {
                 color = 10526880;
             }
             

+ 28 - 0
src/main/java/com/blamejared/controlling/client/gui/GuiCustomList.java

@@ -0,0 +1,28 @@
+package com.blamejared.controlling.client.gui;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.screen.ControlsScreen;
+import net.minecraft.client.gui.widget.list.KeyBindingList;
+
+import java.util.List;
+
+public class GuiCustomList  extends KeyBindingList {
+    
+    public List<Entry> allEntries;
+    
+    public GuiCustomList(ControlsScreen controls, Minecraft mcIn) {
+        
+        super(controls, mcIn);
+    }
+    
+    public List<Entry> getAllEntries() {
+        
+        return allEntries;
+    }
+    
+    public void add(Entry ent) {
+        
+        getEventListeners().add(ent);
+        allEntries.add(ent);
+    }
+}

+ 140 - 0
src/main/java/com/blamejared/controlling/client/gui/GuiFreeKeysList.java

@@ -0,0 +1,140 @@
+package com.blamejared.controlling.client.gui;
+
+import com.google.common.collect.ImmutableList;
+import com.mojang.blaze3d.matrix.MatrixStack;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.IGuiEventListener;
+import net.minecraft.client.gui.screen.ControlsScreen;
+import net.minecraft.client.gui.widget.list.KeyBindingList;
+import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.client.util.InputMappings;
+import net.minecraft.util.text.TranslationTextComponent;
+import net.minecraftforge.api.distmarker.Dist;
+import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraftforge.fml.client.gui.GuiUtils;
+import sun.security.jca.GetInstance;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@OnlyIn(Dist.CLIENT)
+public class GuiFreeKeysList extends GuiCustomList {
+    
+    private final ControlsScreen controlsScreen;
+    private final Minecraft mc;
+    private int maxListLabelWidth;
+    
+    List<KeyBinding> keyBindings;
+    
+    public GuiFreeKeysList(ControlsScreen controls, Minecraft mcIn) {
+        
+        super(controls, mcIn);
+        this.width = controls.width + 45;
+        this.height = controls.height;
+        this.y0 = 43;
+        this.y1 = controls.height - 80;
+        this.x1 = controls.width + 45;
+        this.controlsScreen = controls;
+        this.mc = mcIn;
+        getEventListeners().clear();
+        allEntries = new ArrayList<>();
+        keyBindings = Arrays.stream(mc.gameSettings.keyBindings).collect(Collectors.toList());
+        
+        recalculate();
+        
+    }
+    
+    public void recalculate() {
+        
+        getEventListeners().clear();
+        allEntries.clear();
+        
+        add(new HeaderEntry("Available Keys"));
+        InputMappings.Input.REGISTRY.values().stream().filter(input -> {
+            return !input.toString().startsWith("key.keyboard.world");
+        }).sorted(Comparator.comparing(o -> o.func_237520_d_().getString())).forEach(input -> {
+            if(keyBindings.stream().noneMatch(keyBinding -> keyBinding.getKey().equals(input))) {
+                int i = mc.fontRenderer.getStringWidth(input.func_237520_d_().getString());
+                if(i > this.maxListLabelWidth) {
+                    this.maxListLabelWidth = i;
+                }
+                add(new InputEntry(input));
+            }
+        });
+    }
+    
+    @Override
+    protected int getScrollbarPosition() {
+        
+        return super.getScrollbarPosition() + 15 + 20;
+    }
+    
+    @Override
+    public int getRowWidth() {
+        
+        return super.getRowWidth() + 32;
+    }
+    
+    @OnlyIn(Dist.CLIENT)
+    public class InputEntry extends Entry {
+        
+        private final InputMappings.Input input;
+        
+        public InputEntry(InputMappings.Input input) {
+            
+            this.input = input;
+        }
+        
+        @Override
+        public List<? extends IGuiEventListener> getEventListeners() {
+            
+            return ImmutableList.of();
+        }
+    
+        public InputMappings.Input getInput() {
+        
+            return input;
+        }
+    
+        @Override
+        public void render(MatrixStack stack, int slotIndex, int y, int x, int p_render_4_, int p_render_5_, int mouseX, int mouseY, boolean p_render_8_, float p_render_9_) {
+            
+            String str = this.input.toString() + " - " + input.getKeyCode();// + " - " + input.func_237520_d_().getString() + " - " + input.getKeyCode();
+            int length = mc.fontRenderer.getStringWidth(input.func_237520_d_().getString());
+            
+            GuiFreeKeysList.this.mc.fontRenderer.drawString(stack, str, x, (float) (y + p_render_5_ / 2 - 9 / 2), 16777215);
+            GuiUtils.drawHoveringText(stack, Collections.singletonList(input.func_237520_d_()), x + p_render_4_ - (length), y + p_render_5_, mc.currentScreen.width, mc.currentScreen.height, -1, mc.fontRenderer);
+            
+        }
+        
+    }
+    
+    @OnlyIn(Dist.CLIENT)
+    public class HeaderEntry extends Entry {
+        
+        private final String text;
+        
+        public HeaderEntry(String text) {
+            
+            this.text = text;
+        }
+        
+        @Override
+        public List<? extends IGuiEventListener> getEventListeners() {
+            
+            return ImmutableList.of();
+        }
+        
+        @Override
+        public void render(MatrixStack stack, int slotIndex, int y, int x, int p_render_4_, int p_render_5_, int mouseX, int mouseY, boolean p_render_8_, float p_render_9_) {
+            
+            drawString(stack, mc.fontRenderer, new TranslationTextComponent("options.availableKeys"),  (mc.currentScreen.width / 2 - this.text.length() / 2), (y + p_render_5_ - 9 - 1), 16777215);
+        }
+        
+    }
+    
+}

+ 219 - 148
src/main/java/com/blamejared/controlling/client/gui/GuiNewControls.java

@@ -2,94 +2,91 @@ package com.blamejared.controlling.client.gui;
 
 import com.blamejared.controlling.Controlling;
 import com.mojang.blaze3d.matrix.MatrixStack;
-import com.mojang.blaze3d.platform.GlStateManager;
-import net.minecraft.client.AbstractOption;
-import net.minecraft.client.GameSettings;
-import net.minecraft.client.Minecraft;
+import net.minecraft.client.*;
 import net.minecraft.client.gui.IGuiEventListener;
-import net.minecraft.client.gui.screen.ControlsScreen;
-import net.minecraft.client.gui.screen.MouseSettingsScreen;
-import net.minecraft.client.gui.screen.Screen;
+import net.minecraft.client.gui.screen.*;
 import net.minecraft.client.gui.widget.TextFieldWidget;
 import net.minecraft.client.gui.widget.button.Button;
 import net.minecraft.client.gui.widget.list.KeyBindingList;
 import net.minecraft.client.settings.KeyBinding;
 import net.minecraft.client.util.InputMappings;
 import net.minecraft.util.Util;
-import net.minecraft.util.text.ITextComponent;
-import net.minecraft.util.text.StringTextComponent;
-import net.minecraft.util.text.TranslationTextComponent;
-import net.minecraftforge.api.distmarker.Dist;
-import net.minecraftforge.api.distmarker.OnlyIn;
+import net.minecraft.util.text.*;
+import net.minecraftforge.api.distmarker.*;
 import org.lwjgl.glfw.GLFW;
 
-import java.util.LinkedHashSet;
-import java.util.Random;
-import java.util.Set;
+import java.util.*;
 import java.util.function.Predicate;
 
 @OnlyIn(Dist.CLIENT)
 public class GuiNewControls extends ControlsScreen {
-
+    
     private Button buttonReset;
     private final Screen parentScreen;
     private final GameSettings options;
-
+    
     private String lastSearch;
     private TextFieldWidget search;
-
+    
     private DisplayMode displayMode;
     private SearchType searchType;
     private SortOrder sortOrder;
-
+    
     private Button buttonNone;
     private Button buttonConflicting;
     private GuiCheckBox buttonKey;
     private GuiCheckBox buttonCat;
+    private Button buttonFree;
     private Button patreonButton;
     private boolean confirmingReset = false;
-
+    private boolean showFree = false;
     private String name;
-
+    
+    private KeyBindingList customKeyList;
+    private GuiFreeKeysList freeKeyList;
+    
     public GuiNewControls(Screen screen, GameSettings settings) {
+        
         super(screen, settings);
         this.parentScreen = screen;
         this.options = settings;
     }
-
+    
     /**
      * Adds the buttons (and other controls) to the screen in question. Called when the GUI is displayed and when the
      * window resizes, the buttonList is cleared beforehand.
      */
     protected void init() {
-
+        
         this.addButton(new Button(this.width / 2 - 155, 18, 150, 20, new TranslationTextComponent("options.mouse_settings"), (p_213126_1_) -> {
             this.minecraft.displayGuiScreen(new MouseSettingsScreen(this, options));
         }));
         this.addButton(AbstractOption.AUTO_JUMP.createWidget(this.minecraft.gameSettings, this.width / 2 - 155 + 160, 18, 150));
-
-        this.keyBindingList = new GuiNewKeyBindingList(this, this.minecraft);
+        customKeyList = new GuiNewKeyBindingList(this, this.minecraft);
+        freeKeyList = new GuiFreeKeysList(this, this.minecraft);
+        this.keyBindingList = customKeyList;
         this.children.add(this.keyBindingList);
         this.setListener(this.keyBindingList);
-        this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29, 150, 20, new TranslationTextComponent("gui.done"), (p_213126_1_) -> GuiNewControls.this.minecraft.displayGuiScreen(GuiNewControls.this.parentScreen)));
-
-        this.buttonReset = this.addButton(new Button(this.width / 2 - 155, this.height - 29, 150, 20, new TranslationTextComponent("controls.resetAll"), (p_213126_1_) -> {
-
-            if (!confirmingReset) {
+        this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29, 150, 20, new TranslationTextComponent("gui.done"), (p_213126_1_) -> GuiNewControls.this.minecraft
+                .displayGuiScreen(GuiNewControls.this.parentScreen)));
+        
+        this.buttonReset = this.addButton(new Button(this.width / 2 - 155, this.height - 29, 74, 20, new TranslationTextComponent("controls.resetAll"), (p_213126_1_) -> {
+            
+            if(!confirmingReset) {
                 confirmingReset = true;
                 p_213126_1_.setMessage(new TranslationTextComponent("options.confirmReset"));
                 return;
             }
             confirmingReset = false;
             p_213126_1_.setMessage(new TranslationTextComponent("controls.resetAll"));
-            for (KeyBinding keybinding : GuiNewControls.this.minecraft.gameSettings.keyBindings) {
+            for(KeyBinding keybinding : GuiNewControls.this.minecraft.gameSettings.keyBindings) {
                 keybinding.setToDefault();
             }
-
+            
             KeyBinding.resetKeyBindingArrayAndHash();
         }));
         this.buttonNone = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24, 150 / 2, 20, new TranslationTextComponent("options.showNone"), (p_213126_1_) -> {
-            if (displayMode == DisplayMode.NONE) {
+            if(displayMode == DisplayMode.NONE) {
                 buttonNone.setMessage(new TranslationTextComponent("options.showNone"));
                 displayMode = DisplayMode.ALL;
             } else {
@@ -100,7 +97,7 @@ public class GuiNewControls extends ControlsScreen {
             filterKeys();
         }));
         this.buttonConflicting = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24, 150 / 2, 20, new TranslationTextComponent("options.showConflicts"), (p_213126_1_) -> {
-            if (displayMode == DisplayMode.CONFLICTING) {
+            if(displayMode == DisplayMode.CONFLICTING) {
                 buttonConflicting.setMessage(new TranslationTextComponent("options.showConflicts"));
                 displayMode = DisplayMode.ALL;
             } else {
@@ -111,38 +108,46 @@ public class GuiNewControls extends ControlsScreen {
             filterKeys();
         }));
         search = new TextFieldWidget(font, this.width / 2 - 154, this.height - 29 - 23, 148, 18, new StringTextComponent(""));
-        this.buttonKey = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 37, new TranslationTextComponent("options.key").getString(), false) {
+        this.buttonKey = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 37, new TranslationTextComponent("options.key")
+                .getString(), false) {
             @Override
             public void onPress() {
+                
                 super.onPress();
                 buttonCat.setIsChecked(false);
                 searchType = this.isChecked() ? SearchType.KEY : SearchType.NAME;
                 filterKeys();
             }
         });
-        this.buttonCat = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 50, new TranslationTextComponent("options.category").getString(), false) {
-
+        this.buttonCat = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2), this.height - 29 - 50, new TranslationTextComponent("options.category")
+                .getString(), false) {
+            
             @Override
             public void onPress() {
+                
                 super.onPress();
                 buttonKey.setIsChecked(false);
                 searchType = this.isChecked() ? SearchType.CATEGORY : SearchType.NAME;
                 filterKeys();
             }
         });
-        name = Controlling.PATRON_LIST.stream().skip(Controlling.PATRON_LIST.isEmpty() ? 0 : new Random().nextInt(Controlling.PATRON_LIST.size())).findFirst().orElse("");
-        patreonButton = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24 - 24, 150 / 2, 20, new StringTextComponent("Patreon"), p_onPress_1_ -> {
-            Util.getOSType().openURI("https://patreon.com/jaredlll08?s=controllingmod");
-        }) {
+        name = Controlling.PATRON_LIST.stream()
+                .skip(Controlling.PATRON_LIST.isEmpty() ? 0 : new Random().nextInt(Controlling.PATRON_LIST.size()))
+                .findFirst()
+                .orElse("");
+        patreonButton = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24 - 24, 150 / 2, 20, new StringTextComponent("Patreon"), p_onPress_1_ -> Util
+                .getOSType()
+                .openURI("https://patreon.com/jaredlll08?s=controllingmod")) {
             private boolean wasHovered;
-
+            
             @Override
             public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
-                if (this.visible) {
+                
+                if(this.visible) {
                     this.isHovered = mouseX >= this.x && mouseY >= this.y && mouseX < this.x + this.width && mouseY < this.y + this.height;
-                    if (this.wasHovered != this.isHovered()) {
-                        if (this.isHovered()) {
-                            if (this.isFocused()) {
+                    if(this.wasHovered != this.isHovered()) {
+                        if(this.isHovered()) {
+                            if(this.isFocused()) {
                                 this.nextNarration = Util.milliTime() + 200L;
                             } else {
                                 this.nextNarration = Util.milliTime() + 750L;
@@ -151,229 +156,295 @@ public class GuiNewControls extends ControlsScreen {
                             this.nextNarration = Long.MAX_VALUE;
                         }
                     }
-
-                    if (this.visible) {
+                    
+                    if(this.visible) {
                         this.renderButton(stack, mouseX, mouseY, partialTicks);
                     }
-
+                    
                     this.narrate();
                     this.wasHovered = this.isHovered();
                 }
             }
         });
         sortOrder = SortOrder.NONE;
-        Button buttonSort = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24 - 24, 150 / 2, 20, new TranslationTextComponent("options.sort").appendString(": " + sortOrder.getName()), (p_213126_1_) -> {
+        Button buttonSort = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24 - 24, 150 / 2, 20, new TranslationTextComponent("options.sort")
+                .appendString(": " + sortOrder.getName()), (p_213126_1_) -> {
             sortOrder = sortOrder.cycle();
             p_213126_1_.setMessage(new TranslationTextComponent("options.sort").appendString(": " + sortOrder.getName()));
             filterKeys();
         }));
+        
+        this.buttonFree = this.addButton(new Button(this.width / 2 - 155 + 76, this.height - 29, 74, 20, new TranslationTextComponent("options.toggleFree"), (p_213126_1_) -> {
+            this.children.remove(this.keyBindingList);
+            if(showFree) {
+                buttonSort.active = true;
+                buttonCat.active = true;
+                buttonKey.active = true;
+                buttonNone.active = true;
+                buttonConflicting.active = true;
+                buttonReset.active = true;
+                keyBindingList = customKeyList;
+            } else {
+                freeKeyList.recalculate();
+                buttonSort.active = false;
+                buttonCat.active = false;
+                buttonKey.active = false;
+                buttonNone.active = false;
+                buttonConflicting.active = false;
+                buttonReset.active = false;
+                keyBindingList = freeKeyList;
+            }
+            this.children.add(this.keyBindingList);
+            this.setListener(this.keyBindingList);
+            showFree = !showFree;
+        }));
+        
         lastSearch = "";
         displayMode = DisplayMode.ALL;
         searchType = SearchType.NAME;
-
+        //        InputMappings.Input.REGISTRY.values().stream().forEach(input -> {
+        //            System.out.println(input.func_237520_d_().getString() + " : " + input.getKeyCode());
+        //        });
     }
-
+    
     @Override
     public boolean charTyped(char var1, int var2) {
+        
         return search.charTyped(var1, var2);
     }
-
+    
     @Override
     public void tick() {
+        
         this.search.tick();
-        if (!lastSearch.equals(search.getText())) {
+        if(!lastSearch.equals(search.getText())) {
             filterKeys();
         }
     }
-
+    
     public void filterKeys() {
-
+        
         lastSearch = search.getText();
         keyBindingList.getEventListeners().clear();
-        if (lastSearch.isEmpty() && displayMode == DisplayMode.ALL && sortOrder == SortOrder.NONE) {
-            keyBindingList.getEventListeners().addAll(((GuiNewKeyBindingList) keyBindingList).getAllEntries());
-            return;
-        }
-        this.keyBindingList.setScrollAmount(0);
-        Predicate<GuiNewKeyBindingList.KeyEntry> filters = displayMode.getPredicate();
-
-
-        switch (searchType) {
-            case NAME:
-                filters = filters.and(keyEntry -> keyEntry.getKeyDesc().toLowerCase().contains(lastSearch.toLowerCase()));
-                break;
-            case CATEGORY:
-                filters = filters.and(keyEntry -> new TranslationTextComponent(keyEntry.getKeybinding().getKeyCategory()).getString().toLowerCase().contains(lastSearch.toLowerCase()));
-                break;
-            case KEY:
-                filters = filters.and(keyEntry -> keyEntry.getKeybinding().func_238171_j_().getString().toLowerCase().contains(lastSearch.toLowerCase()));
-                break;
-        }
-
-        for (GuiNewKeyBindingList.Entry entry : ((GuiNewKeyBindingList) keyBindingList).getAllEntries()) {
-            if (searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
-                if (entry instanceof GuiNewKeyBindingList.KeyEntry) {
-                    GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
-                    if (filters.test(keyEntry)) {
+        if(keyBindingList instanceof GuiNewKeyBindingList) {
+            
+            if(lastSearch.isEmpty() && displayMode == DisplayMode.ALL && sortOrder == SortOrder.NONE) {
+                keyBindingList.getEventListeners().addAll(((GuiCustomList) keyBindingList).getAllEntries());
+                return;
+            }
+            this.keyBindingList.setScrollAmount(0);
+            Predicate<GuiNewKeyBindingList.KeyEntry> filters = displayMode.getPredicate();
+            
+            
+            switch(searchType) {
+                case NAME:
+                    filters = filters.and(keyEntry -> keyEntry.getKeyDesc()
+                            .toLowerCase()
+                            .contains(lastSearch.toLowerCase()));
+                    break;
+                case CATEGORY:
+                    filters = filters.and(keyEntry -> new TranslationTextComponent(keyEntry.getKeybinding()
+                            .getKeyCategory()).getString().toLowerCase().contains(lastSearch.toLowerCase()));
+                    break;
+                case KEY:
+                    filters = filters.and(keyEntry -> keyEntry.getKeybinding()
+                            .func_238171_j_()
+                            .getString()
+                            .toLowerCase()
+                            .contains(lastSearch.toLowerCase()));
+                    break;
+            }
+            
+            for(GuiNewKeyBindingList.Entry entry : ((GuiCustomList) keyBindingList).getAllEntries()) {
+                if(searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
+                    if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
+                        GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
+                        if(filters.test(keyEntry)) {
+                            keyBindingList.getEventListeners().add(entry);
+                        }
+                    } else {
                         keyBindingList.getEventListeners().add(entry);
                     }
                 } else {
-                    keyBindingList.getEventListeners().add(entry);
-                }
-            } else {
-                if (entry instanceof GuiNewKeyBindingList.KeyEntry) {
-                    GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
-                    if (filters.test(keyEntry)) {
-                        keyBindingList.getEventListeners().add(entry);
+                    if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
+                        GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
+                        if(filters.test(keyEntry)) {
+                            keyBindingList.getEventListeners().add(entry);
+                        }
                     }
                 }
+                
             }
-
-        }
-        if (searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
-            Set<GuiNewKeyBindingList.CategoryEntry> categories = new LinkedHashSet<>();
-
-            for (KeyBindingList.Entry entry : keyBindingList.getEventListeners()) {
-                if (entry instanceof GuiNewKeyBindingList.CategoryEntry) {
-                    GuiNewKeyBindingList.CategoryEntry centry = (GuiNewKeyBindingList.CategoryEntry) entry;
-                    categories.add(centry);
-                    for (KeyBindingList.Entry child : keyBindingList.getEventListeners()) {
-                        if (child instanceof GuiNewKeyBindingList.KeyEntry) {
-                            GuiNewKeyBindingList.KeyEntry childEntry = (GuiNewKeyBindingList.KeyEntry) child;
-                            if (childEntry.getKeybinding().getKeyCategory().equals(centry.getName())) {
-                                categories.remove(centry);
+            if(searchType == SearchType.CATEGORY && sortOrder == SortOrder.NONE && displayMode == DisplayMode.ALL) {
+                Set<GuiNewKeyBindingList.CategoryEntry> categories = new LinkedHashSet<>();
+                
+                for(KeyBindingList.Entry entry : keyBindingList.getEventListeners()) {
+                    if(entry instanceof GuiNewKeyBindingList.CategoryEntry) {
+                        GuiNewKeyBindingList.CategoryEntry centry = (GuiNewKeyBindingList.CategoryEntry) entry;
+                        categories.add(centry);
+                        for(KeyBindingList.Entry child : keyBindingList.getEventListeners()) {
+                            if(child instanceof GuiNewKeyBindingList.KeyEntry) {
+                                GuiNewKeyBindingList.KeyEntry childEntry = (GuiNewKeyBindingList.KeyEntry) child;
+                                if(childEntry.getKeybinding().getKeyCategory().equals(centry.getName())) {
+                                    categories.remove(centry);
+                                }
                             }
                         }
                     }
                 }
+                keyBindingList.getEventListeners().removeAll(categories);
+            }
+            sortOrder.sort(keyBindingList.getEventListeners());
+            
+        } else if(keyBindingList instanceof GuiFreeKeysList) {
+            if(lastSearch.isEmpty()) {
+                keyBindingList.getEventListeners().addAll(((GuiCustomList) keyBindingList).getAllEntries());
+                return;
+            }
+            this.keyBindingList.setScrollAmount(0);
+            
+            for(GuiFreeKeysList.Entry entry : ((GuiCustomList) keyBindingList).getAllEntries()) {
+                if(entry instanceof GuiFreeKeysList.InputEntry) {
+                    GuiFreeKeysList.InputEntry inputEntry = (GuiFreeKeysList.InputEntry) entry;
+                    if(inputEntry.getInput().toString().toLowerCase().contains(lastSearch.toLowerCase())) {
+                        keyBindingList.getEventListeners().add(entry);
+                    }
+                } else {
+                    keyBindingList.getEventListeners().add(entry);
+                }
+                
             }
-            keyBindingList.getEventListeners().removeAll(categories);
         }
-        sortOrder.sort(keyBindingList.getEventListeners());
-
-
     }
-
+    
     /**
      * Draws the screen and all the components in it.
      */
     @Override
     public void render(MatrixStack stack, int mouseX, int mouseY, float partialTicks) {
+        
         this.renderBackground(stack);
         this.keyBindingList.render(stack, mouseX, mouseY, partialTicks);
         drawCenteredString(stack, this.font, this.title.getString(), this.width / 2, 8, 16777215);
         boolean flag = false;
-
-        for (KeyBinding keybinding : this.options.keyBindings) {
-            if (!keybinding.isDefault()) {
-                flag = true;
-                break;
+        
+        if(!showFree) {
+            for(KeyBinding keybinding : this.options.keyBindings) {
+                if(!keybinding.isDefault()) {
+                    flag = true;
+                    break;
+                }
             }
         }
         search.render(stack, mouseX, mouseY, partialTicks);
         this.buttonReset.active = flag;
-        if (!flag) {
+        if(!flag) {
             confirmingReset = false;
             buttonReset.setMessage(new TranslationTextComponent("controls.resetAll"));
         }
-        for (int i = 0; i < this.buttons.size(); ++i) {
+        for(int i = 0; i < this.buttons.size(); ++i) {
             this.buttons.get(i).render(stack, mouseX, mouseY, partialTicks);
         }
-
+        
         ITextComponent text = new TranslationTextComponent("options.search");
         font.func_238407_a_(stack, text.func_241878_f(), this.width / 2f - (155 / 2f) - (font.getStringWidth(text.getString())) - 5, this.height - 29 - 42, 16777215);
-
-        if (patreonButton.isHovered()) {
+        
+        if(patreonButton.isHovered()) {
             String str = "Join " + name + " and other patrons!";
             renderTooltip(stack, new StringTextComponent(str), mouseX, mouseY);
         }
     }
-
+    
     @Override
     public boolean mouseClicked(double mx, double my, int mb) {
+        
         boolean valid;
-        if (this.buttonId != null) {
+        if(this.buttonId != null) {
             this.options.setKeyBindingCode(this.buttonId, InputMappings.Type.MOUSE.getOrMakeInput(mb));
             this.buttonId = null;
             KeyBinding.resetKeyBindingArrayAndHash();
             valid = true;
             search.setFocused2(false);
-        } else if (mb == 0 && this.keyBindingList.mouseClicked(mx, my, mb)) {
+        } else if(mb == 0 && this.keyBindingList.mouseClicked(mx, my, mb)) {
             this.setDragging(true);
             this.setListener(this.keyBindingList);
             valid = true;
             search.setFocused2(false);
         } else {
             valid = search.mouseClicked(mx, my, mb);
-            if (!valid && search.isFocused() && mb == 1) {
+            if(!valid && search.isFocused() && mb == 1) {
                 search.setText("");
                 valid = true;
             }
         }
-
-        if (!valid) {
-
-            for (IGuiEventListener iguieventlistener : this.getEventListeners()) {
-                if (iguieventlistener.mouseClicked(mx, my, mb)) {
+        
+        if(!valid) {
+            
+            for(IGuiEventListener iguieventlistener : this.getEventListeners()) {
+                if(iguieventlistener.mouseClicked(mx, my, mb)) {
                     this.setListener(iguieventlistener);
-                    if (mb == 0) {
+                    if(mb == 0) {
                         this.setDragging(true);
                     }
-
+                    
                     return true;
                 }
             }
-
+            
             valid = true;
         }
-
-
+        
+        
         return valid;
     }
-
+    
     @Override
     public boolean mouseReleased(double mx, double my, int mb) {
-        if (mb == 0 && this.keyBindingList.mouseReleased(mx, my, mb)) {
+        
+        if(mb == 0 && this.keyBindingList.mouseReleased(mx, my, mb)) {
             this.setDragging(false);
             return true;
-        } else if (search.isFocused()) {
+        } else if(search.isFocused()) {
             return search.mouseReleased(mx, my, mb);
         } else {
             this.setDragging(false);
             return false;
         }
     }
-
+    
     @Override
     public boolean keyPressed(int keyCode, int scanCode, int modifier) {
-        if (!search.isFocused() && this.buttonId == null) {
-            if (hasControlDown()) {
-                if (InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_F)) {
+        
+        if(!search.isFocused() && this.buttonId == null) {
+            if(hasControlDown()) {
+                if(InputMappings.isKeyDown(Minecraft.getInstance().getMainWindow().getHandle(), GLFW.GLFW_KEY_F)) {
                     search.setFocused2(true);
                     return true;
                 }
             }
         }
-        if (search.keyPressed(keyCode, scanCode, modifier)) {
+        if(search.keyPressed(keyCode, scanCode, modifier)) {
             return true;
         }
-        if (search.isFocused()) {
-            if (keyCode == 256) {
+        if(search.isFocused()) {
+            if(keyCode == 256) {
                 search.setFocused2(false);
                 return true;
             }
         }
-        if (this.buttonId != null) {
-            if (keyCode == 256) {
+        if(this.buttonId != null) {
+            if(keyCode == 256) {
                 this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings.INPUT_INVALID);
                 this.options.setKeyBindingCode(this.buttonId, InputMappings.INPUT_INVALID);
             } else {
-                this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings.getInputByCode(keyCode, scanCode));
+                this.buttonId.setKeyModifierAndCode(net.minecraftforge.client.settings.KeyModifier.getActiveModifier(), InputMappings
+                        .getInputByCode(keyCode, scanCode));
                 this.options.setKeyBindingCode(this.buttonId, InputMappings.getInputByCode(keyCode, scanCode));
             }
-
-            if (!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.buttonId.getKey()))
+            
+            if(!net.minecraftforge.client.settings.KeyModifier.isKeyCodeModifier(this.buttonId.getKey())) {
                 this.buttonId = null;
+            }
             this.time = Util.milliTime();
             KeyBinding.resetKeyBindingArrayAndHash();
             return true;
@@ -381,6 +452,6 @@ public class GuiNewControls extends ControlsScreen {
             return super.keyPressed(keyCode, scanCode, modifier);
         }
     }
-
-
+    
+    
 }

+ 1 - 11
src/main/java/com/blamejared/controlling/client/gui/GuiNewKeyBindingList.java

@@ -17,12 +17,11 @@ import org.apache.commons.lang3.ArrayUtils;
 import java.util.*;
 
 @OnlyIn(Dist.CLIENT)
-public class GuiNewKeyBindingList extends KeyBindingList {
+public class GuiNewKeyBindingList extends GuiCustomList {
 
     private final ControlsScreen controlsScreen;
     private final Minecraft mc;
     private int maxListLabelWidth;
-    public List<Entry> allEntries;
 
     public GuiNewKeyBindingList(ControlsScreen controls, Minecraft mcIn) {
         super(controls, mcIn);
@@ -60,15 +59,6 @@ public class GuiNewKeyBindingList extends KeyBindingList {
     }
 
 
-    public List<Entry> getAllEntries() {
-        return allEntries;
-    }
-
-    public void add(Entry ent) {
-        getEventListeners().add(ent);
-        allEntries.add(ent);
-    }
-
     @Override
     protected int getScrollbarPosition() {
         return super.getScrollbarPosition() + 15 + 20;

+ 1 - 0
src/main/resources/META-INF/accesstransformer.cfg

@@ -1,2 +1,3 @@
 public net.minecraft.client.gui.screen.ControlsScreen field_146494_r # keyBindingList
 public net.minecraft.client.gui.screen.SettingsScreen field_228182_a_ # parentScreen
+public net.minecraft.client.util.InputMappings$Input field_199875_d # REGISTRY