I'm trying to make a quick macro mod for my clientside jar. I'm using MCP.
I suppose, to be modular, the purpose of this mod is to bind commands (like /cast <fireball>, for example) to specific keys. I know it's possible to bind things to keys, but I can't figure it out! What's more, when I figure out how to bind something to the key, how do I make it so that the key makes the player send a chat command to the server?
Sorry, I know that's basically asking the forum to write the mod for me ._. , but I'm lost and it's a pretty simple mod anyway.
The Meaning of Life, the Universe, and Everything.
Join Date:
1/18/2011
Posts:
256
Minecraft:
Plecks
Member Details
Well, first you need to bind a key. I use ModLoader/MCP, so I'll explain using that. First you need to define the keybinding.
private KeyBinding keyBindCastFireball = new KeyBinding("key.castFireball", 44);
Then in your constructor, you need to register the key with ModLoader.
ModLoader.RegisterKey(this, this.keyBindCastFireball, false);
ModLoader.AddLocalization("key.castFireball", "Cast a fireball");
Then you use KeyboardEvent to capture the keypress and send off the chat message.
public void KeyboardEvent(KeyBinding event)
{
Minecraft mc = ModLoader.getMinecraftInstance();
if((event == this.keyBindCastFireball) && (mc.currentScreen == null)) //Checks that the keypress is the right key, and that we don't have a GUI up
{
mc.thePlayer.sendChatMessage("/cast fireball");
}
}
I'm trying to make a quick macro mod for my clientside jar. I'm using MCP.
I suppose, to be modular, the purpose of this mod is to bind commands (like /cast <fireball>, for example) to specific keys. I know it's possible to bind things to keys, but I can't figure it out! What's more, when I figure out how to bind something to the key, how do I make it so that the key makes the player send a chat command to the server?
Sorry, I know that's basically asking the forum to write the mod for me ._. , but I'm lost and it's a pretty simple mod anyway.
Is this possible?
Thanks!
EDIT: Figured it out.
I wrote this a little while back but I'm still actively developing it and adding new features all the time. I'm also happy to share the source code if you wanted to modify it:
One thing I will say if you decide to implement your own version anyway - a lot of modders forget to check whether a GUI is being displayed when they hook the key bind! This means that if you're not careful your keybind will hook even when typing chat messages etc or in the options screen.
The solution I've come up with to this particular problem is never executing in a GUI unless a special "override" key is held, which gives you the flexibility to use ordinary binds whilst in-game, or selectively whilst in a GUI. I've also added multiple configuration support (with auto-switch for different servers) and lots of insertable parameters, as well as the ability to include files and edit text files in-game.
Sorry if this isn't any help but people aren't finding my mod even though it does something that a lot of people want, I think I need to promote it more :smile.gif:
Oh, I also added scripting so you can do timed messages and such.
this is just a simple method to use an ingame key like space, or w,a,s,d
if you want to use a custom one put this into onTickInGame:
if(Keyboard.isKeyDown(19))
{
}
/\
|| this one asks if 'r' is pressed, getting your key to work is guess and check.
hope you can put these methods to work.
remember they go in your 'mod_****'
-Quince
This
if(Keyboard.isKeyDown(19))
{
}
will be true while the key is held down.
Also, for keybinds you can use Keyboard.KEY_NAME. Just type Keyboard. in eclipse and it will give you a list of all the available keys. (This is LWJGL.)
So, for things like toggles, this isn't really going to work. And for things like chat commands it won't work that well either.
I have a class for this sort of thing, if you want to see it just ask
Also, just noticed this thread is over a year old...
I wrote this a little while back but I'm still actively developing it and adding new features all the time. I'm also happy to share the source code if you wanted to modify it:
One thing I will say if you decide to implement your own version anyway - a lot of modders forget to check whether a GUI is being displayed when they hook the key bind! This means that if you're not careful your keybind will hook even when typing chat messages etc or in the options screen.
The solution I've come up with to this particular problem is never executing in a GUI unless a special "override" key is held, which gives you the flexibility to use ordinary binds whilst in-game, or selectively whilst in a GUI. I've also added multiple configuration support (with auto-switch for different servers) and lots of insertable parameters, as well as the ability to include files and edit text files in-game.
Sorry if this isn't any help but people aren't finding my mod even though it does something that a lot of people want, I think I need to promote it more
Oh, I also added scripting so you can do timed messages and such.
But, this mod and/or LiteLoader need to be updated for 1.6.1
I'm trying to make a quick macro mod for my clientside jar. I'm using MCP.
I suppose, to be modular, the purpose of this mod is to bind commands (like /cast <fireball>, for example) to specific keys. I know it's possible to bind things to keys, but I can't figure it out! What's more, when I figure out how to bind something to the key, how do I make it so that the key makes the player send a chat command to the server?
Sorry, I know that's basically asking the forum to write the mod for me ._. , but I'm lost and it's a pretty simple mod anyway.
Is this possible?
Thanks!
EDIT: Figured it out.
Then in your constructor, you need to register the key with ModLoader.
Then you use KeyboardEvent to capture the keypress and send off the chat message.
I wrote this a little while back but I'm still actively developing it and adding new features all the time. I'm also happy to share the source code if you wanted to modify it:
Forum Thread - Macro/Keybind Mod
One thing I will say if you decide to implement your own version anyway - a lot of modders forget to check whether a GUI is being displayed when they hook the key bind! This means that if you're not careful your keybind will hook even when typing chat messages etc or in the options screen.
The solution I've come up with to this particular problem is never executing in a GUI unless a special "override" key is held, which gives you the flexibility to use ordinary binds whilst in-game, or selectively whilst in a GUI. I've also added multiple configuration support (with auto-switch for different servers) and lots of insertable parameters, as well as the ability to include files and edit text files in-game.
Sorry if this isn't any help but people aren't finding my mod even though it does something that a lot of people want, I think I need to promote it more :smile.gif:
Oh, I also added scripting so you can do timed messages and such.
this is just a simple method to use an ingame key like space, or w,a,s,d
if you want to use a custom one put this into onTickInGame:
/\
|| this one asks if 'r' is pressed, getting your key to work is guess and check.
hope you can put these methods to work.
remember they go in your 'mod_****'
-Quince
This
will be true while the key is held down.
Also, for keybinds you can use Keyboard.KEY_NAME. Just type Keyboard. in eclipse and it will give you a list of all the available keys. (This is LWJGL.)
So, for things like toggles, this isn't really going to work. And for things like chat commands it won't work that well either.
I have a class for this sort of thing, if you want to see it just ask
Also, just noticed this thread is over a year old...
But, this mod and/or LiteLoader need to be updated for 1.6.1
You don't suppose that that link being over 1.5 years old could have anything to do with it?