Hey what’s going on guys turtleworthy here and welcome back to part three of the 1.17 uh forge modding tutorials for minecraft now in this tutorial we are just going to make a very simple block and uh yeah that’s pretty much it so let’s go ahead and get started So the first thing we need to go ahead and do is create our block initialization class so i’m going to call this block in it to stick with the theme however obviously mod blocks or tutorial mod blocks is perfectly fine too Here we go and let’s create the deferred register exactly like we did with items so public static final deferred register that takes in block and we’ll call this blocks now it’s just equal to deferred register dot create port registries dot blocks and then obviously our mod id which is tutorial dot mod id Okay let’s just import block from net.minecraft.world.level.block.block you need to make sure you import the right block here there are quite a few so it is this top one there we go let’s also just real quick make this class final and give it a private constructor not that we are ever going to Instantiate it anyways so then let’s come down here and we can now create the registry object so public static final registry objects and that will be of a block and we can just call this example underscore block is equal to blocks dot register example underscore block And that is just a supplier of a new block and once this wants to load there we go okay now this just takes a block. a block properties however it’s slightly different from items so to make a block properties we actually need to use abstract block dots properties dot is that not right Has that changed again maybe it’s changed again let’s see if uh properties once you come up here we go so where is properties not that properties wrong one okay let’s see properties so here we go block behavior right so it’s block behavior do you guys about that right no behave yeah i’m So bad at spelling okay that’s that’s correct block behavior dot properties and then dot off and here you can pass in a material and a material color or you can copy it from an existing block so let’s say you wanted to copy it we’ll go through that first You can simply just use blocks which is the vanilla block init class blocks and then all the different blocks are here so you could just choose one brick stairs for example and boom you your block now has the properties of brick stairs and you can still modify this so You can still do dots and then you can still do any of these functions that you wish to do so that is the copy method and now we’ll go through of if eclipse wants to stop doing this really annoying okay let’s put it on a new line manually then Okay let’s say we want to use off we can pass in a material so material dots and this will basically change the sounds i believe it changes a few things um but basically just put the one that’s most similar to what your block is um look skulk is even in here huh interesting Very interesting um but yeah you can just put whatever you want so i’m gonna put just stone and then you can also pass in a material color so if you do that you can then see the different material colors that you can do so material color and you’ll see all of these different Colors so this is basically for the map colors i believe pretty sure um so i’m gonna put pretty much the color of my block which is i guess the closest one is terracotta blue it’s probably the closest okay and then after that we can do a bunch of different properties So we can set for example the strength and this is basically the hardness and the resistance of the block so the best way to figure out what these values should be is simply just to look at vanilla so let’s uh in a clip which you can do ctrl shift t And in intellij that is uh four shifts so you just shift four times but eclipse is ctrl shift t and then you just type the name of the class that you want to view so i want to view the blocks class and once that loads we can now see a Bunch of blocks obviously all the blocks so i want to look for stone so i’m just going to search stone is there a lot of stones there is a lot of stones okay let’s search in that case for block and then stone and that should find us the actual stone field Oh it’s right at the top of course it is um and you can see here the strength so the hardness is 1.5 and the resistance is 6.0 so for the strength uh i’m going to put 2.0 and for the resistance i’m going to put 15. and yeah you should basically just base That off of what vanilla uses you can fairly easily grab that and then i’m also going to use this requires correct tool for drops so i’m going to go ahead and copy that and paste it in that basically means you need to have this correct tool in order to mine block And obtain the loop table and then after that you can do any of these properties that you want to do so let’s say you wanted it to be slippery you can simply do uh friction and you could go 0.5 for example and yeah obviously there are tons of Properties here it would take a little while to go through all of them so we’re not going to do that so yeah we will now have a block in the game after we have done one thing and that is obviously adding it to our main class so If we come back in here we can just do blocking it dot blocks dot register bus i’m actually going to go ahead and move this before the items just because blocks do register before items but it doesn’t matter which order you have these in i just prefer to have them In the correct order if possible so yeah that’s that’s that we will now have a block in the game however we have a block that’s great but we can we don’t have an item for the block so we can’t place the block down we cannot have it in our hand We cannot have it in a creative inventory because it doesn’t exist as an item it will only exist in the form of an actual place down block which we could only get from set block the command so the next thing you need to do is create a block item now Where you put this block item is up to you it is an item so it does make more sense to be an item in it i would say however some people do it in blocking it because it is a block item so it’s up to you which one of these Classes you put it in i’m personally going to put it in item in it because i prefer to actually keep my items in here you can always just add comments so um that’s what i’m gonna do i’m gonna have block items and then create it down here so block items are actually slightly Different from normal items and i will show you why so let’s just create the public static final registry object that’s the exact same however instead of putting item in here we want to put block item since it’s a block item and then we can just call this example underscore block underscore item And that can be equal to items dot register and this right here needs to be or it doesn’t need to be but it should be the exact same name as your block in here which i put example block so i’m just going to copy that across make sure it’s the exact same And then we just have a normal supplier like uh previously however instead of using a new item we want to do a new block item and you’ll see this has two parameters so let me just format this there we go so this has two parameters and if we Have a look this requires a block and a properties so for the block that is basically going to be the block that we want to create this item for so is the block that will be placed when we create this when we get this item so The block that we want to place is obviously our example block so how do we reference that so it’s pretty simple to be honest we just go blocking it dot example block now you may think that’s it but as you can see there is now an error so you Cannot do that that does not work that throws you an error and the reason being if we look in our block in it this is a registry object of a block so this is not a block right here this is a registry object that holds a supplier of a block So we need to find a way to go ahead and get this block and the keyword there is get so it’s pretty simple you just call dot get and that will go ahead and as you can see if you look in here that returns you a block and then you have the parameter That it’s asked for it’s fairly simple um but it is a bit confusing for some people you need to be careful however when you call this dot get since this could it could um basically throw a null point or exception since if the block is not yet registered Registered and you try to get it it won’t exist so it will be null and it will throw a null pointer exception and crash your game so you do need to be careful when you call this dot get however if we’re using it for block items this is perfectly Fine it it’s in a supplier so it all happens later anyways the next thing is just the normal item properties so i’m just going to go ahead and copy this one from up here uh yeah right there and paste that in however i’m not going to have it in the Mix tab i’m going to have this one in the building blocks tab or actually am i going to have it in the building blocks no i’m going to put yeah i am gonna have it in the building blocks i was thinking to put it in decoration but that’s a bit strange uh Item what’s going on here no why why okay um yeah that’s pretty much it that is it actually so now we need to go ahead and we need to go ahead and create the assets for this block so the first thing we need for a block is a block state So a block state is basically the the thing that exists in the world there is no such thing as a block in the world everything is a block state the block state is basically it holds all the information the block is only sort of a type it’s More of a template a block is a template um it’s it’s a slightly confusing concept to understand but you will get the hang of it eventually like a lot of things in forge it’s a bit complicated at first but you you will understand it eventually So we need to go ahead and create a new package in our assets and that is block states so in here we just need to create a file with the exact same name as our block which was example underscore block dot json here we go and this will just create an empty file So in here um you’re probably going to want to go ahead and copy this from the description okay there we go this is our json so the one in the description will probably look like it will probably look more like this this is probably what it will look like in the description And you just fill this out with your mod id and your uh block name pretty much um so basically what’s happening here is a block state has or can have multiple variants to it um so a great example of this is the door so the door has Actually the door has a lot of block state but we’ll just go with the most simple one and that is open and closed so those are two different block states for the door so obviously if that was the case we would just have um it would be something like open equals true Or it would be open equals false um but obviously for the default one we just leave this blank and that is the default block state and then this refers to a model so this is the location of the block model and obviously that’s your mod id And then it is in the models by default and then the block package and from there it will just be the example block so let’s go ahead and let’s create this json file so example underscore block dot json okay yep that was indeed correct so that Will work perfectly fine so we can now go ahead and close that and the final thing we need to go ahead and do uh well not the final thing actually that’s wrong uh the next thing we need to go ahead and do is the uh item model for the block item so obviously It’s a different item so we need to go ahead and create a model for it now we can just go ahead and copy this uh one right actually there’s no point copying it it’s it’s fairly different so this is just obviously going to be the same name example block And this is a very simple json so it is literally just parent and then this parents off of the block so tutorial mod colon block forward slash example and sql block and that will just use the basically the block model and the next thing we need to go ahead And do is obviously add the texture so i’m just going to refresh and there we go i have my texture in here 16 by 16 of course next we need to go ahead and do is the lang so that is for the block item so item.tutorialmod dot example unscroll block And obviously then just example block there we go obviously make sure you have a comma here this is a json so you need to make sure everything is like that and yeah that’s pretty much it however when we run the game i’m not going to run the game yet because there is one Thing you might want to go ahead and do and that is loop table so by default it will drop nothing unless you have a loot table so we do need to go ahead and create a loot table okay so the first thing you need to go ahead and do Is we need to create a new folder in our source main resources and we need to call this data and then we want to create another folder called uh tutorial mod there we go and in tutorial mod we’re going to create another folder called loot underscore table tables Boot table table tables i think tables i think it’s plural and then we want to create another package for blocks and just to separate this out a little bit i’m going to create one for ends tease and i’m going to also i’m going to also make another package here For recipes just to space it out a little bit so it’s not so clumped up now we’re actually going to want to go ahead and create a loot table so there is this very handy website uh missouri github.io for a shoe table this will be in the description of course And make sure it’s obviously on version 1.17 and here we can set the type to block and we can go ahead and we should be able to use a preset right here so if you see presets and you can use any preset you want edit the loot table how you want I’m literally just going to copy acacia planks and change it to my block so tutorial mod colon example underscore block and yeah that’s pretty much it so we can just go ahead and copy that then we can go back into eclipse you can create a new file we need which needs to Be the exact same name as our block for example underscore block dot json of course everything is a jason and yeah that’s pretty much it obviously you can edit this how you like you don’t have to make it drop a block you can make it drop different items Just yeah this times of little things you can go ahead and make it do uh not just a basic loot table however this will work with any tool so we need to go ahead and make it only work with a specific level of tool or we Can make it work with a specific level of talk and the way we need to go ahead and do that is we need to add it to some tags okay so we now want to go ahead and create another package inside data and this is actually going to be for the minecraft And in here we want to go ahead and create another package and this will be for dot tags and then another package for blocks and then another package for minable and in here we need to go ahead and create a file called um whatever tool type you want your um Your block to be mineable by so i want mine to be mindable by pickaxe so i’m simply going to write pickaxe dot jason um there’s also axe hoe and shovel those are the possible types so let’s go ahead and add pickaxe.json Okay and what we want to simply do in here is this is a very simple json so first we want replace colon false so that means it won’t replace the vanilla tag it will just add to it and then values which is an array and in here we simply just want to put Tutorial mod colon example and it’s got block so that is the block we want to make mineable by a pickaxe and that is it for that file the next thing we want to go ahead and do is do the harvest levels so this is very similar however it does depend on what harvest Level you want so if you want a never right harvest level a gold harvest level or a wood harvest level then you need to go ahead and create another package inside data for dot forge and in here you can create another package for dot tags okay and in here you can create another Package for your blocks again and in there you will just put the the tool so let’s say you want it to be only mineable by gold then you can simply create a file and you would just simply call this needs underscore gold underscore tool dot json And this is literally just a normal tag so it’s just replace false and then values and then you can just put your block in here so you know you can say uh tutorial mod colon example and scroll block now obviously if you want to be using stone iron or diamond Tool two levels then you need to put this in the minecraft package instead of the uh not instead of forge so actually i’m going to go ahead and do that i’m going to move this into here um that’s not quite what i meant actually okay let’s delete that let’s create a new file That way we can actually change the name here and we can just put needs underscore iron underscore tool json and that way we can just add it back in here replace colon false values colon and then that’s an array and we literally just add our tool in here example underscore block voila And that should work so let’s actually just delete this package we don’t need that anymore and let’s go ahead and run the game let’s see if it works okay i am now in the game it turns out i did mess one thing up right here um i accidentally I mistaken it and it actually needs to be block dot tutorial mod since it is a block i completely forgot about that i thought it was an item or at least i thought it the name functioned as an item we can now just f3 and t and that will Go ahead and reload the assets and there we go that has now reloaded and it has the right name so when we place it down it has the sound of stone it has our texture uh has everything in hand as well now let’s go ahead and test it with some Pickaxes so let’s grab an iron pickaxe let’s grab um let’s grab a diamond shovel let’s add a wooden let’s add a stone pickaxe yeah those should be i guess we’ll add a we’ll have a never right pickaxe as well okay let’s go into survival game mode survival and Uh i guess we’re going to actually need a few more if we want to test this so let’s give at s tutorial mod colon example block and let’s just give ourselves uh three was actually too many but that’s fine so let’s first break it with an iron pickaxe And as you can see it gives us our example block now let’s try and break it with a diamond shovel so it’s going to take a little bit since obviously we set the hardness quite high as you can see we do not get anything from that Now let’s try with a stone pickaxe so it’s the right tool type but it’s not the right level as you can see we don’t get anything and with a never right pickaxe it should work of course yeah that works perfectly fine so yeah that’s that’s pretty much it Um i hope you guys did enjoy this tutorial if you did please do be sure to smash your face into that like button and subscribe if you really enjoyed please do be sure to share it and uh yeah i’ll see you guys in the next video Hey guys i’m in new york city just hanging out Video Information
This video, titled ‘1.17/1.18 Minecraft Forge Modding Tutorial – Blocks’, was uploaded by TurtyWurty on 2021-10-27 20:00:11. It has garnered 6000 views and 173 likes. The duration of the video is 00:27:40 or 1660 seconds.
In this video, I cover how to add a block to Minecraft and also how to create a loot table for it, including the new tag tool system.
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
Blockstate JSON: https://pastebin.com/HXNiXW2B Block Model JSON: https://pastebin.com/Q3xajRQN Block Item Model JSON: https://pastebin.com/uKUZf92z Loot Table site: https://misode.github.io/loot-table/ Extra Information about the new tool system: https://gist.github.com/gigaherz/691f528a61f631af90c9426c076a298a