    001    package net.minecraft.client.settings;
    002
    003    import cpw.mods.fml.relauncher.Side;
    004    import cpw.mods.fml.relauncher.SideOnly;
    005    import java.util.ArrayList;
    006    import java.util.Iterator;
    007    import java.util.List;
    008    import net.minecraft.util.IntHashMap;
    009
    010    @SideOnly(Side.CLIENT)
    011    public class KeyBinding
    012    {
    013        public static List keybindArray = new ArrayList();
    014        public static IntHashMap hash = new IntHashMap();
    015        public String keyDescription;
    016        public int keyCode;
    017
    018        /** because _303 wanted me to call it that(Caironater) */
    019        public boolean pressed;
    020        public int pressTime = 0;
    021
    022        public static void onTick(int par0)
    023        {
    024            KeyBinding var1 = (KeyBinding)hash.lookup(par0);
    025
    026            if (var1 != null)
    027            {
    028                ++var1.pressTime;
    029            }
    030        }
    031
    032        public static void setKeyBindState(int par0, boolean par1)
    033        {
    034            KeyBinding var2 = (KeyBinding)hash.lookup(par0);
    035
    036            if (var2 != null)
    037            {
    038                var2.pressed = par1;
    039            }
    040        }
    041
    042        public static void unPressAllKeys()
    043        {
    044            Iterator var0 = keybindArray.iterator();
    045
    046            while (var0.hasNext())
    047            {
    048                KeyBinding var1 = (KeyBinding)var0.next();
    049                var1.unpressKey();
    050            }
    051        }
    052
    053        public static void resetKeyBindingArrayAndHash()
    054        {
    055            hash.clearMap();
    056            Iterator var0 = keybindArray.iterator();
    057
    058            while (var0.hasNext())
    059            {
    060                KeyBinding var1 = (KeyBinding)var0.next();
    061                hash.addKey(var1.keyCode, var1);
    062            }
    063        }
    064
    065        public KeyBinding(String par1Str, int par2)
    066        {
    067            this.keyDescription = par1Str;
    068            this.keyCode = par2;
    069            keybindArray.add(this);
    070            hash.addKey(par2, this);
    071        }
    072
    073        public boolean isPressed()
    074        {
    075            if (this.pressTime == 0)
    076            {
    077                return false;
    078            }
    079            else
    080            {
    081                --this.pressTime;
    082                return true;
    083            }
    084        }
    085
    086        private void unpressKey()
    087        {
    088            this.pressTime = 0;
    089            this.pressed = false;
    090        }
    091    }