码迷,mamicode.com
首页 > 其他好文 > 详细

Minecraft InputFix

时间:2015-09-24 11:13:55      阅读:206      评论:0      收藏:0      [点我收藏+]

标签:

  1. 环境

    MCP&eclipse

  2. InPutFix在MCP中的源码

    位置:net.minecraft.gui.GuiScreen
    InPutFix源码
    public void handleKeyboardInput() throws IOException
        {
            int k = Keyboard.getEventKey();
            char c = Keyboard.getEventCharacter();
    
            if (Keyboard.getEventKeyState() || k == 0 && Character.isDefined(c))
            {
                this.keyTyped(c, k);
            }
    
            this.mc.dispatchKeypresses();
        }
    Minecraft反编译源码
        /**
         * Handles keyboard input.
         */
        public void handleKeyboardInput() throws IOException
        {
            if (Keyboard.getEventKeyState())
            {
                this.keyTyped(Keyboard.getEventCharacter(), Keyboard.getEventKey());
            }
    
            this.mc.dispatchKeypresses();
        }

     keyboard是LWJGL库的类,文档:http://legacy.lwjgl.org/javadoc/;Character是Java库的类,文档:http://tool.oschina.net/apidocs/apidoc?api=jdk_7u4

    所以,InputFix添加了对字符的判断(按键event=0时),让字符也能被判断为输入内容


Minecraft InputFix

标签:

原文地址:http://my.oschina.net/wangyangdahai/blog/510502

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!