0

私が欲しいのは、Oを押したときにF3を押すフォージmodを作ることだけです

これは、KeyBindings.java を持っている 2 つのクラス ファイルです。

package com.example.examplemod;
import cpw.mods.fml.client.registry.ClientRegistry;
import net.minecraft.client.settings.KeyBinding;

public class KeyBindings {

    // Declare two KeyBindings, ping and pong
    public static KeyBinding ping;

    public static void init() {
        // Define the "ping" binding, with (unlocalized) name "key.ping" and
        // the category with (unlocalized) name "key.categories.mymod" and
        // key code 24 ("O", LWJGL constant: Keyboard.KEY_O)
        ping = new KeyBinding("key.ping", 24, "key.categories.mymod");
        // Register both KeyBindings to the ClientRegistry
        ClientRegistry.registerKeyBinding(ping);
    }

}

KeyInputHandler.java

package com.example.examplemod;

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import cpw.mods.fml.common.gameevent.InputEvent;
import java.awt.Robot;
import java.awt.event.KeyEvent;

public class KeyInputHandler {

    @SubscribeEvent
    public void onKeyInput(InputEvent.KeyInputEvent event) {
        if(KeyBindings.ping.isPressed())
            System.out.println("ping");
        try {
            Robot r = new Robot();
            r.keyPress(KeyEvent.VK_F3);
            r.keyRelease(KeyEvent.VK_F3);
    } catch (Exception e) {
        e.printStackTrace();
}
    }
}

ゲームに入ってOを押しても何も起こらない

4

0 に答える 0