Let’s press some buttons and add custom keybinds to Minecraft once more and in this to this tutorial we’re going to be adding custom keybinds to Minecraft now this is actually part of a four tutorial part Series so this is the first part where we add literally Just the keybind and this is going to output something in the chat that is all that’s going to happen nothing more will be done in this tutorial but the next tutorial we’re then going to be adding custom networking and then we’re going to be saving some data on the player and Then last but not least we’re also going to add a HUD element so basically the four part tutorial series that we’re going to embark on is adding a thirst system to your player now the first thing I wanted to mention here is you can definitely work through it and you Can create it and this is going to serve as a good example on how you would create something like a thirst system however please do not use this particular system exactly in your mod reasons for this are plentiful but just a few of them number one this is just an Example for you to understand how you would go about actually adding it not only is it actually lacking a lot of features that a proper thirst system should have there also are things that actually don’t quite work a hundred percent and especially if you’re just copying over the code you should not use This particular system it is just for you to understand how to do all of those things at keybinds custom networking how to save data on the player and then also last but not least the custom HUD elements but it should not be used in a actual mod please don’t do this I hope That that was enough of a disclaimer I basically push away all responsibility if you’re using it in actual mod and the mod breaks then you have to fix it whatever the case may be that’s enough of a disclaimer here let’s start so what we want is we want a new package in our Tutorial mode package and that’s going to be called the event package and inside of there we’re going to make a new Java class and this is going to be the key input Handler now this is going to be very interesting so this will actually have a few things a few fields N2 methods first of all we’re going to have a public static final string this is going to be the key category tutorial so this is just going to be basically what our category is for our custom key bindings what it basically is going to be called so we’re going to call this Key category dot tutorial this is basically the translation key the second key that we want is we want the key drink water so basically we’re going to have a bring water key we’re just going to call this key dot drink water now if we want to be like absolutely certain That everything is going to be fine we’re actually want to add our Boreal mod mod ID as well let’s just do this key.category.utorial mod.tutorial just in case and then we should be totally fine that those will not be taken and then we’re going to make a new custom Keybind so there’s going to be a click static key binding from and this very important net Minecraft client option make sure you choose the correct one not the one from java X swing so from client option right here and that’s going to be called the drinking key and then we need Two new methods the first method is going to be the register key input so there’s going to be public static void register key inputs and this is going to actually use a an event to register a particular key so this is going to use the client tick events right here dot End client tick so we’re going to basically call this when a tick has ended we’re going to register this with a client and you can see it already suggests to us this parameter here and we’re just going to add the curly brackets the other curly bracket will generate automatically and in theory Here what we would want to do is we want to check if the particular key binding is pressed so we’re going to say if drinking key dot was pressed and then we want to do something now this happens when our custom key is pressed alright that’s pretty good now what we’re going To do is we’re literally just going to output something in the chat we’re going to get the player via this and we’re just going to send a chat message over here and we’re just going to say hello I pressed a key once again this will be changed in the next tutorial when we Actually Implement some networking some custom networking then we’re going to make a custom packet and we’re going to actually send some data over and then we’re going to do something a little bit different for the time being we’re going to keep it like this now we also need a Public aesthetic void register method and this is going to actually initialize the drinking key field over here so I’m going to say drinking key it’s going to be equal to the key binding helper this one right here from client keybinding version one and we’re going to say register keybinds and we’re going to Make a new keybinding there you go and then what do we need well first of all the parameters here for the new keybind are the first one is going to be the key drink water string so this is going to be the name so this is the translation Key of the keybind name then we want to know what this is what type of input this is so we’re going to say input util that and we want to use Key System this is basically the type of keybind this this is going to be for the keyboard and Then of course mouses for the mouse should be fairly self-explanatory then we want the key code the key code we’re going to get through glfw.glfw underscore key underscore and then whatever well basically key we want in our case we’re just going to use the o key but the you can of course change This you can see you know you have plenty of other keys that you can choose over here but like I said we’re going to choose the o key for the time being and this is the type here of course also has to be keyism he says there you go and Then the last parameter is going to be the key category tutorial so this is going to be the translation key of the category that we’re going to register this under and we’re going to make a new category in this case and we also want to call the register key inputs right Here so that’s very important that we call this method as well and then the register method should be called in the tutorial model client class right here we’re just going to call the key input handler.register method right here and what’s very important if you don’t have the client class done yet then create This you know make it implement the client mod initializer and then very important add it to your fabric mode Json file right here under the client that is extremely important otherwise it will not work so keep that in mind as well all right and last but not least we Also want to add the translation so let’s just copy that over over here nothing too crazy right just this translation key that we’ve made right here and then the key translation key right here so this is the drink water key and the these are the tutorial mod Keys basically or you can also say key bindings I mean whatever we basically want the to call the category we can also just call it tutorial mod the name of our mod whatever basically you want to do here that is pretty much all that we need to do once again to add a Keybind I want to stress this one more time next tutorial we’re going to be adding custom networking so that we can actually make something interesting happen instead of just sending a message over here but for the time being this is all that we’re doing in this tutorial so Let’s go into the game and see if it works or it finds us in Minecraft and let’s just go into the options control menu to the keybinds and at the very bottom we should find there we go the tutorial mod category with the drink water key being oh so this is a great Sign and already shows that everything should be working fine so now if we press the o key while in game we should get a message sent by our own players so let’s see there we go hello I pressed the key so exactly how we would want This to happen let’s just you know if we keep press down then you can see it shouldn’t Theory output this every tick so when you keep it pressed down but overall that is pretty awesome and that is pretty much how easy it is to add a custom keybind to Minecraft and like I Said for the actual functionality we’ll need custom networking which we’re going to cover in the next video so I hope to see you all there so yeah Video Information
This video, titled ‘Minecraft 1.19 Fabric Modding Tutorial | CUSTOM KEYBINDINGS | #14’, was uploaded by Modding by Kaupenjoe on 2022-07-25 13:59:56. It has garnered 9450 views and 156 likes. The duration of the video is 00:07:54 or 474 seconds.
In this Minecraft Modding Tutorial, we add custom Keybinds to Minecraft 1.19 using Fabric! 🙂
== MINECRAFT COURSES == ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 *
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Fabric-Tutorial-1.19/tree/14-keybinds Gist: https://url.kaupenjoe.net/yt372/gist
== TIMESTAMPS == 0:00 Intro 0:48 Important Disclaimer about the Thirst System 1:54 Adding the KeyInputHandler Class 6:02 Calling the register method in the Client Class 6:23 Adding the Translations 7:06 Demonstration 7:44 Outro
== TAKE A LOOK AT MY COURSES WITH COUPON CODES == ▶️ NEW Forge Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseForge120X ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 * ▶️ Complete and Roblox Lua Game Development: https://url.kaupenjoe.net/RobloxCoupon *
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== SOCIALS == Discord: https://discord.com/invite/yqxykanpWf Personal Twitter: https://twitter.com/Kaupenjoe
Instagram: https://url.kaupenjoe.net/tutorials/instagram Facebook: https://url.kaupenjoe.net/tutorials/facebook Twitter: https://url.kaupenjoe.net/tutorials/twitter TikTok: https://url.kaupenjoe.net/tutorials/tiktok Written Tutorials: https://url.kaupenjoe.net/tutorials/blog
== LICENSE == Source Code is distributed under the MIT License. Additional Licenses for other assets can be seen below or in the accompanying CREDITS.txt on download.
== ADDITIONAL CREDITS == Outro Musik by Kevin MacLeod: “That’s a Wrap” Kevin MacLeod (incompetech.com) Licensed under Creative Commons: By Attribution 3.0 http://creativecommons.org/licenses/by/3.0
== AFFILIATE DISCLAIMER == * Some of the links and other products that appear in the video description are from companies which I will earn an affiliate commission or referral bonus from or are my own products. This means that if you click on one of the product links, I’ll receive a small commission or additional kickback without any additional cost for you. This helps support the channel and allows me to continue to make videos. Thank you for the support!
== HASHTAGS == #Minecraft #MinecraftModding #MinecraftTutorial #Kaupenjoe