Hey guys it’s Thomas here with techno vision and welcome to the next part of our modding tutorial series in this episode we’ll be creating a custom basic block and it’s not going to do anything special yet that’ll be in a later video but it’s just gonna be a basic block That you can place down and you can brake so first thing you’re gonna want to do when you’re in your IntelliJ is come to the registry handler class here and that’s in the utilities and you can see here that we registered our our items here and for the sake of learning Purposes I’m gonna actually register all of the objects you make in this class but I just want to mention that you’re welcome to register these different objects you know like items and blocks and separate classes so if you’d like to have an items class in a blocks class You can totally do that I just want to put it all in one place you can see sort of what it looks like side by side alright so once you’re inside of the registry handler class first thing you want to do is create a new deferred register for our blocks so right below This items deferred register we made just make a little space and we’re gonna type public static final deferred register and this is gonna take in the parameter of block because we are holding blocks in this deferred register and the name is gonna be blocks at all capitals this is gonna equal a new Deferred register of course and the arguments that we’re gonna pass in is pretty much the same except for block so Forge registries dot blocks comma and then of course you want our mod ID so and I believe it’s yeah we haven’t registered statically so tutorial dots mod underscore ID and again replace Tutorial with the name of your mod of course and a semicolon at the end of course and we also have to import block it’s very important and import it from net minecraft I’ll block alright so now that we have this deferred register the next thing we actually want to do is Make sure that it’s registered so if we go to this init method we have here it closed up on me make a few spaces or I guess just one and below this items not register we have here we’re gonna do the same thing but with blocks so blocks dots register And arguments again are going to be pretty much exactly the same in fact they are the same so we can just copy this whole line up here right-click copy right-click paste and send me clone at the end here and I forgot to add the s there we got blocks because we need this To be the same name as this of course so that’s gonna make sure that it actually gets registered in our actual mod when it when time comes for that and now we actually can make the actual block itself okay so you can see here on the Left hand side that we have an item’s package and we’re gonna make another one for blocks so let’s just close this up real quick and in our comm dot your name dot the name of your mod package right here we’re gonna right-click new and we’re going to create a blocks package So package and we’re just gonna name it blocks and hit enter and inside of this package of course is going to be all of the different classes that we use to hold our blocks and also a block item base which again you don’t have to use But in my case I’m gonna use so now we can actually make the items so right below our items tag we ever here or I guess our notes we can make a few spaces and I’m gonna add another note slash slash and this is gonna be blocks and Then I’m going to add another note below it maybe two spaces is time slash slash block items so you might be a little confused here basically in in Minecraft since forge you know in particular there’s actually two types of an item or a block rather so there’s the actual Block that you place on the ground and that you mine of course and then there’s the block item which is what is held in your hand and they’re actually two separate things and you have to register them separately as well which is kind of confusing for people Who are new to to forge and modding but I promise you it’s not that bad so first you want to make the actual block so let’s type public static final and this is gonna be just like with the items or registry object so registry object except this time it’s gonna take in a Block and the name of this is going to be the name of your item more or less your block underscore block so if you’re making something like let’s say crying obsidian you know that’s what you’re making for your block it’s going to be crying underscore of the city Underscore block just like that so you want the name and then an underscore block in my case I’m gonna make a ruby block because we just made a ruby item so ruby underscore block and again use those underscores for spaces but the name does not really matter here it’s Just sort of for the code so this is gonna equal blocks in all capitals my bad blocks okay I’m not supposed today blocks dot register there we go dart register and inside of here again very similar to how we did this up above we’re gonna do the Name of our actual block so in my case Ruby underscore block and a comma and we’re going to use a lambda here to create our or instance our class so Ruby block is gonna be the name of mine colon colon new and this class right here has Not been made we’re gonna make it in a second but just name this class again the same name that you have here but instead of semicolons just to use camel case so again if your block was crying obsidian it would be crying oh not capital crying a city in blocked just Like that and that should be how you name your class this is actually kind of important so again mine is a me Ruby block and we’re gonna make this class in a second so go over to your blocks package here this is where that that ruby block is actually going to be so We’re gonna right-click new Java class and we’re gonna name this ruby block again the same thing we named it right here in the lambda we’re gonna enter and I’m gonna add this to my git repository but don’t worry about that you’re not using that right now so this class is Ruby block class is going to let’s take a look at our items real quick item base so you can see item base extends item and that means it’s inherently inheriting everything from the item class well in our block base here or I guess this is in a block base but it’s a Specialized class for this particular block it’s gonna extend block so extend block and we’re probably gonna have to import block import class from net da Minecraft op block and hover over it again and you want to click on create constructor matching super and we’ll deal with this in a second but just move It down a little bit so ruby block is extending block it’s inheriting everything from the block class and that’s what we’re gonna do is super here in a second so what we want to do is set its properties to whatever we want this this block to be so let’s get rid of Properties here because we’re gonna make our own and inside of here we’re gonna type block instead of super I should specify block dots properties for the capital P dot creates and then in the create method we’re gonna pass in a material and this material is going to Be the material of your block so material dots and you can see there’s a bunch of different options here these are all different material types for blocks and let’s see what should we choose well a ruby block is gonna be similar to like an iron block right so I Guess it doesn’t really matter we can always come back to it but I’m gonna make mine material dier n– where is it material de iron there we go we can double click that and you can see here it is material iron in all capitals and we can actually move this a little what Is this a parenthesis parenthesis and a semicolon down a bit and we’re gonna add some more properties here so you can indent with a tab here a couple times and I’m going to add dot hardness and resistance and this is going to actually set the hardness value and the resistance value And these are all over the place in Minecraft but you can find them by just going on the Minecraft Wiki in my case I’m gonna make my hardness 5.0 f comma and then I’m gonna make my resistance 6.0 F with this I’m not gonna add a semicolon because we’re not done yet So again it IntelliJ is really nice it’s gonna tell you what is what the hardness value here is how long I believe it takes to mine your block and the resistance value is how long it takes or not how long it takes how easy it is to Be blown up by TNT so you know how wool is like you know super easy to blow up with TNT but obsidian never gets blown up that is what this resistance value will be and the higher the hardness value is before the F the harder it is To break and we can add another dots here and you can keep adding dots here and you can see there’s a bunch of different options you can play around with all of these but I’m just gonna show you a couple just so you sort of have some examples under your belt so I’m gonna do dots sound don’t sound and instead of here this dots sound method we’re gonna pass in a sound and this is you know just like it sounds gonna be the sound of the oh if that was a fun pun just like it sounds Um so just like it sounds it’s gonna be the sound type of the the block so sound type dots and you can see there’s a bunch here since I did iron I’m gonna do dot metal dot metal there we go and again all this is doing is setting the Sound type to metal by and that’s basically making the sound metal when you walk on it and when you mine in I believe as well alright so the next property we need to set is the harvest level and we can come down here and type dot harvest level and we’re gonna pass Into here a number between zero and three and the number zero is gonna correspond to wood one is gonna correspond to stone and gold two is going to correspond to iron and three is going to correspond to diamond and essentially what these numbers mean and what harvest level means is the tier of Tool that you need to actually harvest this block so what does that mean well in minecraft you know the Abyssinian block for example you need a diamond pickaxe to harvest an obsidian block otherwise it’ll just disappear as soon as you mine it same thing with the redstone ore or Diamond blocks for example those are those or blocks you can’t harvest them unless you have an iron pickaxe so what this harvest level is saying is the number that you pass into it is the minimum required tool tier that you need to harvest the block So I guess a way to say this is let’s say you pass in one what that’s saying is you need to harvest this block with at least an iron sorry a gold or stone pickaxe otherwise it will not harvest if I were to put the max number of three That would require a diamond pickaxe to mine the block and if I wanted to put zero in there that would mean that I could use any of the tool types I can use wood stone gold iron diamond and it would all work so the higher the number Is all the way up to three the higher the tier you require to harvest this block so because this is similar to an emerald block I want it to be I want you to be required to use an iron pickaxe to actually mine it and harvest it so I’m Gonna type 2 because that corresponds to an iron pickaxe and after that we can now set our tool type so dots tool or I guess it’s harvest tool harvest tool and inside of here we’re gonna pass in a tool type so tool type dots and you can See here we have axe pickaxe and shovel so a you know pretty self-explanatory this is the tool that you require to actually mine this block you know axes correspond to wood blocks pickaxes to stone and shovels to dirt and those sort of things so in this case it’s a metal Type block it’s a ruby block so we’re gonna want to use a pickaxe but if you were making for example a wood block a new wood type you would do dot axe and you would set that in or you know if it was dirt you could do shovel but in my Case I want people to have to use a pickaxe and that’s pretty much it we can bring this up this parentheses semi-colon up a little bit file save all and that’s pretty much it for our Ruby block okay so now you can actually go back to your registry handler class because We’re done here and we can import our Ruby block because you can hover over it and import class and that will import the actual Ruby block itself and again this is going to be a different for every single block that you make this specific area it’s not like item base Where we just copy it over this has to be specific to every block you make because the actual blocks all have different values or at least they they probably will so that’s why you have to make a new class every time just wanted to throw that out there so now we have To actually make the block item which is what is held in your hand so right in our block items here this is where all the block items are going to be so just make a space and we’re gonna make a public static final and again it’s gonna Be a registry objects and it’s gonna take in an item but we’re gonna name this Ruby underscore block so you want to take this exact same naming off here right click copy you want to paste it in so whatever you have there you want to take and then add an underscore item so It’s basically the name of your block and then block item so again copy and paste this name and then add an underscore item to it so then we’re gonna do equals and this is going to equal items dot register because it is technically an item and we’re gonna pass In the name and this is going to be the same name we have up here so you can just copy and paste this name up here copy paste and add a comma and we’re gonna make do another lambda statement here so two parenthesis with an arrow Let’s that up real quick an arrow and this is going to make a new block item base item base and this is gonna be we need to pass something into this of course we’re gonna pass in our block so the block we just made Ruby underscore block I’m going to Right-click copy and you want to paste that into your block item base paste it in paste dog gets there we go and I know this is just barely about to fall off the edge of the screen here but again if you don’t understand lambdas that’s okay that’s really not the point in this Video pretty much we’re making a new instance of our block item base class which we’re gonna create in a second here and we’re passing in our block that we made so we’re basically assigning our block here we’re assigning it to the of the block item so the program actually Knows and again you don’t need to use a block item base class if you don’t want to some people say that’s bad practice I’m sure it is but just for the the sake of not having to reuse so much code I’m gonna use one so inside of your blocks Package here we want to right-click new Java class and again same name you put here block item base and this is gonna be for yes ID that real quick this is gonna be for basic block items so again these aren’t gonna do anything crazy but If you want to block item that like you know deletes a chunk or something then that’s not going to be this video not yet at least so this is gonna extend its gonna extends block item because again it is a block item and it’s gonna import this Class real quick and we want to hover over this this red line and click create constructor matching super and just like last time push it down a little bit and we’re actually going to remove this properties here because we’re gonna make that ourselves we don’t need to pass it In we’re just gonna keep block and then block in and you can just name a block actually that’s just simpler so for let’s get rid of everything in super we want to pass in our block value here of course so we’re going to type block And then comma and then we need to pass in of course our properties because that’s what block item requests from its super so we’re just going to make a new item dots properties for the capital P except this one’s gonna have a visit is It a capital P I think it’s a capital P it’s always different I swear item dot properties yeah and with with two parentheses here of course dot group and inside of this just like with our item based class here we have our tutorial tab we’re gonna add in our custom tab as Well so tutorial dot time and this is just gonna make sure that our item or our block item is actually in the creative tap but again if you wanted to use a vanilla items tab you would just do item group dots and then you would Get a vanilla one but I’m gonna use our custom tab that we just made in last episode so tutorial dots have and we have to import tutorial import class and that’s pretty much it for this block item base class again you don’t need to use this if you don’t want to but I’m Just gonna to limit code reefs so go back to your registry handler class and hover over block item base and make sure you import it okay so now things are gonna start to get a little crazy because we’re gonna actually make the JSON files to register the the actual Texture so and there’s actually a lot of JSON files involved with blocks a lot more than items so just make sure you pay close attention in this part so instead of your resources folder and I guess actually first we should close out of some of these tabs here just because We have so many files have all there we go so instead of our resources folder here we can go to assets thought the name of your mod and first thing we’re gonna want to do of course is make sure that we actually have the name of our Object set so go to Lang your Lang folder and en underscore us JSON double click that and right below our item group or I guess so we can do above we’re gonna make a a new entry here and this is going to be block I guess I have To add some quotation marks quotation marks and then inside of that block dots your mod ID in my case tutorial again your mod ID is what you have right here set in your app mod tag in the main class so block dot mod ID dots and then you’re gonna go to Registry Handler and copy this name you set right here Ruby underscore block just copy it go back and paste it in so it’s block dot your mod ID dot the name of your your block and colon and this name this name is going to be again Whatever you want it to be so in my case I’m gonna name it block of Ruby and again this is the in game name so whatever you put here will show up in the game and make sure there’s no comma in the last statement and you can file save all all right so Now that’s done we can close out of en underscore US stop Jason now in our assets dot tutorial folder we’re gonna have to right-click create a new directory and we’re gonna name this block States block states hit enter and this is gonna hold all of our block State Jason’s so we can actually go ahead and create that right now we can well I guess first we should make the the models yeah let’s do the models first so instead of models we have our item our item page and I want to actually flatten this out so we can see It so I believe you go up to settings here and go to uncheck compact middle packages and that should show the items there so we can open up item and we can see our Ruby Jason in there so in the models package or I guess as a directory We want to right-click create a new directory and name this block not block with an S just block an answer so now our models file should have the block file and item file and instead of our is it block seats know instead of textures there we go we want to right-click Create a new directory and we want to name this blocks and this one actually has an S so it’s blocks with an S good answer and that’s gonna hold our textures and now we’re done with directories so that all that craziness you can see even I was getting confused It’s a lot so now we need to make the jason’s so first jason if you go into the description of this video there will be a bunch of links to some pay spins so the first paceman you’re gonna go to is the model / block 1 and you can actually I again I Have all of them laid out for you here just for ease of access because it’s kind of annoying to code these by hand so right click copy this model / block go to your IntelliJ and we’re going to go to models block and in our block directory in models we’re going to right Click new file and we’re gonna name this the name that you have set right here for your Ruby block so Ruby underscore block again it’s this name right here not the one in all capitals and you want dots Jason at the end hit enter I’m gonna add it to the repository and you Can right click and paste into it the code and all you have to do now is pretty much change your mod ID in the block name so mana T excuse me is gonna be tutorial and the and again mod ID is right here and the block name is gonna Be this thing again right here this name copy paste it in for block name there we go so just a quick rundown this is saying that the block is a block and it’s a cube so and we’ll be dealing with these later and making them different shapes of course that’s what this is Going to deal with but right now it’s just a basic cube and it’s saying the textures point to our tutorial mod in the block / ruby block that’s where the actual that’s the pathway to the file so we can file save all and now we need to Go to item here and we need to make a JSON for our actual item block so right click new file and this is going to be the exact same name Ruby underscore block it’s all JSON hit enter and we can add it of course now go back to the Description of this video and go to the second link and that’s going to take you to the models item and you copy this right-click copy and paste it back in and this is just setting the parent it’s saying this block item is its parent is the block and it’s saying The block is the parent is the Ruby block so again change your mod ID to tutorial or whatever your mod ID is and change block underscore name to your block name again I have it right here oh there we go right click copy and paste it in Ruby Underscore block just our name and we can file save all now there’s actually one more jason we have to make I know it’s crazy and this is gonna be the block states so go to block States you’re the new director you just made right click new file and this file is Gonna be again same exact name they’re all gonna be the same name Ruby Jason oh now I’m Ruby underscore Jason that’s that’s our old item Ruby underscore Blanc Jason again same name we’re gonna add it and go to the last link in the description and it should take you to This block state space pin and you can copy all this code right click copy and you can paste it in and again change your mod idea to tutorial or whatever your mod ID is and block name to again what we have here Ruby underscore block the name paste it in there we go And this block state is just setting the block state to a regular model and there’s no really real variants but this is what we’ll be using to create custom blocks in the future that have multiple sides with different textures like a furnace things like that that’s what This will deal with but we’re just gonna do a basic one Freight now you can file save all and the last thing we have to do is actually get our our texture so if we go to our desktop here I actually have a texture already set of course for Ease of access but you can make one yourself all again I’ll link another video in the description on how to make a texture with a free program or you can use Photoshop and one thing you want to make sure right click properties again you want to make sure with details that It is 16 by 16 pixels otherwise it most likely will not I know there’s some other pixel sizes that do work but make sure for now it’s sixteen by sixteen that’s very important and you want to name it again the exact same name you have sets in your registry Handler this name so we’re using this name again this name right here this very important name for all of our JSON files and inside of them as well to point to other files and we’re using it for the name of our our PNG file here so Ruby underscore block PNG so go to your minecraft modding folder go to tutorial mod or whatever the name of your mod is go to source main resources assets tutorial textures blocks and you want to drag it into blocks and we can close out of here and if we go back to IntelliJ You can see that in our textures blocks package here we do have our Ruby underscore block type in G so that is working great and now if we actually run the game we’ll actually see our blocks so we’re pretty much done and again to Run the game just go up to the top right here make sure you select run client and hit this green triangle so I’m gonna run the game and I’ll see you guys inside alright so we’re inside of the game now and we can open up our creative menu and Go to the next tab and click on our tutorial creative tab that we just made and there we go we can see our block is inside of the game and it does say block of Ruby and of course we can place it down and has a texture and just listen To sound real quick yeah so you can see that that is the the metal sound that we set and also if we were to for example walk on it real quick you can hear the the walk sound as well just what we set yeah so it’s a little faint but you can Hear it so also we should just test that real quick let’s get a shovel and axe let’s get like a diamond axe so if we go to game mode survival you can see that if we use an axe it will not work very well as a harvestable tool because we set it To pickaxe and same as shovel it will not work very well which is good that’s just how we want it but if we were to use say a diamond pickaxe you can see that we can super easily mine it because that is what we set as our tool type and again We set the the what is it the material the harvest level to iron so we should be able to harvest a with iron you can see it’s taking a little bit time because we did set a pretty high hardness level but a stone pickaxe in and below will pretty much not be able To mine it you can see it’s taking a long time now of course our block is not going to actually drop anything because we’d have to create a loot table and that’s a whole nother video because it’s a little complicated but eventually we will get to that and we will make your Block drop it’s either itself or something custom alright so that’s gonna do it for this episode of our modding series thanks guys so much for watching I hope you learned a lot and I will see you guys in the next episode you Video Information
This video, titled ‘Minecraft 1.15.2: Forge Modding Tutorial – Custom Blocks (#4)’, was uploaded by TechnoVision on 2020-04-30 03:25:00. It has garnered 49574 views and 1717 likes. The duration of the video is 00:28:11 or 1691 seconds.
Learn to code a Minecraft mod from scratch in this complete tutorial series! In this episode, we create a custom block with some unique values.
— Important Links —
● Model-Block JSON: https://pastebin.com/CrfnVSku ● Model-Item JSON: https://pastebin.com/40yUG3J4 ● Blockstates JSON: https://pastebin.com/jLnVTfgs
● Hardness Values: https://minecraftmodcustomstuff.fandom.com/wiki/Hardness ● Resistance Values: https://minecraftmodcustomstuff.fandom.com/wiki/Resistance ● Harvest Levels: https://minecraftmodcustomstuff.fandom.com/wiki/HarvestLevel ● Texture Guide: https://www.youtube.com/watch?v=Sg_znEXBD7k
● Discord: https://discord.gg/ZsB3Eha ● GitHub Repository: https://github.com/TechnoVisionDev/Minecraft-1.15.2-Modding-Tutorial.git
— Music —
● [No Copyright] Chill Lofi Hip-hop ● Phil Smiff – lake.side ● Xori – Dreamin ● DJ Quads – Chillin ● Chill Out Records – Minute Mix
— My Channel —
● Subscribe: http://tinyurl.com/zbc7mwy ● Instagram: https://www.instagram.com/tomm.peters ● Twitter: https://twitter.com/TechnoVisionTV
#minecraft #modding #tutorial