diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-01-20 15:21:10 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-01-20 15:21:10 +0800 |
| commit | 855f72d9f730ce54be6167259f33bf1785b140fb (patch) | |
| tree | 7a12beed35ee2466c75c85eab3b3edc90240f53a /src/main/java/me/shedaniel/rei/client/KeyBindHelper.java | |
| parent | 277a10844312a2d8310875cfbd4205772a11445b (diff) | |
| download | RoughlyEnoughItems-2.0.0.11.tar.gz RoughlyEnoughItems-2.0.0.11.tar.bz2 RoughlyEnoughItems-2.0.0.11.zip | |
Fixes malilib crash *sighs*v2.0.0.11
Diffstat (limited to 'src/main/java/me/shedaniel/rei/client/KeyBindHelper.java')
| -rw-r--r-- | src/main/java/me/shedaniel/rei/client/KeyBindHelper.java | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/main/java/me/shedaniel/rei/client/KeyBindHelper.java b/src/main/java/me/shedaniel/rei/client/KeyBindHelper.java new file mode 100644 index 000000000..65ce788a1 --- /dev/null +++ b/src/main/java/me/shedaniel/rei/client/KeyBindHelper.java @@ -0,0 +1,42 @@ +package me.shedaniel.rei.client; + +import com.google.common.collect.Lists; +import me.shedaniel.rei.RoughlyEnoughItemsCore; +import me.shedaniel.rei.listeners.IMixinKeyBinding; +import net.minecraft.client.settings.KeyBinding; +import net.minecraft.client.util.InputMappings; +import net.minecraft.util.ResourceLocation; +import org.dimdev.rift.listener.client.KeyBindingAdder; + +import java.util.Collection; +import java.util.List; + +public class KeyBindHelper implements KeyBindingAdder { + + private static final ResourceLocation RECIPE_KEYBIND = new ResourceLocation("roughlyenoughitems", "recipe_keybind"); + private static final ResourceLocation USAGE_KEYBIND = new ResourceLocation("roughlyenoughitems", "usage_keybind"); + private static final ResourceLocation HIDE_KEYBIND = new ResourceLocation("roughlyenoughitems", "hide_keybind"); + public static KeyBinding RECIPE, USAGE, HIDE; + + @Override + public Collection<? extends KeyBinding> getKeyBindings() { + String category = "key.rei.category"; + List<KeyBinding> keyBindings = Lists.newArrayList(); + keyBindings.add(RECIPE = createKeyBinding(RECIPE_KEYBIND, InputMappings.Type.KEYSYM, 82, category)); + keyBindings.add(USAGE = createKeyBinding(USAGE_KEYBIND, InputMappings.Type.KEYSYM, 85, category)); + keyBindings.add(HIDE = createKeyBinding(HIDE_KEYBIND, InputMappings.Type.KEYSYM, 79, category)); + addCategoryIfMissing(RECIPE, category); + return keyBindings; + } + + private void addCategoryIfMissing(KeyBinding keyBinding, String category) { + if (!((IMixinKeyBinding) keyBinding).hasCategory(category)) + ((IMixinKeyBinding) keyBinding).addCategory(category); + } + + private KeyBinding createKeyBinding(ResourceLocation location, InputMappings.Type inputType, int keyCode, String category) { + RoughlyEnoughItemsCore.LOGGER.info("Registering: key." + location.toString().replaceAll(":", ".") + " in " + category); + return new KeyBinding("key." + location.toString().replaceAll(":", "."), inputType, keyCode, category); + } + +} |
