Foreign ladies and gentle ladies and welcome back to another Minecraft modding tutorial for Forge 1.20 in this tutorial we are going to be covering how we can make a block and add it to the game and yeah so let’s get started so the first thing we’re going to want To do is come into our init package and create a new class this would be called I’m sure you can guess but Block in it just as our item in it was for items this is going to be pretty much exactly the same as our item in it So we’re going to once again want a deferred register so a public static final deferred register let me just turn copilot off and that will be of type block instead of type item we’ll call that blocks and that is deferred registock dot create and we’ll pass in Forge Registries dot blocks Then we need to once again pass our mod ID in here so tutorial Mod Dot mod ID is the constant note we created and then we just want to create the registry object so once again this is exactly the same as it is for items we’re going to do block We’ll call this example underscore block is equal blocks.register let’s give it our name so once again no spaces no special characters etc etc just basic A to Z 0 to 9 underscores and colons uh not colons forward slashes and those are all the fine characters I Think you can also have dots but you know if you’re putting characters like that then I don’t know what’s going on there and once again just same as items we just want a supplier instead of doing a new item we’re going to do new and you’ll see IntelliJ shows Us all of the default block classes that we could use here so we’re just going to use a normal block for this tutorial in the future we’ll cover other ones and inside of here you’ll see just the same as items we need to give it some properties so it knows how it will Function for example slipperiness and you know other things like hardness etc etc so we’re going to do block dot properties Dot off and then we can do Dot and we can pass it any of these different um things here so for example one thing you will probably want to do is Maybe the map color right so the color that it shows up on a map and that will ask for a map color so map color dot and you’ll see all of the different map colors and now I’m just going to do color green because my block is going to be green Let’s just put this on a new line and put these on a new line so we can train some more properties here we can also do stuff like destroy time or alternatively you can just do strength you have strength with a float and a strength with two floats Least strength with two floats is the hardness so how long it takes to break basically and then also the explosion resistance so how resistant it is to explosives if we use the single float that will just put the same value for both so I’ll just do this one um we’ll say Five for the hardness and maybe 17 for the explosion resistance and then we can get other properties I’m not going to go through all of these you can choose which ones you want most of them are fairly obvious we can actually do something fun now with 1.20 we can specify the instrument That it should play for note blocks so you can say Note Block instrument and you have all these different instruments and you can also probably create your own let’s see what is this is it an enum it’s an enum can we make our own it doesn’t look like we can Unfortunately not without a mixing anyways which is a bit of a shame but it’s it is what it is what else can we do that’s just a little bit fun maybe okay let’s talk about a light level because that’s something a little bit more complicated So when we say a light level it asks for a two int function of a block state so this means that we have a block State and based on that block State you can provide an integer which is the light level so obviously 0 to 15. so basically To do this you just do value which is the block state and then just give it a number so um five per example um I prefer to just name this state though so we know it’s the block State and obviously you can do something dependent on that state so you could say States dot gets value for example and if you had stake properties which is something we’ll cover in a future tutorial you could say based on you know um whether it is on then you could say five or ten for example um obviously we don’t have that state so We can just give it something default I’ll say 10 for this one and since we’re going to be covering loot tables we need to talk about that so that’s not as simple as just a loot table exists we have to make a loot table for all of our blocks that we want To drop for something now I want this block to only be minable by iron pickaxes or above so we actually need to give it the property requires correct tool for drops and that basically means you have to have the correct tool before the before you can actually mine the block So that’s a very important property that you might want to add and I believe also you can copy properties here instead of just doing them yourself so say for example I wanted to copy blocks dots anvil then that would copy the properties from the Anvil and then you can also add additional properties On top of that or overwrite existing ones if you want to look at the vanilla blocks to see what they all are and their different properties you just come into this blocks class here and you’ll see every single block in the game so obviously it’s going to take a Minute to load because there’s loads of them but you can just come through and you can see all of their different properties here all listed across like this for example you can supply like push reactions for Pistons so I could say push reaction push reaction Dot destroy right so if It’s pushed by a piston it destroys the block a lot of these properties are new for 1.20 because they used to be in something called a material which would Define a lot of these properties but now they are all just part of the actual block properties which is great But that’s pretty much it for the code once again as we did with the items we need to register this deferred register to the event bus so let’s come back into our main class and just the same with items we do Block in it dot blocks dot register bats now Whilst we have registered a block here the thing is we don’t have an item for our block so a lot of people kind of when they start they assume that registering a block means your registering the item as well but you’ve got to remember that a block is Completely unrelated to the item you can have a block without an item it doesn’t have to have an item think for example um let’s see what what blocks don’t have items in Minecraft for example um pumpkin stems or Melon stems right they don’t have an item they’re just a block so We need to register a block item now generally I do this in my block in it however you can also do this in your item in it I think so that we know it’s an item let’s do it in our item in it and I think that’ll make a bit more sense really So it’s really going to be exactly the same as before registry object but instead of of type item we’re just going to say of type block item now since block item just extends item we can still register it to this deferred register and that’ll be fine now I’ll just call this example Underscore block and it’s got item is equal items dot register example underscore block and then a supplier of a new block item oh block item there we go let’s put that on a new line and inside of here you’ll see that it requires two parameters so it first requires the actual block Which is fairly easy to do we can do block init dot example block now if you try to do that you’ll see we have an error and that’s because it’s asking for a block and not a registry object of a block so you see here this Is a residue object of a block it’s not an actual block so if you recall as I talked about last time these registry objects are effectively A supplier so it’s like a supplier with a string inside of it so to be able to get the object from the supplier we just dot get And then we need to provide the properties like we did before so just a new item dot properties and I don’t think we’ll put anything special on that I might in fact give it a Rarity as well just for funsies so we’ll do a rarity dot uncommon And let’s put these well that should put that on a new line so that if in the future we want to add more properties we can and in fact I’ll do that that and then like that okay fantastic so that’s our block item and that will now automatically be Registered that’s our block registered and that’s our block registry added to the bus fantastic so now we can move on to the resources so let’s do the same as we did before let’s come into our resources inside of our assets mod ID we can see that in the previous tutorial We created this block States folder for us so this is what we’re going to be using today so we need to create a new file in here now this once again same with item this needs to be the same name as your block now we called ours example underscore block dot Json Would be the name and inside of here this is fairly simple since we don’t have any special block States we want to First specify the variance which is an object and we just want the default variant so that means it’s just an empty string and that’s also going to be an object Now in here we specify a model and that will link to our block model that we choose to use for this specific state so when it is an empty string here that just means this is the default state of that block so for example when I talk about States I’m talking for example Um let’s think a furnace for example right it has four directions that it could be those are different states that’s known as I a direction property so that’s four states north south east and west additionally it has a property for whether it is on or off I think it’s actually Ignited or something is the name of the property something like that oh lit there you go it’s called lit so you have those two states as well so that means you actually have eight possible different States since you have the four directions and the two um lit States So this here is just the default State we don’t have any special properties that we’ve added so we just leave it blank okay then inside of the model we say first our mod ID so mine is tutorial mod colon then block forward slash and then whatever the name Of our model would be so mine is just going to be exactly the same name I don’t want to get it confused with anything else so we just keep it the exact same name and that is our block State done now a lot of people will move this onto this same line here Because that just keeps it a little bit cleaner but just just kind of show off more so what’s happening here I’m going to put it on separate lines so I’ll just go through this one more time first we are specifying the different block State variants now the Only variant we have in our block is the default variant so because it’s default we leave it blank then this variant needs to specify the model property and we say that this is in our mod ID block and example block so this is referring specifically to assets Because it is by default an asset and then our mod ID and then it knows it’s our model because we’re specifying the model property and it comes inside models and it looks for the folder of block which we have right here and then it looks for a file with this name right Here example underscore block so let’s create that file for example underscore block dot Json and this is in models block so in here we just want the default model so first we need to specify same as we did with items we need to say what model this parents from So ours is just going to be a normal block we don’t want anything really special with the model here so we can say the parent is block forward slash Cube underscore all now once again same as before generally the recent trend is to prefix this with Minecraft codon so we’ll do that as well just to keep with the trend and consistency with Minecraft so what is happening in fact I’ll talk about that once we have finished this model um so we need to specify the textures same as before with the items now the texture we’re specifying for This model is all and we’re saying that it’s equal to tutorial mod so our mod ID colon block forward slash example underscore block so whatever the name of our texture is okay let’s just go back through this again and I’ll go ahead and explain everything so first we specify the Parent model this specifies the things such as the different shapes that make up the moral and also the different texture layers that you could have inside of that model say for example an anvil or a brewing standard may be a better example a brewing stand has a special model and it Has multiple different textures in different places of that model so you may have in the brewing stand for example you may have base which would specify the base texture and you may also have something like um I don’t exactly know what they call it but it’s probably something along the lines of Stand which specifies that texture too but for us since we’re going to be using Cube all that means it has the same texture for all of the sides of the model and they won’t differ between them if you wanted a different texture for different sides you would need to Specify a different model here instead of cube all for that I would just recommend looking at vanilla models and seeing which which ones do that I’m sure there are vanilla blocks which have different textures on different sides so just go ahead into your assets in your Minecraft installation Try and find the model you want and see what it parents off of then we specify the different textures that will be used inside of this model so Cube all only specifies one texture and that is the all texture and we’re saying that is a location of Tutorial mod so by default once again this is an asset so it knows it’s inside of assets then it looks for tutorial mod our mod ID and then it looks for Block so it knows that once again this is a texture since we’re specifying it’s the textures so it looks inside of Textures and then for the folder block as we’ve said here and then it looks for a file example underscore block so obviously we then need to actually have that texture so luckily I already have this two hand which I’ve once again stolen from my 1.19.3 tutorial And that is my texture here same as before this needs to be a power of two so 16 by 16 is kind of the recommended size for a texture okay fantastic so that’s pretty much it but we need to talk about loot tables and also we need to do some stuff with tags So let’s go ahead oh first let’s do our La all right Lang so let’s come into here and in here all we need to say is block dot tutorial mod but example underscore block and then we just say example block okay there we go that’s our Lang and Also we need to do the model for the item that’s very important too think of for example sugarcane it looked like a normal item that places down a block so it has a different model so for that we need to do the item model now luckily since we’re doing just a Normal kind of model we want ours to just look like a block in the hand we can just do it fairly simply really so once again this needs to be the exact same name as what you called your item in the block item registry so I just called mine example underscore block And this is super simple so since we’re parenting off of our model that we specified here right we want this to be the exact same as our block model we just say parent colon tutorial mod colon block or slash example underscore block and this just means that it will Use this model right here for the model of the item fantastic so that’s all we need for the Assets Now we need to create some data so we need to create a data pack by the way this is technically a resource pack right here this assets tutorial mod this Is our mods resource pack it’s not a technical resource pack in the way that you cannot just turn it on or off but it is a resource pack in the same way that Minecraft has their own resource pack so we need to create a data pack which Allows us to specify Loop tables and tags and things like that so let’s create a new fold folder or directory inside of our resources and we’re going to call this data not data that is a misspelling data there we go and inside of here we’re going to probably want multiple different Directories we’ll start with just our mod ID so tutorial mod and inside of here we’re going to want to create a new file or a new folder my bad once again directory for looped underscore tables now obviously if you don’t want your block to drop anything then you don’t Need to do this but I do want my block to drop something so I need to do this and then here we’re going to create another folder for blocks and then create a file or whatever our block is called so mine was registered as example underscore blocked so we just Put that in here now it doesn’t actually need to be called your block name but generally that’s just best practice to keep your loot table the same name as your block so now we actually need to create a loop table now this is luckily fairly simple since There is a great website known as misode.github.io and they have a bunch of different generators if we come to their main page you can see they have generators for tons of different things now we want a loot table so we’re going to use that and we’re going to give it a preset here So I’m just going to preset off of something default like Acacia log and you can also default to 1.20 now what we’re going to want is we’re going to specify our item that we want to drop so for us we want to drop tutorial mode hold on example underscore block And you’ll see that shows up as this little thing here I believe you can I thought there was a way to change the texture so it shows up as it actually is but apparently not so that doesn’t really matter um I believe you don’t actually have to Specify the random sequence you can just leave that blank and that will use the world seed for your sequence however if you wish to specify your own random sequence you can do that that’s fine but I’m just going to leave it blank because it doesn’t really matter for a block That only drops itself however obviously if you wanted it to maybe drop multiple different items you could say add another item here and it drops Stone maybe it drops um five Stone and only on a condition of a um check that it is raining and not thundering right you can do these Different conditions and misload makes it really simple to actually do that but I’m not going to do that I’m just going to leave it kind of as the default and I’m going to copy it so we can press this copy button down here and then we can close this this will Obviously be linked in the description by the way we can come back into IntelliJ and just paste it in now I’ll briefly just go through this I’m not an expert in Loop tables so I might not be have a perfect explanation but I will try my best to give a rough Idea of what’s going on here so we’re saying that this loot tables type is just going to be using the block type we want this to only happen on a block not on say a chest opening or an entity dropping then we’re going to specify the different pools so these are the Different kind of um a pull I guess I don’t really know a better way to describe this other than what it says it’s pools so it’s a different basically things that can drop from it so on the first pull which is this object here we say that this rolls once And you can optionally supply the bonus rolls for how many times it may roll on a bonus now we just set this to zero because we don’t want a bonus roll then we specify the entries for these roles so our entry will just be the singular entry so it will always be this But you could specify multiple entries and then that means it could pick either this or this depending on what it rolls as so our entry here is saying it’s a type of item and this is the name of the item that it will drop which if we go back Into our item in it we can see is what we’ve registered our block item as we called it example underscore block prefixed with our mod ID of course example block and we’re saying a condition for this pool is that it will survive an explosion um so that’s just basically what most Blocks do really when they drop their loot table they have a condition that makes sure it survives the explosion okay and that’s pretty much it for the loot table now what we will need to do though is we’ll need to specify some tags for Forge or more specifically Minecraft So let’s come back into our resources let’s create a new directory this will be inside of data but this time it will need to be the Minecraft data so what we’re doing here is we’re modifying the Minecraft data pack so inside of here we’re going to want another directory for tags And then another directory for blocks and then a nerva directory for minable and inside of here we’re going to want a new file and this will be this file will be called whatever tool you want to be able to be used to mine your block So I only want my block to be mined by a pickaxe so I will call this pickaxe dot Json let’s say I wanted it to only be mined by a hoe I would call it ho.json etc etc you get the point so I’m going to leave it as pickaxe.json now inside of here This is fairly simple really we first create the object as usual we specify that we don’t want to overwrite vanilla so we say that replace is false if you set this to true this will overwrite the vanilla pickaxe Json then you can say the values now this is An array so we use square brackets and then we can just pass in whatever we want to add to this pickaxe Json so we just want to add our block so we say tutorial mod colon example underscore block fairly simple let’s say you wanted to add like a vanilla block here you do Minecraft colon acacia underscore right it’s very simple that’s how that works and you would do the same for any other tools that you wanted to work you can add multiple tools as well you don’t just have to use you know um one tool for one block you could use Multiple tools for the same block as well then let’s create the forge shall we so if we create another directory now this one will be board slash X or slash blocks and that’s inside of the data folder by the way and in here we can create a file for needs underscore never right Underscore at all dot Json now this means that you would require a level of never right for this to work so once again it’s the exact same as kind of the pickaxe Jason really so we specified that we don’t want to replace vanilla or in this case we don’t Want to replace Forge and we specify the values like this now this is only because we’re doing never right however if we want Iron which we do we do want iron in that case we would come into Minecraft tags blocks and create needs iron tool but for never Right and I believe gold as well I believe is the other one these are Forge tags instead so that’s a little bit confusing but I will show you what I mean so let’s create a new file here in Minecraft tags forward slash blocks and inside of there we want needs Underscore iron underscore tools dot Json let’s put the same thing in here so basically this gives you kind of a rough idea of how it works you have never right and gold inside of Forge tags and you have iron diamond stone wood inside of the Minecraft tag I hope that makes sense uh if not I will re leave a document in the description that kind of covers this whole tool system and how it works uh it will talk about maybe like 1.16 or 1.17 I forget but don’t worry about that because it’s Exactly the same as it would be in 1.20 that kind of thing hasn’t changed so that’s all well and good and theoretically this should all work now so what we’re going to do is we’re going to close these little files here now I’m actually going to remove the Never right tool and as such remove this Forge directory because we’re not going to need that for now in the future we’ll be adding that back but not at this current moment so I’m going to delete that and I’m just going to leave the iron tool and I have just realized I’ve Accidentally called it needs iron dot tool so that’s actually not going to work we need to make it iron underscore tool it’s little typos like that that you need to make sure you don’t have because that will cause it to not work but from that let’s go ahead and let’s Run the game so once again grab your configuration if you don’t have it go into the Gradle Forge Gradle runs ground client double click it and that will run and I’ll see you in the game all right so we are in the game now I’ve already tested Everything I just wanted to make sure it worked um but if you do slash give at s tutorial mod example block then you’ll see that gives us the block and you’ll see it has the Rarity like we specified on the item properties and if we place it down you’ll see it has a Light level you can see there’s a light around there just in case you cannot see that we’ll do time set night and you’ll see that has a light level now what else did we do I think we specified jump or something what else did we Specify if we have a look in our block in it we can see that we specified a map color which was specified a push reaction so let’s find an instrument so let’s go test those so let’s grab that subscriber piston piston and we’ll go ourselves a redstone block Boom and boom you can see that it breaks it perfect that’s exactly what it should do because we said apist reaction of destroy and we should also see that if we give ourselves a map yeah you can see that area has increased it’s only a little Bit darker since we only sell it to Green but that does actually work and the other thing was instrument so if we grab a note block there we go and if we place this down now I don’t have audio turned on so hopefully that is playing the correct instrument I’ll only find Out when I’m editing this um what did we actually set it to we set it to banjo so this should be playing a banjo instrument right now um I’m very much hoping this is working but I’m sure we’ll see later it should do there’s no reason it wouldn’t really And then let’s test uh breaking so we said it should break with an iron pickaxe or higher so let’s test that with a stone pickaxe and what it should do is not drop anything correct and I’ve already tested a diamond shovel to check that that doesn’t drop I’m not going to do it Again because it took forever so we’ll just get rid of those and we should see it does drop with an iron pickaxe which it does fantastic so yeah that’s pretty much it um if you had any problems with this tutorial be sure to join the Discord which is linked in the description it’s Not just for modding health of course we have other stuff going on in there as well so come join come and hang out and get help with any modding issues that you have and that will be linked in the description and obviously if you found this tutorial Useful or enjoyed it then please do be sure to smash that like button and subscribe so you know when I release the next one which will be on Creative tabs and getting these items in a creative tab because it’s really annoying to have to slash give them every single time And uh yeah I’ll see you in the next tutorial good bye Video Information
This video, titled ‘1.20 Minecraft Forge Modding Tutorial – Blocks’, was uploaded by TurtyWurty on 2023-06-15 17:30:04. It has garnered 1928 views and 59 likes. The duration of the video is 00:37:43 or 2263 seconds.
In this video, I show you how to create our first block and create its loot table!
In the next video, we will create a creative tab and add our items to it as well as how you can add your items to vanilla creative tabs too. Remember, if you have any problems, please join the discord that is linked below!
Links: Patreon: https://www.patreon.com/turtywurty Discord: https://discord.gg/BAYB3A38wn Github: https://github.com/DaRealTurtyWurty/1.20-Tutorial-Mod
Learn Java Links: https://java-programming.mooc.fi/ https://www.codecademy.com/learn/learn-java https://docs.oracle.com/javase/tutorial/
Java Support Server: https://discord.gg/GzvQjhv
Misode (Loot table website): https://misode.github.io/
Chapters: 0:00 – Intro 0:25 – Registry class 0:50 – DeferredRegister 1:30 – RegistryObject 2:45 – Block Properties 8:45 – Registering the registry 10:00 – Registering a BlockItem 12:30 – Blockstates 16:00 – Block Model 20:00 – Texture 20:35 – Translation files 21:10 – Item Model 22:50 – Data directory 23:15 – Loot tables 28:40 – Harvest Level/Tool Tags 34:00 – Testing 36:50 – Outro