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