[Tutorial] - make a keybind category

Started by TokeN on

Topic category: Help with Minecraft modding (Java Edition)

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
[Tutorial] - make a keybind category
Tue, 04/02/2024 - 20:04 (edited)

Tutorial - Make a Keybind Category

Mcreator Version 2020.x & 2023.x

Last topic update : 04/02/2024 - 18:41



Many of you may have the same problem as me creating a category for the keybind.
 

But today I'm going to teach you how to do it in detail.


Mcreator Version 2020.x (1.12.2 - 1.14.4)
 

1.Make a keybind and save elements

 

2.Go to the Localization page and click "Add localization entry" and named it "key.categories.[you categories name]"

 

3.Set a name to display

 

4.Press the keybind created and go to "Edit code of selected mod element".


 

5.Find the line "FMLInitializationEvent" and replace "key.categories.misc" with "key.categories.[you categories name]".

 

6.Press exit and "Close and Save" and "Lock the code for MCreator and save".

 

Finish


 

 


Mcreator Version 2023.x (1.19.x - 1.20.x)

 

1.Create a keybind, change "key.categories.[you categories name]" want you need and save elements

 

2..Go to the Localization page and click "Add localization entry" and named it "key.categories.[you categories name]"

 

3.Set a name to display

 

 

Finish


 


 

Hope it will be helpful for everyone.

Edited by TokeN on Tue, 04/02/2024 - 20:04
Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Hello, sorry to bother. i…
Mon, 01/29/2024 - 16:30

Hello, sorry to bother. i try to create my own custom keyBind category (completely separate from misc, or other already build keybind categories) but didnt make it.  I conclude that it s either :

  1. i don t change the code at the right place (.jjk instead of .misc)
  2. I don t lock the code correctly before running the client (which will erase my modification in the process)
  3. in mc creator 2023.4 it require a lot of code to do what i want 

This is my work step to step.  https://imgur.com/a/S9CMJ91

Could you help me if you are strong enough ? i appreciate it ;)

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I'll check it out. If I find…
Tue, 04/02/2024 - 18:41

I'll check it out. If I find a way, I'll reply again. I'm not very familiar with Mcreator Version 2023.4. It might take me a while to figure it out.

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Tutorial - Make a Keybind…
Tue, 04/02/2024 - 20:03

Tutorial - Make a Keybind Category
Mcreator Version 2020.x & 2023.x
Lest post update : 04/02/2024 - 18:41

I've updated my topic tutorial, hope it's more or less helpful. Sorry for the late reply and sorry for the missing photos. Because I left the MCreator industry a long time ago.

Thank you to everyone who saw my tutorial.
 

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
OMG i m so dumb, it was that…
Fri, 04/05/2024 - 13:18

OMG i m so dumb, it was that easy xD. 

Thanks very much to have came back to answer me even if you aren t actif anymore :)

No worry for the late answer !

I m just trying my luck here, i tried to set a keybind to a mouse click, or the rotation of the mouse rotor but can t find a way to archieve it. Would it be easy for you to find a way ? 

I don t want you to spend a lot of time on it, just trying my luck if it would be easy for you with your past knowledg of coding.

If you don t have time, don t remember, don t want to, or it bother you, i would understand no worry ;)

In both case, I wish the best for you !

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Will try to help solve your…
Sat, 04/06/2024 - 19:26

Will try to help solve your problem.
I don't know if you mean the code I wrote.
If not, this code doesn't take very long to write, so don't worry.

*I'm not a native speaker. There may be some mistranslation.

*This code may not work. Because I wrote with the previous knowledge I had. But you can learn from it in some lines.


For keyboard button settings, click Mouse.

public class MouseClickKeybind {

    private Keybind clickKeybind;

    public MouseClickKeybind() {
        clickKeybind = new Keybind("Click", Keyboard.KEY_LBUTTON); // Assign a keyboard button to the left mouse button.

        clickKeybind.onPress(() -> {
            // Code that will run when the key is pressed
            System.out.println("Mouse click!");

            // Simulate left mouse click
            Robot robot = new Robot();
            robot.mousePress(InputEvent.BUTTON1_MASK);
            robot.mouseRelease(InputEvent.BUTTON1_MASK);
        });
    }

    public void register() {
        MinecraftForge.EVENT_BUS.register(this);
    }

    public void unregister() {
        MinecraftForge.EVENT_BUS.unregister(this);
    }

}


For keyboard button settings, rotate the mouse.

public class MouseRotationKeybind {

    private Keybind rotateUpKeybind;
    private Keybind rotateDownKeybind;

    public MouseRotationKeybind() {
        rotateUpKeybind = new Keybind("Rotate Up", Keyboard.KEY_W);
        rotateDownKeybind = new Keybind("Rotate Down", Keyboard.KEY_S);

        rotateUpKeybind.onPress(() -> {
            // Code that will run when the "Rotate Up" keyboard key is pressed.
            System.out.println("Turn the mouse up!");

            // Simulate turning the mouse up
            Robot robot = new Robot();
            robot.mouseWheel(1);
        });

        rotateDownKeybind.onPress(() -> {
            // Code that will run when the "Rotate Down" keyboard key is pressed.
            System.out.println("Roll the mouse down!");

            // Simulate turning the mouse down
            Robot robot = new Robot();
            robot.mouseWheel(-1);
        });
    }

    public void register() {
        MinecraftForge.EVENT_BUS.register(this);
    }

    public void unregister() {
        MinecraftForge.EVENT_BUS.unregister(this);
    }

}

 

 

Joined Mar 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
u can use Library: java-robot
Sat, 04/06/2024 - 19:31

u can use Library: java-robot

Joined Jan 2024
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Alright, thanks a lot mate ;…
Sun, 04/07/2024 - 10:06

Alright, thanks a lot mate ;) 

I will try it 

Have a good day !