Hey guys what’s up its mr. crayfish and welcome back to my modding tutorials now before we start today I just want to let you know that the patreon is finally live I’ve got it all set up I was making sure that it was perfect before I actually released it because I didn’t Want to have something that was incomplete and I did get some of your got guys feedback on the last video and kind of applied it to it now so here it is you can go ahead support it I’ve also updated the rewards so we now have Actually three rewards $1 $5 and $10 I’m not going to go over like oh what you get in them you can check it out yourself by going to the link below but it’d be awesome if you guys go support me because it’s going to help me continue the development and maintenance Of all my mods and also keep these our modding tutorials running but anyway let’s get back into the tutorial today and I probably guessed it from the title we are going to be adding in a custom block so it’s very similar to adding in items and let’s just get straight into It that’s not I’m not talk about it let’s just get straight into it so the first thing that we are going to do is go to our initialization package over here and when it creates something we’re going to create a new class and want to call it mod blocks pretty simple way and We’re pretty much going to be having exactly the same method so what we’re going to do is we’re going to copy these four methods there paste them in there let’s just get rid of the code inside of them and before we do anything what we’re going to do is we’re actually Going to change this around so if we’re going to get rid of that item parameter there and instead change it to block block and make sure we import this correctly so what we’re going to do is organize import so ctrl shift o and then we should be able to import this now Import block net minecraft up block there make sure you import the right one if you are if you’re unable to do ctrl shift o you can just right click here let’s just put that up a little bit higher source organized imports and that will do exactly the same thing Then what we’re going to do is change this item here to item dot get item from a block and then just inside as the parameter there pass in our block parameter up here and then here what we’re going to do is change that to block I’m assuming get registry name yep That seems to be correct now again it’s very simple and pretty pretty obvious how you actually start creating a block so we go public static block and then we’re going to call this cheese now I’m adding a cheese block so we’ve got a cheese item but I want to make it so you Can actually like turn that into a block and use it for some building and then what we’re going to do is new is cheese equals new block cheese semicolon on the end there we’re then going to create this block cheese class but what we’re going to do is create another package Here so got one for items we’re going to create one for block so right click our tutorial package there new package at the end just do dot blocks finish and inside of that blocks package go new class block cheese and then what we’re going to do is the super class is going To be net dot minecraft dot block dot block finish then add the constructor here and what we’re going to do is we’re going to get rid of this material parameter here and what we’re going to do is simply change this around here so this is like the material of your block So if you go material dot you get a list of all these types of materials that we can use as air and we’ll bury a cactus and just a bunch of other things so we’re going to find something that’s close to a cheese we might what is coral We might do cake that sounds cool I think I might use cake is it sometimes what it would do is it will give it like default sounds so if you did it as like material rock we’ll have the rock sound now let’s go back to our model ox class here and Import block cheese then inside a register here again what we need to do is good game registry register and then just pop in the cheese object or the cheese the block here cheese inside of register renders we’re going to simply going to do register render and then Pass in our cheese block and then now again we have to do go into our client proxy here and this time we need to call mod blocks start register renders make sure it registers those blocks all the inventory models now we need to actually give it a none localized name and also The registry name like we did for the item here so as you can see we’ve got set on localized name and set registry name inside of our custom item classes we need to do exactly the same for the block class as well so we’re going to go To our reference class here and we have one for the tutorial items so an enum here for tutorial items we’re going to create exactly the same thing pretty much for tutorial blocks I’m going to put in cheese there we’re simply just going to copy all this here change that There to tutorial blocks and then we just need to do cheese as our as our unlike last name and then our registry name is going to be block cheese now let’s go back to our block cheese class and then let’s do those is set and localize name reference tutorial blocks Cheese dot get unlike a live name and then our registration you can do that set registry name reference dot tutorial item our tutorial blocks I mean cheese get registry name so that’s pretty much it for the code what we’ve got to do now is create a couple of JSON files one to Define the model and also one to define the block state now a block state is literally determining like the model we’re going to be using depending on the state of the block so pretty much block states are another way to say metadata for blocks now we’re not going to go Into metadata in this episode right now because it can get quite confusing we’ll be doing that as a separate tutorial this is just literally showing you how to do the most basic block you can in Minecraft so what we’re going to do is we’re going to right click on our assets C TM or your whatever your mod ID is we’re going to right click on that new package and then what we’re going to do is type in dot textures dot block blocks I mean not block blocks you make sure you have that correct and I’m going to Check in a texture I made just before this video of what I’m going to be decorating this block as so it’s just like a kind of a plain at cheese block so we need to go copy this here going to our working directory go to source main Resources assets see TM textures go into block here paste that there so all our block textures go go in this folder all your item textures go on the items folder so that’s where we have our cheese and our cracker item texture now we’re going to go back here we’ll do This in Eclipse we’re going to create a new package so right-click assets dot c TM or whatever your mud ID is new package and at the end here we’re going to do dot block States and then what we’re going to do is right-click that new entire text file And what we’re going to do is paste in this now I’ll put a pastebin in the description below because I don’t expect you to write this out there’s really no point now I’ve just copied the andesite model but what you need to do is simply change this here this model around here to Whatever your mod ID is so CTM then colon and then we’re going to put out the unlike alized name there so ours is cheese I’m going to go ahead save that and then what we’re going to do is go into here source main resources assets CTM block state and then I’m pretty sure We’re going to name this block cheese which is our registry name press ok and I made a mistake there we need to make sure we put Jason on the end refactor rename dot jason okay then go into models and then what we have actually got to do is create a separate folder For all our block state models for our block models I mean so I’m going to go open here this might be a little quicker asset CTM models and then inside of here create one called block go back to eclipse now and we go to our models here And you’ll notice we’ve got now got two separate folders when you create a new file in here it’s a new untitled text file then what we’re going to do is copy in this code which allows you to set the texture or sets define the model and set The texture so again I’ll put a pastebin inside the parent is just going to be the default cube ol so this will texture basically a full block with the texture that you define down below here so textures and then the texture oh is blocks brick so we’re actually going to Change that to our our cheese block texture so we’re going to type in our mod ID then colon blocks forward slash cheese press save and then just open that up source main resources assets CTM click on textures and then click on block and I’m not block hemming click on model Then click on block and then we’re going to name this cheese dot dot Jason press ok then inside of item here what we’re going to do is create a new untitled text file because we need to define basically a model because you have to define a model for the block and The item whereas an item you just have to do the item so again we’re going to do this very simple again now I did actually make a mistake in the previous tutorial what you actually need to do is for both of your item models we want to Do is simply just get rid of this display bit here and then also that comma there press save and this will actually fix the model item up because well I think I already fixed the other one up hold up ok it wasn’t opening wasn’t opening in Eclipse get rid of That and also get rid a comma save that and it will look a lot more nicer in your hand when you’re in game now we’re actually going to copy one of those so copy that paste that in there we’re going to change this instead of items We’re just going to change this to block blocks I mean save that and then again we need to put that into source main resources assets CTM models then click on item here and name that block cheese dot jason ok now if you go ahead and we Run the game now we should have a block I’m hoping fingers crossed I got this working first time okay I made a big mistake we need to go back to our mod class here we actually forgot to initialize and register the blocks so I’m going to go under our mod items here Go mod blocks dot in it and then mud block start register can’t believe I forgot to do that now if we go ahead and we run the game now looks like everything loaded up as it should let’s go single player load up our test world here then we’re going to Do would /give play here CTM which is our mod ID : block block cheese and there’s no such item alright so it seems like there’s been a couple of changes in 1.9 which make it so now you have to kind of explicitly register an item block and basically what an item Block is is minecraft handles everything through items it doesn’t have like items and blocks it handles through everything through items like in your inventory and you actually have to create an item for your block you don’t see that in the background but that’s what you actually Happens so what we’re going to do here is we’re going to create an extra method we’re going to do one under this register here called private static void register block then it’s going to take in a block parameter and then first what we’re going to do is Move this here so I copy that out put that there and replace that cheese there with a block then what we also need to do is do item block lock equals new item oops item block then pass in the block parameter as for the item block there Well what the hell and then we also have Sneed change this here change that to item that will fix up that mistake there but make sure you import this correctly so you should have up here import net minecraft got item to item block and then we’re Just simply going to do item dot set registry name and then we’re going to do block dot get registry name so we’re getting that from here and then we need to do game registry dot Register item and I think that should work and then we just need to inside of the register Method here go register block and then pass in cheese and we run the game now and hopefully this works because I just spent 20 minutes figuring this out and it’s going to take a while to edit there’s our video down now so hopefully this works now oh well that’s a good Sign I guess we got the item in here but it’s still not kind of correct okay to fix that up we’ve simply got to do is fix up our model definition here so go over to your item folder here right click on block cheese we’re going to Open that with the text editor here we’re going to change this here to block dot cube underscore ol and then change this here textures o2c TM blocks cheese now one last thing I almost forgot to do was to give our block a name so under our names here we’re going to separate Them by a line because now we’re going to have blocks here as well we’re going to type in not add and we’re going to type in tile then dot the unload collides name say cheese and then dot name equals and then we’re going to call it cheese block I’m going to go ahead and save that so there we go now guys we now have our block we can place it down it has its nice model we can break it now there is some couple of properties we can change around and I’ll go over them quickly Right now so if I just quit here and we go back into our block class we’ve got a couple of things that you guys can do now I’m just going to get rid of that creative tab one if we just go here we can do set hardness and then you can Decide how hard your block might be so you can play around with this valley but basically it’s a flute value do 1.0 so that’s pretty much like default you can do set let’s have a look here so you can do like something like set block unbreakable which is something like Bedrock and it won’t you won’t actually be able to break your block at oh I can set the light level so if you want yours to have any light on it you can do that play around with that what else we got here we’ve got sound type so you can set What sound your block makes and that’s pretty much like the main ones you want to be using to kind of like customize the properties of your block now I’m not going to show them off because I’m actually running out of time right now but that’s pretty much the basic block Guys hopefully you enjoyed now remember I am going to be posting the source code for my patreon supporters so if something went wrong in your code you can actually go ahead download this code have a look at it compare it to your own and see what mistakes you may might have Made but that’s it guys hopefully in blitz it guys for this tutorial but that’s it guys that’s it for this tutorial the next one is most likely going to be how to add your own custom block model then after that we’re going to do like crafting recipes and then I’m Still deciding what we’re actually going to be doing next after that so make sure you guys look out for them and the next tutorial should be coming really soon I know this one was quite laid and that is because I actually had exams for Union I had to like study and Didn’t have any time to actually make a video explain this to you guys but I will see you guys next time bye bye Video Information
This video, titled ‘Minecraft 1.9: Modding Tutorial – Custom Blocks (#4)’, was uploaded by MrCrayfish on 2016-06-27 12:30:00. It has garnered 51127 views and 809 likes. The duration of the video is 00:19:03 or 1143 seconds.
● Support this series on Patreon! https://www.patreon.com/mrcrayfish
★ Cray’s Social Media Links ★ ● Website: http://www.mrcrayfish.com ● Facebook: https://www.facebook.com/MrCrayfish ● Twitter: https://twitter.com/MrCraayfish ● Instagram: http://instagram.com/mrcraayfish ● MinecraftForums: http://www.minecraftforum.net/user/596140-mr-crayfish/ ● PlanetMinecraft: http://www.planetminecraft.com/member/mr_crayfish/
★ Sponsors ★ Looking for an affordable but good performing Minecraft server? Check out PickleHosting and use the code “CRAYFISH” to get 20% off your the lifetime of your server! https://billing.picklehosting.com/aff.php?aff=421
Blockstate JSON: http://pastebin.com/wPb7pz9k
Model JSON: http://pastebin.com/xHFF5rkT