Let’s add custom blocks to Minecraft modding courses with close to 100 topics ranging from Custom tools and armor to custom block entities all the way to custom mobs Linked In the description below oh right references back and tell her once more and in this tutorial we’re Going to be adding custom blocks to our mod over here and it’s going to be very interesting indeed now first things first a disclaimer you will not be able to mine those blocks and they will not drop something that is something we’re going to do in a future tutorial so keep That in mind but to add those blocks let’s go to the tutorial mod package I’m going to right click new package called a block and inside of there we’ll make a new Java class and we’ll call this the mod blocks class the modblocks class will start similar to the mod items Class with a public static final deferred register over here of type of block this time making sure we choose net micro of world block and not open jdk Nas horn that’s very important that you choose the correct block class and then we’ll have this we’re going to call This blocks and this is equal to a deferred register dot create board Registries dot blocks and then passing in tutorial mod.mod ID and when you have a deferred register you will always have a public static void a register method with an i event bus right here called event bus and then blocks.register is Going to be a cold and the event bus is passed in here and we can call this register method in the tutorial mode class just below the mod items here mod blocks data register passing in the mod event bus right here and then our deferred register is also registered now For blocks we will actually need two helper methods and they are going to look a little strange but no worries we will get through this so we’re gonna have a private static and then we’ll have open angle bracket t extends block and then closing this then registry Object of type item and this is going to be the register block item class this is going to have a string name parameter as well as a registry object of type T parameter called block and that is going to be the method signature highly recommended if this is a little bit too Complicated for you to type out to go into the GitHub repository Linked In the description below you can basically always compare your code and the code that I’m writing here so to make sure that there is no typos the general idea here is just that this is all generics So the basic idea is that the T that we put into this registry object just has to be some sort of block that’s basically all we’re defining here and then the return here is just going to be an item because what we’re doing here is we will return mod items dot items dot Register and then passing in the name and then a new supplier of new block item passing in block.get and then after the first closing parentheses new item properties and then ending it with a semicolon and there you go that is the register block item method so we’re basically registering an Item that is associated with the block passed into the register block item method reason why we need to do this is when we register a normal block with this blocks deferred register right here it actually does not have an item associated with it so you need to register that manually and we’re doing That with this helper method there are definitely other ways to do this as well but I personally prefer to do it this way and that’s basically the way that I’m going to show you here the next thing is going to be another private static method this time again the open Angle bracket T extends block this will return a registry object of type T this time and this is going to be the register block method with once again a string name parameter and a supplier this time from java util function over here of type T and we’re going to call This the block as well this will first of all make a registry object of type T I’m going to call this the two return it’s going to be the object that we’re going to return in a moment and this is equal to blocks.register passing in the name and the block over here And then the second line is going to be the register block item passing in the name as well and then the tool return object over here the registry object and then we’ll just return the to return registry object so the first line here registers the block the second line registers the Block item and then we just return the block for this particular method and now the preparation has been done and we can finally actually create the block to create a block we need a public static final registry object of type block here in this case I’m going to call this the Sapphire underscore block and this is equal to the register block method passing in the sapphire underscore block here as a name this is a string and you can see once again this Name colon over here generates automatically you don’t have to type this out that is created by IntelliJ itself a second parameter is going to be a new supplier so this is going to be once again open and closing parentheses and then this Arrow here with new Block in this case so we’re going to make a new block and we will make new block Behavior dot properties Dot and then we can either say of or copy now in this case I suggest you use copy because then you can just pass in blocks dot for example iron block over here and then end it with a semicolon and the sapphire block is done when it Comes to the block properties the idea is that you can either copy them from an already existing block or you can well basically choose to create your own with the dot of here in this case if you do this however then you basically have to supply it the sounds that it uses map Color and some other things you can basically middle Mouse by click on the iron block and we were able to see you know map color instrument requires tool for drops the strength and the sound here is basically created now you can copy the properties from a block and Then still override them quote unquote so for example maybe we say hey you know what I actually want a different sound type so we’re going to choose the sound type amethyst for this one so it’s going to have all of the different properties from the iron block however it is going To sound like amethyst but of course we’re not nearly done just yet let’s first of all add it to our creative mode tab over here and to do this we’re just going to say p output dot accept mod block start Sapphire block.get and that is it that will add our block to our Custom creative mode tab oh and then we get to the Json files what a delight so for the Json files in the assets tutorial for a mod folder we wanted to right click create a new directory called block States make sure that this is written correctly Block states with an S at the end and we also want to create a new folder in the models folder called block and the same thing in the text test folder also new directory called block make sure that those are called block and the other one is called block States You can also always take a look at the GitHub repository to see the actual polar structure or just right here is this photo structure basically for you on the screen to see as well now let’s start with the block stage Json file let’s right click new file and this is Going to be the sapphire underscore block.json once again note that the name of this Json file has to match the name given right here and then of course it has to have the Json ending that should make sense and the block stage Json file basically determines what model your Block takes on when it is created inside of a world so when you set it down in the world hey what should what model should I take to display this and it’s going to be actually fairly straightforward so we’re going to have variance over here and those are going To be of an empty string and that is going to be model colon tutorial mod colon block slash Sapphire underscore block and that is it now what does this do well blocks can have different block State Properties in our case this is a normal block therefore it doesn’t have Any kind of properties right it has no special properties in this case that may be change and therefore we’re just always pointing to the sapphire block model file in the block folder right here so we’re basically to say hey I want to look for a sapphire block Json File in the tutorial mode models block folder so that’s what we’re going to create so we’re going to create that new file that’s going to be the sapphire underscore block data Json again there we go and a block model file you’re going to see is going to be very similar To an item model file but it’s going to be a little bit different as well this is going to be apparent is going to be Minecraft block Cube underscore all is also going to have textures over here and the textures are going to be of all and that’s going to be tutorial mod Colon Sapphire underscore block there we go and you can see it is very similar to an item model Json file if you like compare them next to each other later like almost the same we basically just have a cube all apparent over here that basically just means that all the Sides of the cube are going to be this particular texture defined as Sapphire underscore block.png in the block folder right here in the textures folder for the tutorial mod namespace that’s once again how it all fits together pretty much the same thing as the item should be fairly self-explanatory and now if we Had this we would have a block that would have a texture inside the world however it wouldn’t have a texture in the inventory because we still need an item model Json for this and we also don’t have the translation let’s first of all do the translation because that Is a very easy indeed so we’re just going to add a new key here and that is block.tutorial Mod Dot Sapphire underscore block and this is going to be a block of sapphire so once you’ve seen this you should pretty much be able to spot the pattern on what happens here The first part is always going to be well what type of thing are we creating right here we’re creating an item here we’re creating a block then we have a DOT and then our mod ID and then just the name given right here Sapphire block and then this is the sapphire block so At this point the translation should be a easy thing to understand and pretty trivial when you really look at it it’s it’s very straightforward but what about the item model file well the item model file that’s created right click on the item folder new file this is the sapphire underscore block.json and the Contents of this oh boy those are going to be crazy so this is once again a parent over here and that is tutorial mod colon block slash Sapphire underscore block you might say yourself wait that’s it it is indeed it because the item model Json file for a block Simply points back to the block model Json file to be like okay I’m going to display this block in this like 3D pattern that we’ve seen basically any block in Minecraft inventory be displayed just with the texture that is defined in the block model Json file speaking of the texture let’s copy this Over and this was of course also going to be available to you for download so no worries at all but with that we have the block stage Json file we have a translation we have the block model Json file the item model Json file and the texture meaning that we have everything Done that we need so let’s jump into the game and see our custom Sapphire block alright fuzzles back in Minecraft and let’s take a look and there we go the block of sci-fi has been added to the game and you can even hear it has the amethyst sound group Absolutely freaking spectacular and as we’ve said before one is none let’s add a second block as well because of course just like with the item people have been asking well how do I add a second block over here Captain draw do I have to create a new mod blocks class do I have To copy the register block methods absolutely not that would be ridiculous also good indication that you should maybe check a little bit more Java knowledge if you are confused with that but that’s totally fine because how you add a second block is you just need another registry object over here so We’re gonna have another public static final or registry object of type block over here in this case and this is going to be the raw underscore Sapphire underscore block equal to the register block method once again and this is the raw underscore Sapphire underscore block awesome this will be once again A Supplier of a new block here in this case taking the block behavior.properties and then copying blocks iron block and then just adding the same sound group of amethyst I think that that’s actually a great idea there we go and we can end it with a semicolon And the block has been added now it’s registered we still have to add it to the creative mode tab but once again we can just duplicate this line just click on it press Ctrl D and we can specify the raw Sapphire block here and then When it comes to the Json files well in this case it’s a little more complicated because of course each one of your blocks needs a separate Json file in this case however in the future in a future tutorial we’re going to see a way easier way to do this with data gen I’m I’m telling you it’s going to be really awesome for the time being we do have to copy them over to do this what you do is you just drag them into the same folder while holding Ctrl and you can see this little plus appears that will duplicate This file and you can then also change the name to Raw underscore Sapphire underscore block and then inside of the file you can change the contents as well you can do this for the block States the block model Json as well as the item model Json file and then you should be Good to go there you go done for all the different Json files similar to The Lang over here that should be like literally the easiest thing ever you just duplicate this line and instead of the sapphire block you want to translate the raw Sapphire block and this is then of Course a block of raw Sapphire lastly we want to add the texture over here so that is the raw Sapphire block texture and that is it that is the second block added as well you can of course see much faster once you’ve set everything up and You sort of understand okay this is a block status file this is a block model Json file and this is an item model Json file and if you have an example to copy over that is of course also going to be very useful indeed and just for the sake Of argument let’s go into the game one more time and take a look alright friends as a migrant again and let’s take a look and there we go the block of a raw Sapphire also added and if I set it down it also sounds like amethyst and it looks absolutely freaking fantastic I Really love it I mean there you go that’s two blocks added to Minecraft right as always take a look at the code if anything was confusing to you it is linked in the description below in the GitHub repository you can always take a look at that otherwise next time we’re Going to take a look at recipes in this video right here hope to see you there so yeah Video Information
This video, titled ‘Forge Modding Tutorial – Minecraft 1.20: Custom Blocks | #3’, was uploaded by Modding by Kaupenjoe on 2023-07-10 14:59:55. It has garnered 3359 views and 131 likes. The duration of the video is 00:13:14 or 794 seconds.
In this Minecraft Modding Tutorial for Forge, we are adding a Custom Block to Minecraft 1.20 😀
== MODDING COURSES == FORGE ▶️ https://url.kaupenjoe.net/CourseForge120X FABRIC ▶️ https://url.kaupenjoe.net/CourseFabric120X
== COMPATIBILITY == ▶️ Compatible with 1.20 & 1.20.1
== ASSETS & DOWNLOAD LINKS == GitHub Repo: https://github.com/Tutorials-By-Kaupenjoe/Forge-Tutorial-1.20.X/tree/3-customBlocks Assets Zipped: https://url.kaupenjoe.net/mbkj50/assets
== SUPPORT ME ON PATREON == ▶️ https://www.patreon.com/Kaupenjoe
== 25% OFF FOR GAMING SERVERS == ▶️ https://www.bisecthosting.com/Kaupenjoe
== TAKE A LOOK AT MY COURSES WITH COUPON CODES == ▶️ NEW Forge Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseForge120X ▶️ NEW Fabric Modding with Minecraft 1.20.X: https://url.kaupenjoe.net/CourseFabric120X ▶️ Complete and Roblox Lua Game Development: https://url.kaupenjoe.net/RobloxCoupon * ▶️ Learn Forge Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseForge118 * ▶️ Learn Fabric Modding with Minecraft 1.18: https://url.kaupenjoe.net/CourseFabric118 *
== 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.
== 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