Jared 6 éve
szülő
commit
d34be41736

+ 30 - 24
build.gradle

@@ -10,49 +10,55 @@ buildscript {
         classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true
     }
 }
+
 apply plugin: 'net.minecraftforge.gradle'
 apply plugin: 'eclipse'
 
-version = '4.0.1'
+version = '5.0.0'
 group = 'com.blamejared.controlling'
 archivesBaseName = 'Controlling'
 
 sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8'
 
 minecraft {
-    mappings channel: 'snapshot', version: '20180921-1.13'
+    mappings channel: 'snapshot', version: '20190608-1.14.2'
     runs {
-        client = {
-            // recommended logging data for a userdev environment
-            properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP'
-            // recommended logging level for the console
-            properties 'forge.logging.console.level': 'debug'
-            workingDirectory project.file('run').canonicalPath
-            source sourceSets.main
+        client {
+            workingDirectory project.file('run')
+            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
+            property 'forge.logging.console.level', 'debug'
+            mods {
+                examplemod {
+                    source sourceSets.main
+                }
+            }
         }
-        server = {
-            // recommended logging data for a userdev environment
-            properties 'forge.logging.markers': 'SCAN,REGISTRIES,REGISTRYDUMP'
-            // recommended logging level for the console
-            properties 'forge.logging.console.level': 'debug'
-            workingDirectory project.file('run').canonicalPath
-            source sourceSets.main
+        server {
+            workingDirectory project.file('run')
+            property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP'
+            property 'forge.logging.console.level', 'debug'
+            mods {
+                examplemod {
+                    source sourceSets.main
+                }
+            }
         }
     }
 }
 
 dependencies {
-    minecraft 'net.minecraftforge:forge:1.13.2-25.0.10'
+    minecraft 'net.minecraftforge:forge:1.14.2-26.0.6'
 }
 
 jar {
     manifest {
-        attributes(["Specification-Title"     : "controlling",
-                    "Specification-Vendor"    : "BlameJared",
-                    "Specification-Version"   : "24.0", // We are version 1 of the modlauncher specification
-                    "Implementation-Title"    : project.name,
-                    "Implementation-Version"  : "${version}",
-                    "Implementation-Vendor"   : "controlling",
-                    "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],)
+        attributes([
+                "Specification-Title"     : "controlling",
+                "Specification-Vendor"    : "BlameJared",
+                "Specification-Version"   : "1",
+                "Implementation-Title"    : project.name,
+                "Implementation-Version"  : "${version}",
+                "Implementation-Vendor"   : "controlling",
+                "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ")],)
     }
 }

+ 57 - 0
src/main/java/com/blamejared/controlling/client/gui/GuiCheckBox.java

@@ -0,0 +1,57 @@
+package com.blamejared.controlling.client.gui;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.widget.button.Button;
+import net.minecraftforge.fml.client.config.GuiUtils;
+
+/**
+ * This class provides a checkbox style control.
+ */
+public class GuiCheckBox extends Button {
+    
+    private boolean isChecked;
+    private int boxWidth;
+    
+    public GuiCheckBox(int xPos, int yPos, String displayString, boolean isChecked) {
+        super(xPos, yPos, Minecraft.getInstance().fontRenderer.getStringWidth(displayString) + 2 + 11, 11, displayString, b -> {
+        });
+        this.isChecked = isChecked;
+        this.boxWidth = 11;
+        this.height = 11;
+        this.width = this.boxWidth + 2 + Minecraft.getInstance().fontRenderer.getStringWidth(displayString);
+    }
+    
+    @Override
+    public void renderButton(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.boxWidth && mouseY < this.y + this.height;
+            GuiUtils.drawContinuousTexturedBox(WIDGETS_LOCATION, this.x, this.y, 0, 46, this.boxWidth, this.height, 200, 20, 2, 3, 2, 2, 500);
+            int color = 14737632;
+            
+            if(packedFGColor != 0) {
+                color = packedFGColor;
+            } else if(!this.active) {
+                color = 10526880;
+            }
+            
+            if(this.isChecked)
+                this.drawCenteredString(mc.fontRenderer, "x", this.x + this.boxWidth / 2 + 1, this.y + 1, 14737632);
+            
+            this.drawString(mc.fontRenderer, getMessage(), this.x + this.boxWidth + 2, this.y + 2, color);
+        }
+    }
+    
+    @Override
+    public void onPress() {
+        this.isChecked = !this.isChecked;
+    }
+    
+    public boolean isChecked() {
+        return this.isChecked;
+    }
+    
+    public void setIsChecked(boolean isChecked) {
+        this.isChecked = isChecked;
+    }
+}

+ 79 - 123
src/main/java/com/blamejared/controlling/client/gui/GuiNewControls.java

@@ -2,41 +2,40 @@ package com.blamejared.controlling.client.gui;
 
 import net.minecraft.client.GameSettings;
 import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.screen.*;
+import net.minecraft.client.gui.widget.*;
+import net.minecraft.client.gui.widget.button.*;
 import net.minecraft.client.resources.I18n;
-import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.client.settings.*;
 import net.minecraft.client.util.InputMappings;
 import net.minecraft.util.Util;
 import net.minecraftforge.api.distmarker.*;
-import net.minecraftforge.fml.client.config.GuiCheckBox;
 
-import java.util.Iterator;
 import java.util.function.Predicate;
 
 @OnlyIn(Dist.CLIENT)
-public class GuiNewControls extends GuiControls {
-    
-    private static final GameSettings.Options[] OPTIONS_ARR = new GameSettings.Options[]{GameSettings.Options.INVERT_MOUSE, GameSettings.Options.SENSITIVITY, GameSettings.Options.TOUCHSCREEN, GameSettings.Options.AUTO_JUMP};
+public class GuiNewControls extends ControlsScreen {
     
     private GuiNewKeyBindingList keyBindingList;
-    private GuiButton buttonReset;
-    private final GuiScreen parentScreen;
+    private Button buttonReset;
+    private final Screen parentScreen;
     private final GameSettings options;
     
     private String lastSearch;
-    private GuiTextField search;
+    private TextFieldWidget search;
     
     private DisplayMode displayMode;
     private SearchType searchType;
     private SortOrder sortOrder;
     
-    private GuiButton buttonNone;
-    private GuiButton buttonConflicting;
+    private Button buttonNone;
+    private Button buttonConflicting;
     private GuiCheckBox buttonKey;
     private GuiCheckBox buttonCat;
     
-    private GuiButton buttonSort;
+    private Button buttonSort;
     
-    public GuiNewControls(GuiScreen screen, GameSettings settings) {
+    public GuiNewControls(Screen screen, GameSettings settings) {
         super(screen, settings);
         this.parentScreen = screen;
         this.options = settings;
@@ -46,60 +45,50 @@ public class GuiNewControls extends GuiControls {
      * 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 initGui() {
-        this.keyBindingList = new GuiNewKeyBindingList(this, this.mc);
+    protected void init() {
+        
+        this.addButton(new Button(this.width / 2 - 155, 18, 150, 20, I18n.format("options.mouse_settings"), (p_213126_1_) -> {
+            this.minecraft.displayGuiScreen(new MouseSettingsScreen(this));
+        }));
+        this.addButton(AbstractOption.field_216719_z.func_216586_a(this.minecraft.gameSettings, this.width / 2 - 155 + 160, 18, 150));
+        
+        this.keyBindingList = new GuiNewKeyBindingList(this, this.minecraft);
         this.children.add(this.keyBindingList);
         this.setFocused(this.keyBindingList);
-        this.addButton(new GuiButton(200, this.width / 2 - 155 + 160, this.height - 29, 150, 20, I18n.format("gui.done")) {
-            /**
-             * Called when the left mouse button is pressed over this button. This method is specific to GuiButton.
-             */
-            public void onClick(double mouseX, double mouseY) {
-                GuiNewControls.this.mc.displayGuiScreen(GuiNewControls.this.parentScreen);
-            }
-        });
-        this.buttonReset = this.addButton(new GuiButton(201, this.width / 2 - 155, this.height - 29, 150, 20, I18n.format("controls.resetAll")) {
-            /**
-             * Called when the left mouse button is pressed over this button. This method is specific to GuiButton.
-             */
-            public void onClick(double mouseX, double mouseY) {
-                for(KeyBinding keybinding : GuiNewControls.this.mc.gameSettings.keyBindings) {
-                    keybinding.setToDefault();
-                }
-                
-                KeyBinding.resetKeyBindingArrayAndHash();
+        this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29, 150, 20, I18n.format("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, I18n.format("controls.resetAll"), (p_213126_1_) -> {
+            
+            for(KeyBinding keybinding : GuiNewControls.this.minecraft.gameSettings.keyBindings) {
+                keybinding.setToDefault();
             }
-        });
-        this.buttonNone = this.addButton(new GuiButton(2907, this.width / 2 - 155 + 160 + 76, this.height - 29 - 24, 150 / 2, 20, "Show Unbound"/*I18n.translate("options.showNone")*/) {
-            @Override
-            public void onClick(double mouseX, double mouseY) {
-                if(displayMode == DisplayMode.NONE) {
-                    buttonNone.displayString = I18n.format("options.showNone");
-                    displayMode = DisplayMode.ALL;
-                } else {
-                    displayMode = DisplayMode.NONE;
-                    buttonNone.displayString = I18n.format("options.showAll");
-                    buttonConflicting.displayString = I18n.format("options.showConflicts");
-                }
-                filterKeys();
+            
+            KeyBinding.resetKeyBindingArrayAndHash();
+        }));
+        this.buttonNone = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24, 150 / 2, 20, I18n.format("options.showNone"), (p_213126_1_) -> {
+            if(displayMode == DisplayMode.NONE) {
+                buttonNone.setMessage(I18n.format("options.showNone"));
+                displayMode = DisplayMode.ALL;
+            } else {
+                displayMode = DisplayMode.NONE;
+                buttonNone.setMessage(I18n.format("options.showAll"));
+                buttonConflicting.setMessage(I18n.format("options.showConflicts"));
             }
-        });
-        this.buttonConflicting = this.addButton(new GuiButton(2906, this.width / 2 - 155 + 160, this.height - 29 - 24, 150 / 2, 20, "Show Conflicts"/*I18n.translate("options.showConflicts")*/) {
-            @Override
-            public void onClick(double mouseX, double mouseY) {
-                if(displayMode == DisplayMode.CONFLICTING) {
-                    buttonConflicting.displayString = I18n.format("options.showConflicts");
-                    displayMode = DisplayMode.ALL;
-                } else {
-                    displayMode = DisplayMode.CONFLICTING;
-                    buttonConflicting.displayString = "Show All";
-                    buttonNone.displayString = I18n.format("options.showNone");
-                }
-                filterKeys();
+            filterKeys();
+        }));
+        this.buttonConflicting = this.addButton(new Button(this.width / 2 - 155 + 160, this.height - 29 - 24, 150 / 2, 20, I18n.format("options.showConflicts"), (p_213126_1_) -> {
+            if(displayMode == DisplayMode.CONFLICTING) {
+                buttonConflicting.setMessage(I18n.format("options.showConflicts"));
+                displayMode = DisplayMode.ALL;
+            } else {
+                displayMode = DisplayMode.CONFLICTING;
+                buttonConflicting.setMessage("Show All");
+                buttonNone.setMessage(I18n.format("options.showNone"));
             }
-        });
-        search = new GuiTextField(0, fontRenderer, this.width / 2 - 154, this.height - 29 - 23, 148, 18);
-        this.buttonKey = this.addButton(new GuiCheckBox(2908, this.width / 2 - (155 / 2) + 20, this.height - 29 - 37, I18n.format("options.key"), false) {
+            filterKeys();
+        }));
+        search = new TextFieldWidget(font, this.width / 2 - 154, this.height - 29 - 23, 148, 18, "");
+        this.buttonKey = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2) + 20, this.height - 29 - 37, I18n.format("options.key"), false) {
             @Override
             public void onClick(double mouseX, double mouseY) {
                 super.onClick(mouseX, mouseY);
@@ -108,7 +97,7 @@ public class GuiNewControls extends GuiControls {
                 filterKeys();
             }
         });
-        this.buttonCat = this.addButton(new GuiCheckBox(2909, this.width / 2 - (155 / 2) + 20, this.height - 29 - 50, I18n.format("options.category"), false) {
+        this.buttonCat = this.addButton(new GuiCheckBox(this.width / 2 - (155 / 2) + 20, this.height - 29 - 50, I18n.format("options.category"), false) {
             @Override
             public void onClick(double mouseX, double mouseY) {
                 super.onClick(mouseX, mouseY);
@@ -118,34 +107,11 @@ public class GuiNewControls extends GuiControls {
             }
         });
         sortOrder = SortOrder.NONE;
-        this.buttonSort = this.addButton(new GuiButton(2910, this.width / 2 - 155 + 160 + 76, this.height - 29 - 24 - 24, 150 / 2, 20, I18n.format("options.sort") + ": " + sortOrder.getName()) {
-            @Override
-            public void onClick(double mouseX, double mouseY) {
-                super.onClick(mouseX, mouseY);
-                sortOrder = sortOrder.cycle();
-                this.displayString = I18n.format("options.sort") + ": " + sortOrder.getName();
-                filterKeys();
-            }
-        });
-        this.screenTitle = I18n.format("controls.title");
-        int i = 0;
-        
-        for(GameSettings.Options gamesettings$options : GuiNewControls.OPTIONS_ARR) {
-            if(gamesettings$options.isFloat()) {
-                this.addButton(new GuiOptionSlider(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), gamesettings$options));
-            } else {
-                this.addButton(new GuiOptionButton(gamesettings$options.getOrdinal(), this.width / 2 - 155 + i % 2 * 160, 18 + 24 * (i >> 1), gamesettings$options, this.options.getKeyBinding(gamesettings$options)) {
-                    public void onClick(double mouseX, double mouseY) {
-                        GuiNewControls.this.options.setOptionValue(this.getOption(), 1);
-                        this.displayString = GuiNewControls.this.options.getKeyBinding(GameSettings.Options.byOrdinal(this.id));
-                    }
-                });
-            }
-            
-            ++i;
-        }
-        
-        
+        this.buttonSort = this.addButton(new Button(this.width / 2 - 155 + 160 + 76, this.height - 29 - 24 - 24, 150 / 2, 20, I18n.format("options.sort") + ": " + sortOrder.getName(), (p_213126_1_) -> {
+            sortOrder = sortOrder.cycle();
+            p_213126_1_.setMessage(I18n.format("options.sort") + ": " + sortOrder.getName());
+            filterKeys();
+        }));
         lastSearch = "";
         displayMode = DisplayMode.ALL;
         searchType = SearchType.NAME;
@@ -166,9 +132,9 @@ public class GuiNewControls extends GuiControls {
     
     public void filterKeys() {
         lastSearch = search.getText();
-        keyBindingList.getChildren().clear();
+        keyBindingList.children().clear();
         if(lastSearch.isEmpty() && displayMode == DisplayMode.ALL && sortOrder == SortOrder.NONE) {
-            keyBindingList.getChildren().addAll(keyBindingList.getAllEntries());
+            keyBindingList.children().addAll(keyBindingList.getAllEntries());
             return;
         }
         Predicate<GuiNewKeyBindingList.KeyEntry> filters = displayMode.getPredicate();
@@ -182,7 +148,7 @@ public class GuiNewControls extends GuiControls {
                 filters = filters.and(keyEntry -> keyEntry.getKeybinding().getKeyCategory().toLowerCase().contains(lastSearch.toLowerCase()));
                 break;
             case KEY:
-                filters = filters.and(keyEntry -> keyEntry.getKeybinding().getKey().getName().toLowerCase().contains(lastSearch.toLowerCase()));
+                filters = filters.and(keyEntry -> keyEntry.getKeybinding().getKey().getTranslationKey().toLowerCase().contains(lastSearch.toLowerCase()));
                 break;
         }
         
@@ -190,11 +156,11 @@ public class GuiNewControls extends GuiControls {
             if(entry instanceof GuiNewKeyBindingList.KeyEntry) {
                 GuiNewKeyBindingList.KeyEntry keyEntry = (GuiNewKeyBindingList.KeyEntry) entry;
                 if(filters.test(keyEntry)) {
-                    keyBindingList.getChildren().add(entry);
+                    keyBindingList.children().add(entry);
                 }
             }
         }
-        sortOrder.sort(keyBindingList.getChildren());
+        sortOrder.sort(keyBindingList.children());
         
         
     }
@@ -203,29 +169,25 @@ public class GuiNewControls extends GuiControls {
      * Draws the screen and all the components in it.
      */
     public void render(int mouseX, int mouseY, float partialTicks) {
-        this.drawDefaultBackground();
-        this.keyBindingList.drawScreen(mouseX, mouseY, partialTicks);
-        this.drawCenteredString(this.fontRenderer, this.screenTitle, this.width / 2, 8, 16777215);
+        this.renderBackground();
+        this.keyBindingList.render(mouseX, mouseY, partialTicks);
+        this.drawCenteredString(this.font, this.title.getFormattedText(), this.width / 2, 8, 16777215);
         boolean flag = false;
         
         for(KeyBinding keybinding : this.options.keyBindings) {
-            if(!keybinding.func_197985_l()) {
+            if(!keybinding.isDefault()) {
                 flag = true;
                 break;
             }
         }
-        search.drawTextField(mouseX, mouseY, partialTicks);
-        this.buttonReset.enabled = flag;
+        search.render(mouseX, mouseY, partialTicks);
+        this.buttonReset.active = flag;
         for(int i = 0; i < this.buttons.size(); ++i) {
             this.buttons.get(i).render(mouseX, mouseY, partialTicks);
         }
         
-        for(int j = 0; j < this.labels.size(); ++j) {
-            this.labels.get(j).render(mouseX, mouseY, partialTicks);
-            
-        }
         String text = I18n.format("options.search");
-        fontRenderer.drawString(text, this.width / 2 - (155 / 2) - (fontRenderer.getStringWidth(text) / 2), this.height - 29 - 39, 16777215);
+        font.drawString(text, this.width / 2 - (155 / 2) - (font.getStringWidth(text) / 2), this.height - 29 - 39, 16777215);
     }
     
     public boolean mouseClicked(double mx, double my, int mb) {
@@ -251,27 +213,21 @@ public class GuiNewControls extends GuiControls {
         
         if(!valid) {
             
-            Iterator childIter = this.getChildren().iterator();
-            
-            IGuiEventListener listener;
-            boolean clicked;
-            do
-            {
-                if(!childIter.hasNext()) {
-                    return false;
+            for(IGuiEventListener iguieventlistener : this.children()) {
+                if(iguieventlistener.mouseClicked(mx, my, mb)) {
+                    this.setFocused(iguieventlistener);
+                    if(mb == 0) {
+                        this.setDragging(true);
+                    }
+                    
+                    return true;
                 }
-                
-                listener = (IGuiEventListener) childIter.next();
-                clicked = listener.mouseClicked(mx, my, mb);
-            } while(!clicked);
-            
-            this.focusOn(listener);
-            if(mb == 0) {
-                this.setDragging(true);
             }
             
             valid = true;
         }
+        
+        
         return valid;
     }
     

+ 66 - 34
src/main/java/com/blamejared/controlling/client/gui/GuiNewKeyBindingList.java

@@ -1,24 +1,29 @@
 package com.blamejared.controlling.client.gui;
 
+import com.google.common.collect.ImmutableList;
 import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.IGuiEventListener;
+import net.minecraft.client.gui.screen.ControlsScreen;
+import net.minecraft.client.gui.widget.button.Button;
+import net.minecraft.client.gui.widget.list.*;
 import net.minecraft.client.resources.I18n;
 import net.minecraft.client.settings.KeyBinding;
+import net.minecraft.util.text.TextFormatting;
 import net.minecraftforge.api.distmarker.*;
 import org.apache.commons.lang3.ArrayUtils;
 
 import java.util.*;
 
 @OnlyIn(Dist.CLIENT)
-public class GuiNewKeyBindingList extends GuiListExtended<GuiNewKeyBindingList.Entry> {
+public class GuiNewKeyBindingList extends AbstractOptionList<GuiNewKeyBindingList.Entry> {
     
-    private final GuiControls controlsScreen;
+    private final ControlsScreen controlsScreen;
     private final Minecraft mc;
     private int maxListLabelWidth;
     public List<Entry> allEntries;
     
-    public GuiNewKeyBindingList(GuiControls controls, Minecraft mcIn) {
-        super(mcIn, controls.width + 45, controls.height, 63, controls.height - 80, 20);
+    public GuiNewKeyBindingList(ControlsScreen controls, Minecraft mcIn) {
+        super(mcIn, controls.width + 45, controls.height, 43, controls.height - 80, 20);
         this.controlsScreen = controls;
         this.mc = mcIn;
         allEntries = new ArrayList<>();
@@ -53,15 +58,12 @@ public class GuiNewKeyBindingList extends GuiListExtended<GuiNewKeyBindingList.E
         allEntries.add(ent);
     }
     
-    protected int getScrollBarX() {
-        return super.getScrollBarX() + 35;
+    protected int getScrollbarPosition() {
+        return super.getScrollbarPosition() + 15 + 20;
     }
     
-    /**
-     * Gets the width of the list
-     */
-    public int getListWidth() {
-        return super.getListWidth() + 32;
+    public int getRowWidth() {
+        return super.getRowWidth() + 32;
     }
     
     @OnlyIn(Dist.CLIENT)
@@ -75,13 +77,19 @@ public class GuiNewKeyBindingList extends GuiListExtended<GuiNewKeyBindingList.E
             this.labelWidth = GuiNewKeyBindingList.this.mc.fontRenderer.getStringWidth(this.labelText);
         }
         
-        public void drawEntry(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) {
-            GuiNewKeyBindingList.this.mc.fontRenderer.drawString(this.labelText, (float) (GuiNewKeyBindingList.this.mc.currentScreen.width / 2 - this.labelWidth / 2), (float) (this.getY() + entryHeight - GuiNewKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT - 1), 16777215);
+        
+        @Override
+        public List<? extends IGuiEventListener> children() {
+            return ImmutableList.of();
+        }
+        
+        public void render(int p_render_1_, int p_render_2_, int p_render_3_, int p_render_4_, int p_render_5_, int p_render_6_, int p_render_7_, boolean p_render_8_, float p_render_9_) {
+            GuiNewKeyBindingList.this.minecraft.fontRenderer.drawString(this.labelText, (float) (GuiNewKeyBindingList.this.minecraft.field_71462_r.width / 2 - this.labelWidth / 2), (float) (p_render_2_ + p_render_5_ - 9 - 1), 16777215);
         }
     }
     
     @OnlyIn(Dist.CLIENT)
-    public abstract static class Entry extends GuiListExtended.IGuiListEntry<GuiNewKeyBindingList.Entry> {}
+    public abstract static class Entry extends AbstractOptionList.Entry<GuiNewKeyBindingList.Entry> {}
     
     @OnlyIn(Dist.CLIENT)
     public class KeyEntry extends GuiNewKeyBindingList.Entry {
@@ -94,54 +102,76 @@ public class GuiNewKeyBindingList extends GuiListExtended<GuiNewKeyBindingList.E
          * The localized key description for this KeyEntry
          */
         private final String keyDesc;
-        private final GuiButton btnChangeKeyBinding;
+        private final Button btnChangeKeyBinding;
+        private final Button btnResetKeyBinding;
+        
         
         private KeyEntry(final KeyBinding name) {
             this.keybinding = name;
             this.keyDesc = I18n.format(name.getKeyDescription());
-            this.btnChangeKeyBinding = new GuiButton(0, 0, 0, 95, 20, I18n.format(name.func_197978_k())) {
-                /**
-                 * Called when the left mouse button is pressed over this button. This method is specific to GuiButton.
-                 */
-                public void onClick(double mouseX, double mouseY) {
-                    GuiNewKeyBindingList.this.controlsScreen.buttonId = name;
+            this.btnChangeKeyBinding = new Button(0, 0, 75 + 20 /*Forge: add space*/, 20, this.keyDesc, (p_214386_2_) -> {
+                GuiNewKeyBindingList.this.controlsScreen.buttonId = name;
+            }) {
+                protected String getNarrationMessage() {
+                    return name.isInvalid() ? I18n.format("narrator.controls.unbound", GuiNewKeyBindingList.KeyEntry.this.keyDesc) : I18n.format("narrator.controls.bound", GuiNewKeyBindingList.KeyEntry.this.keyDesc, super.getNarrationMessage());
+                }
+            };
+            this.btnResetKeyBinding = new Button(0, 0, 50, 20, I18n.format("controls.reset"), (p_214387_2_) -> {
+                keybinding.setToDefault();
+                GuiNewKeyBindingList.this.minecraft.gameSettings.setKeyBindingCode(name, name.getDefault());
+                KeyBinding.resetKeyBindingArrayAndHash();
+            }) {
+                protected String getNarrationMessage() {
+                    return I18n.format("narrator.controls.reset", GuiNewKeyBindingList.KeyEntry.this.keyDesc);
                 }
             };
         }
         
-        public void drawEntry(int entryWidth, int entryHeight, int mouseX, int mouseY, boolean p_194999_5_, float partialTicks) {
-            int i = this.getY();
-            int j = this.getX();
+        @Override
+        public void render(int p_render_1_, int p_render_2_, int p_render_3_, int p_render_4_, int p_render_5_, int p_render_6_, int p_render_7_, boolean p_render_8_, float p_render_9_) {
+            int i = p_render_2_;
+            int j = p_render_3_;
             boolean flag = GuiNewKeyBindingList.this.controlsScreen.buttonId == this.keybinding;
-            GuiNewKeyBindingList.this.mc.fontRenderer.drawString(this.keyDesc, (float) (j + 90 - GuiNewKeyBindingList.this.maxListLabelWidth), (float) (i + entryHeight / 2 - GuiNewKeyBindingList.this.mc.fontRenderer.FONT_HEIGHT / 2), 16777215);
+            GuiNewKeyBindingList.this.mc.fontRenderer.drawString(this.keyDesc, (float) (j + 90 - GuiNewKeyBindingList.this.maxListLabelWidth), (float)(p_render_2_ + p_render_5_ / 2 - 9 / 2), 16777215);
+            this.btnResetKeyBinding.x = p_render_3_ + 190 + 20;
+            this.btnResetKeyBinding.y = p_render_2_;
+            this.btnResetKeyBinding.active = !this.keybinding.isDefault();
+            this.btnResetKeyBinding.render(p_render_6_, p_render_7_, p_render_9_);
+            
+            
             this.btnChangeKeyBinding.x = j + 105;
             this.btnChangeKeyBinding.y = i;
-            this.btnChangeKeyBinding.displayString = this.keybinding.func_197978_k();
+            this.btnChangeKeyBinding.setMessage(this.keybinding.getLocalizedName());
+            
             boolean flag1 = false;
             boolean keyCodeModifierConflict = true; // less severe form of conflict, like SHIFT conflicting with SHIFT+G
             if(!this.keybinding.isInvalid()) {
                 for(KeyBinding keybinding : GuiNewKeyBindingList.this.mc.gameSettings.keyBindings) {
-                    if(keybinding != this.keybinding && this.keybinding.func_197983_b(keybinding)) {
+                    if(keybinding != this.keybinding && this.keybinding.conflicts(keybinding)) {
                         flag1 = true;
                         keyCodeModifierConflict &= keybinding.hasKeyCodeModifierConflict(this.keybinding);
                     }
                 }
             }
-            //TODO replace with text formatting when it's fixed
             if(flag) {
-                this.btnChangeKeyBinding.displayString = "§f" + "> " + "§e" + this.btnChangeKeyBinding.displayString + "§f" + " <";
+                this.btnChangeKeyBinding.setMessage(TextFormatting.WHITE + "> " + TextFormatting.YELLOW + this.btnChangeKeyBinding.getMessage() + TextFormatting.WHITE + " <");
             } else if(flag1) {
-                this.btnChangeKeyBinding.displayString = (keyCodeModifierConflict ? "§6" : "§c") + this.btnChangeKeyBinding.displayString;
+                this.btnChangeKeyBinding.setMessage((keyCodeModifierConflict ? TextFormatting.GOLD : TextFormatting.RED) + this.btnChangeKeyBinding.getMessage());
             }
             
-            this.btnChangeKeyBinding.render(mouseX, mouseY, partialTicks);
+            this.btnChangeKeyBinding.render(p_render_6_, p_render_7_, p_render_9_);
+        }
+        
+        public List<? extends IGuiEventListener> children() {
+            return ImmutableList.of(this.btnChangeKeyBinding, this.btnResetKeyBinding);
         }
         
         public boolean mouseClicked(double p_mouseClicked_1_, double p_mouseClicked_3_, int p_mouseClicked_5_) {
             if(this.btnChangeKeyBinding.mouseClicked(p_mouseClicked_1_, p_mouseClicked_3_, p_mouseClicked_5_)) {
                 return true;
+            } else {
+                return this.btnResetKeyBinding.mouseClicked(p_mouseClicked_1_, p_mouseClicked_3_, p_mouseClicked_5_);
             }
-            return false;
         }
         
         public boolean mouseReleased(double p_mouseReleased_1_, double p_mouseReleased_3_, int p_mouseReleased_5_) {
@@ -156,8 +186,10 @@ public class GuiNewKeyBindingList extends GuiListExtended<GuiNewKeyBindingList.E
             return keyDesc;
         }
         
-        public GuiButton getBtnChangeKeyBinding() {
+        public Button getBtnChangeKeyBinding() {
             return btnChangeKeyBinding;
         }
+        
+        
     }
 }

+ 19 - 6
src/main/java/com/blamejared/controlling/events/ClientEventHandler.java

@@ -2,9 +2,13 @@ package com.blamejared.controlling.events;
 
 import com.blamejared.controlling.client.gui.GuiNewControls;
 import net.minecraft.client.Minecraft;
-import net.minecraft.client.gui.*;
+import net.minecraft.client.gui.screen.*;
+import net.minecraft.client.renderer.model.IBakedModel;
+import net.minecraft.item.Item;
+import net.minecraft.world.World;
 import net.minecraftforge.client.event.GuiOpenEvent;
 import net.minecraftforge.eventbus.api.SubscribeEvent;
+import net.minecraftforge.fml.client.config.GuiUtils;
 
 import java.lang.reflect.Field;
 
@@ -12,12 +16,21 @@ public class ClientEventHandler {
     
     @SubscribeEvent
     public void openGui(GuiOpenEvent event) {
+        World w;
         try {
-            if(event.getGui() instanceof GuiControls && !(event.getGui() instanceof GuiNewControls)) {
-                GuiControls gui = (GuiControls) event.getGui();
-                Field field = gui.getClass().getDeclaredField("parentScreen");
-                field.setAccessible(true);
-                event.setGui(new GuiNewControls((GuiScreen) field.get(gui), Minecraft.getInstance().gameSettings));
+            if(event.getGui() instanceof ControlsScreen && !(event.getGui() instanceof GuiNewControls)) {
+                ControlsScreen gui = (ControlsScreen) event.getGui();
+                Field parent = null;
+                for(Field field : gui.getClass().getDeclaredFields()) {
+                    if(field.getType() == Screen.class) {
+                        parent = field;
+                    }
+                }
+                if(parent == null) {
+                    return;
+                }
+                parent.setAccessible(true);
+                event.setGui(new GuiNewControls((Screen) parent.get(gui), Minecraft.getInstance().gameSettings));
             }
         } catch(Exception e) {
             e.printStackTrace();

+ 2 - 18
src/main/resources/META-INF/mods.toml

@@ -1,39 +1,23 @@
-# This is an example mods.toml file. It contains the data relating to the loading mods.
-# There are several mandatory fields (#mandatory), and many more that are optional (#optional).
-# The overall format is standard TOML format, v0.5.0.
-# Note that there are a couple of TOML lists in this file.
-# Find more information on toml format here:  https://github.com/toml-lang/toml
-# The name of the mod loader type to load - for regular FML @Mod mods it should be javafml
 modLoader="javafml" #mandatory
-# A version range to match for said mod loader - for regular FML @Mod it will be the minecraft version (without the 1.)
-loaderVersion="[24,)" #mandatory
-# A URL to refer people to when problems occur with this mod
+loaderVersion="[25,)" #mandatory
 issueTrackerURL="https://github.com/jaredlll08/Controlling/issues" #optional
-# A URL for the "homepage" for this mod, displayed in the mod UI
 displayURL="https://minecraft.curseforge.com/projects/controlling" #optional
-# A text field displayed in the mod UI
 authors="Jaredlll08" #optional
-# A list of mods - how many allowed here is determined by the individual mod loader
 [[mods]] #mandatory
-# The modid of the mod
 modId="controlling" #mandatory
-# The version number of the mod - there's a few well known ${} variables useable here or just hardcode it
 version="4.0.0" #mandatory
- # A display name for the mod
 displayName="Controlling" #mandatory
-# The description text for the mod (multi line!) (#mandatory)
 description='''
 Adds the ability to search for keybinds using their name in the KeyBinding menu, this allows players to easily find a key binding in the menu.
 '''
 
-# A dependency - use the . to indicate dependency for a specific modid. Dependencies are optional.
 [[dependencies.controlling]] #optional
     # the modid of the dependency
     modId="forge" #mandatory
     # Does this dependency have to exist - if not, ordering below must be specified
     mandatory=true #mandatory
     # The version range of the dependency
-    versionRange="[24,)" #mandatory
+    versionRange="[25,)" #mandatory
     # An ordering relationship for the dependency - BEFORE or AFTER required if the relationship is not mandatory
     ordering="NONE"
     # Side this dependency is applied on - BOTH, CLIENT or SERVER