Hey what’s going on guys turtle here and welcome back to another minecraft pudding tutorial for forge 1.17 in this tutorial we are going to be covering keybinds so i’m just going to be covering a very basic keybind in this tutorial so it will be all client-side however i’ll be Doing a tutorial next on packets so that we can handle something server-side so key lines are very simple a lot simpler than they may sound so let’s just get started firstly we’re going to come into our client package and we’re going to create a new class Now i’m going to call this key mappings and this is basically where all your keys will be stored and where they will be registered in an actual fax we could go ahead and rename this to key init i’m actually going to do that okay you can put this in your core init However the reason i’m putting it in the client package is because keys are client only and i like to keep my client stuff stuff separate from everything else so we can make this a final class just like all our other inits and obviously a private constructor Then we can go ahead and create the field for our key so we’re going to create a public static key mapping and for now i’m going to call this just test key or i guess uh example key example key mapping yeah mapping example key mapping and just import key mapping Then we need to create a method to register the keys so we don’t use the forge registry in fact we need to use something called the client registry so let’s create a private static key mapping register key this will take in a name it will take in an int key code And it will take in a string for the category actually i’m just going to shuffle this around i’m going to put the category before the key code there we go so the strings are together then let’s create a final var key is equal to a new key mapping and This takes in three arguments it takes in the name of the key or i guess it’s actually called the description and then it takes in the key code and the category so for the description or the name i’m going to put key dots and then plus tutorial mod dot mod id If it wants to do that there we go and then dot and then plus name then i’m going to put in the key code and then i’m going to put in the category okay then we just need to call client registry dot register key binding and that takes in the key Then we can just return the key okay then we can create another method and we can call this public static void and let’s just call it init and we can go example key mapping is equal to register key then this takes in the name so For the name i’m just going to call it example underscore key then it takes in the key code and for this we need to use input constants and then you have every key basically the key i’m going to be using for this example is Uh s i’ll use key s so key underscore s then for the category you need to put key mapping dot and then you have these different categories you can also create a category i think you do that with this method here just create name supplier i’m not sure But i think that’s how you do it i’m just going to put it in a normal category so i’m going to put it in uh let’s just go game play okay that gives us an error all right we need to swap these two around of course and there we go Now we need to actually call this in its method so let’s come into our client event package let’s go in client mod events and inside of client setup we just want to call key init dot init okay let’s just come down into our lang let’s go ahead and put that in here Let’s go key dot tutorial mod dot example underscore key and i’m just going to call this example key Okay let’s now come back into our client events let’s create a new class in here let’s call this client forward events and i’m just going to show you an example of this key actually working so we need at mod event plus subscriber mod id is equal tutorial mod.mod id I still haven’t covered events so don’t worry about this too much and then bus which that one bus dot forge and then value is equal to dist dot client okay let’s just create make sure this is final and then let’s create our private constructor let’s create our events so subscribe event public static Void and we can call this client tick this just takes in a client tick event event this is just a very basic example here so if um Okay let’s say if if key init dot example key mapping dot is down and so i’m going to be relating this to the block entity tutorial that i did previously and i’m going to say minecraft.getinstance.player dot um riding I should be able to get the entity that it is riding let’s see if i can find it’s not as passenger i don’t think but it’s similar right so the passengers is basically the entities that Are riding the player so i need to get the entities that the player is riding okay so if i say is passenger And player dot get oh let’s create a field for this no let’s not do that that would be kind of weird um okay and then we can say uh get vehicle is instance of suitable entity which is our entity class okay and if that’s true we can just for now we’ll print Something in chat so we’ll just say um minecraft dot get instant stop play actually let’s make this a field because we’re accessing it a lot here so player is equal to now let’s go bar player here we go let’s plunk that there there let’s suppress the resource Okay then we can say player dot display client message let’s just do a new text component and let’s just say beans and we’ll leave it as false we want it to be displayed in chat or should we leave it as true let’s do true no let’s do folks i don’t trust doing true Okay let’s run the game let’s see if this works here we are we are now in the game so if we now go to options controls we should be able to go to gameplay and see our example key mapped to the s key obviously it has a conflict because walk backwards is also S if we now go ahead and sit on the toilet and press s it says beans obviously it says it multiple times because um you yeah we’re checking if it’s down we’re not checking when it’s released i’m not sure if there’s a way to check if it’s released uh probably not Yeah i doubt there is so obviously you can just have to you just have to manually implement that delay yourself pretty much so let’s just go to options let’s go controls let’s change this so let’s give it uh y okay if i now press y It changes it’s now y and obviously if i save and quit and load back in let’s go options controls and yeah it’s still y and we can reset it it goes back to x fantastic uh hopefully that really expands the chat but yeah so if you guys did find this Tutorial useful please do be sure to touch that like button and if you really enjoyed please do be sure to share it also subscribe as well because then you will not miss the next tutorial where i will cover handling stuff server side and we will be able to uh do some stuff With the toilet instead of just printing something to chat and uh yeah i’ll see you guys in the next one good bye Video Information
This video, titled ‘1.17/1.18 Minecraft Forge Modding Tutorial – Keybinds’, was uploaded by TurtyWurty on 2021-11-23 09:00:09. It has garnered 4561 views and 83 likes. The duration of the video is 00:13:28 or 808 seconds.
In this video, I cover how to make a client only keybind. In the next tutorial, I will show you how to make a packet and let your keybind work client-side.
Join my Discord Server, to receive support with your modding related questions: https://discord.gg/jCTnnhxc7J My CurseForge where you can find my released mods: https://www.curseforge.com/members/realturtywurty Github Repository: https://github.com/DaRealTurtyWurty/1.17-Tutorial-Mod