Hey guys it’s thomas here with technovision and in this episode of the minecraft modding tutorial series we’re going to be covering advanced block models as well as making them directional so essentially this is going to be an advanced block and i really recommend that you watch this video all the way through before You attempt any of these steps because it is a lot of steps and you can mess it up really easily so i think for the the best experience you should watch it first and then try to complete the steps afterwards so to get right into it What you want to do is go to the first link in the description and you want to download this new program called blockbench and this is going to be a desktop application that will allow you as you can see here to make really advanced blocks this is also what we’ll be using For entities as well as animating your blocks and entities so it’s just a really useful free application so click the download button and it’ll take you to this download page download whatever is meant for your operating system mine is windows and it’ll download and once you have it on your desktop Which i already have what you want to do is double click it of course and it’s going to install block bench and you know this is just a regular install process so you’re just going to have to wait for it to finish and once it’s done it should automatically launch But if you uh don’t if it doesn’t do that for you you can just double click the uh block bench application here we can get rid of this installer now so inside of blockbench here we’ve got um a a menu here to choose from of different Uh models so what we want is a java block item so click on java block item here and what you want to do is give it a file name so in my case i’m going to name this oven because i’m going to make an oven block so you want oven Then for the parent model you can just leave this blank uh have ambient occlusion checked you can leave box uv unchecked and then this width and height is going to be how high and wide your block is so if you wanted to be within the portions of one Minecraft block you’d want to set this to 16 by 16. i would recommend keeping this to 16 by 16 if it’s your first time using this and then you can experiment with it later so hit confirm and you will get this little menu here that allows you to design your custom block so I will leave a link in the description to a tutorial on how to use blockbench because i’m not going to go through all the features because it really is a lot but essentially what you want to do and i really really recommend you watch that video before continuing because This is going to be a little confusing but first thing you definitely want to do come up to um filter go to plugins and i already have it installed here because i was testing it earlier but normally it’ll say no plugins installed you want to go to available And you want to search for mod utils once you see this mod utils by jtk you want to install it and it’ll take a second here but once it is installed what you want to do is just close out of blockbench and then open it back up again That will refresh this uh this plugin and i forgot to save so just let’s make our item again again the file name whatever you want to name it mine is going to be oven and then leave everything the same hit confirm all right so in order to start designing your Your block you can come over to this outliner here and hit add cube and this will add a single cube to your block bench now with this cube what you can do and uh keeping in mind that this grid here is a 16 by 16 grid representing a Regular minecraft block you can take this cube and you can move it around you can double click it to enter a new mode that allows you to expand it in every direction and essentially what you can do is you can add multiple of these cubes here By going to the outliner and as you add more cubes you can design your block however you like um and essentially make a custom block model and this whatever you design here will show up in the game later on once we complete the the remaining steps so what i would Recommend is mess around with this uh get comfortable with it create some cubes uh what you do want to do and and the tutorial i will link in the description will show this is once you’re done making your model you want to uh highlight all of your cubes with ctrl a And then go over to textures here and create a texture and you want to name this uh whatever you want really it can be i would recommend the same name as your your block so in my case oven and then you want to click template and then hit confirm and select like a Color a base color or you can just leave it like transparent or white and leave everything the same here hit confirm and it will generate a texture essentially a texture map for you based on what your block looks like it’ll do it dynamically and now whenever you want to texture a side of One of your blocks you can just click on one of these uh one of the sides of your block so like the red side here and you can see it highlights that side of the texture map and now you can paint with it you can change it however you like You can see you can expand this window here and as we expand it it does change where the texture is mapped to um and even better you can save this texture with this button here throw it into like photoshop and edit it from there so that’s how you create textures And what i’m going to do now is i’m going to speed through a time lapse of me creating my custom oven block and texturing it and then i will see you guys when i when i’m done All right so i have my block [ __ ] model finished and textured but what we need to do is come over to display here and in the top right corner and you’ll notice that it looks really big in this player’s hand but essentially what you can use here is you can change what Your item looks like in different perspective modes so for example obviously our block is going to look like this when it’s placed on the ground just as you made it but in the player’s hand we want to change how big it is of course so for example i want My block to be much smaller if there’s a way to do that scale here we go i want it to be hope not that way i want it to be smaller just in general maybe we can uh make it like zero point uh three for all all variables There we go so i want it to be much smaller in the player’s hand and of course i want it to be like rotated a little bit outwards uh there we go i don’t want it to clip through their hand uh but you can mess around with this Yourself there we go so it looks like they’re kind of just like holding the block now again set this to however you want this is what it’ll look like in the game when you hold it uh next we want to also make sure you can also try some other reference models As well like zombies and that sort of thing next you want to make sure that the third person left hand is also the same so again we might want to change the the size here to like 0.3 so it’s not as big in the hand And i want to rotate this up a little bit so yeah and then also first person rights this is what it’s going to look like in first person when you’re holding it in your hand so uh definitely make this a lot smaller i’m going to say like 0.4 for this one 0.4 there we go and that looks fine so that’s what it’s gonna look like when you’re looking in the game and it’s in the bottom right corner uh in your hand in first person there’s also first person left again you can just copy exactly what you did before i’m gonna have this before And then 0.4 for the size in every single scale there we go so that’s how it looks on your left hand and then also if you wanted to use it as like a hat per se you could set what it looks like on your head i’m just going to set it right There i actually think that looks kind of cute um there’s also the ground as well this is what’s gonna look like when it’s floating on the ground you can see that right now it’s actually uh clipping uh through a block so if you were to throw this block onto the ground It would actually clip into the ground so you definitely want to fix this we can move it up a little bit so it’s not clipping as much and then definitely make it a little bit smaller like 0.3 maybe because right now it’s like the size of the entire block Uh that’s definitely a little too small maybe like 0.6 there we go that looks fine maybe a little bit lower uh so now it should look normal when you throw it on the ground as an item and then i think the last one is an item Frame so you can mess how it will look with in an item frame as well as a gui this is like in your your inventory what it’ll look like i think you can yeah like rotate it around so i want like the front for example to like face Uh the player so hold on this is being very tricky there we go so now it’ll actually look like it’s it’s facing the player and you could even make it like look a little bit 3d in the in the inventory so i could have it be like let’s make it A little bit smaller here 0.8 0.8 and then 0.8 there we go so now it looks like a 3d block that’s sort of sitting in your inventory facing the player uh so yeah once you set all these to how you like them again you really should do this before you Move on then you can go back to edit and we can continue on all right so now that you have your blockbench model completely finished and textured what you want to do is a few things first come over to your texture here right click save as and save it to your Desktop as a png texture and make sure it’s named the same name as your block i already did that but just do that if you haven’t already next you want to come up to file export and you want to export as a block model Now this will generate a uh a j a json file essentially that we’ll use in the game for our our block and you want to name it again the same thing that you named your block or what you will name it and make sure this is set to java block Item model and save that to your desktop i’ve already done that but do that right now and keep this window open or at the very least file save a project because we will come back to this in a second for something that i will show you later on So definitely keep this window open or save it but once you’ve done that go to your desktop and you should now have your texture and your json and if you open up this json real quick with uh either textedit or you can open it up with uh notepad plus plus You want to make sure that you change a few things here you’re going to notice that well what this is doing is mapping essentially all the blocks and as well as the texture for you essentially but what you want to do is in front of the blocks here on xero On line four you want to add your mod id so minus tutorial with a colon and you want to do the same thing for particle tutorial colon and you want to change this texture here where it says texture to the name of your json or your block So my block is going to be oven so you want to name this oven and again this name that you set here and the name of this file is going to be what you use for everything in the game now you’re going to use it to For your texture you’re going to use it for your block registry name all that stuff so keep that in mind once you’ve done that again your item name your block name i mean and your mod id with a colon you want to save and then open up intellij open your intellij project And now that we have our block we can actually make it in the game because this is just the model but we actually need to make the block so just like we’ve done every single time come to your registry handler class and we can just copy one of our previous Blocks so i’m going to copy our ruby block our ruby ore block make a new block and again you want to change the name to whatever the name of your block is mine is going to be oven you want to keep everything same except for the registry name And again like i mentioned the same name that we use everywhere it’s going to be oven for me and then you want to change the class to a custom block class that you’re going to make we haven’t made this yet but just name it exactly what you’ve put Here with a capital first letter so in my case it’s going to be oven if you were making like something with multiple words you would want like oven stove block like something like that so mine is gonna be evan and don’t worry about this air we’re gonna make this Class later on so just leave it there for right now next thing you wanna do is make the block item so again we need to copy our one of our blocks we’ve made now paste it below and everything is going to be the same except of course the name Here we’re going to change this to oven underscore item and we want to change the registry name as well to oven and we want to change the block item as well uh from ruby ore to our oven because we want to get our block that we just created here And then everything can be the same again you can set the dot group the tutorial tab all that stuff uh all right here if you need to um that’s all up to you to decide if you want your custom tab or your vanilla tab as well as some other Methods that you can mess around with in here to your liking so now that we have our items in the game we actually need to add this this custom class here so go over to your blocks package where our other block classes are you want to right click create a new class Just like we’re used to and again name it exactly what you put here for your block mine is going to be oven and you want to add this to the repository now this class is not going to be what you’re used to i mean the first part is but it’s going To start getting pretty advanced so again bear with me we’re just going to have to go through the steps slowly so first thing you want to do of course is make sure that this extends block and this is going to allow you to import block and implement all of the methods If you hover over it again or sorry create constructor matching super so now that we have the constructor you want to treat this just like you have every other block at first so if we open up like a ruby block here you can see that we set our properties with a material type A hardness and resistance sound harvest level harvest tool i don’t know why deleted but we should have set requires tool as well in here i mentioned that in the last video very important uh so if you don’t have that definitely add that but um yeah coming back to our class here We want to do the same sort of thing so again we can get rid of this uh thing that we passed in here because we don’t need it and we can just type block dot properties dot creates and we can do material dots and you can choose a material type Mine is going to be iron because this is like a metal furnace or a metal uh stove or oven and then we can bring this down here and we can just add methods as needed so we can set the hardness and resistance as you’re used to uh 3.5f for me I’m going to set this to 4.0f again none of this should be new to you if you are comfortable with blocks and if you’re not comfortable with making blocks then you should probably not be watching this video you should probably be starting with basic blocks we can set a dot sound Uh don’t sound and i want my sound type to be anvil because i want it to be like a metally sound a metal or g sound and then dot harvest level i’m just going to let this be zero so you can mine it with any tool I mean any any tool tier rather we can also set the harvest tool type harvest tool and uh this is a metal furnace type block so it’s going to be a tool type dot pickaxe for me and of course just like every block we make in 1.16 It now has to have set requires tool if you want it to have a harvest level all right so now that we have all this done our block our block class is good so we can actually go to our registry handler here and import oven import class now this is All great but if we go back to our oven.java class here one thing we want is since this is a special block that has a specific direction like the textures are different on each side and so is the model what we want is for the block to face us Every time we place it kind of like how when you place a furnace the front of the furnace is always facing you when you place it same sort of idea here and you can apply this to any block it doesn’t have to be an advanced model block it can just be something Like a furnace block uh that will work as well so in order to do that in order to make our block face us every time we place it we want to and again you don’t have to add this this is totally optional but just going to show anyway you want to Add a private static final direction property direction property and we just want to name this like facing or whatever you want really is equal to horizontal block dot horizontal facing and we’re going to use this in a second here with some methods so we’re going to have to override a couple methods actually First method we should be overriding is the get default or the get state for placement rather so at override get state for placement there we go right there hit okay and uh you can leave this nullable if you want or get rid of it it doesn’t really matter But you definitely want to get rid of this super here so get rid of the super and you want to return instead this which is going to access this class dot get default state get default state dot with and then you want to pass into here your new Facing variable that you created as well as the context that is passed into this method context.context i really can’t spell today context dot placement uh get placement horizontal facing dot get opposite and this is going to get the state uh whenever you place uh the block And next we need to get the uh the actual rotation or we need to set the rotation so we can do that with at override rotate and with this it is going to say deprecated but remember that deprecations in java or forge rather are really talking about calling the method Not so much overwriting them so if you see a deprecated method it is fine to overwrite it so don’t worry about that but again we want to get rid of the super here and instead we want to put state dot with and we want to pass in our new facing variable As well as the rotation dots rotates and you want to rotate with state dot gets and again our facing variable and this is going to be allow you to rotate the block as necessary next and i think the last one well actually the second the last one we need to add override At override uh the mirror so once you have this again remove the super method and you want to add states dot rotate uh dot rotate uh and inside of here we’re gonna pass in the mirror so mirror in mirror in dot two rotate or two rotation rather And we’re gonna pass in our state dot gets dot get and then pass in the facing variable all right this is going to set the block state mirror um and i think the last thing we need to do is just fill the state container uh yeah so let’s do that really quickly At override um and we want to fill the state container that is now he’s supposed to fill fill state container okay and then again get rid of the super method or the super here and instead what we want to do is just have us use the builder and then add our facing variable Okay so this is all good now so essentially um well we haven’t set the the json yet but um assuming that our json will work fine this will allow us to have the block rotate towards us every time we place it again all of this is totally optional if That’s what you want for your your model so now that we have this we have to add the jsons and ooh i know the scary part of custom blocks so go to resources go to assets tutorial and first one we should do is probably block states so go to block states Right click new file and we’re going to name this again exactly the name that we put in registry handler our oven here so right click new file oven dot json and add the repository and now you’ll notice with our ruby block that this block because it’s a lot more Simple it only has um a a single uh variant for the model but uh if you come to the description you can find a paste bin here for this new block state and you want to copy this and paste it in and what this is going to allow us to do Is use a different model for every time our block is facing in a different direction and this is going to allow us to essentially uh fulfill this rotation here that allows your block to like you know face you whenever you place it if you don’t want to use this if you Don’t want your block to rotate every time towards you when you place it you can just copy what’s in ruby underscore block here what we made before you can just copy this and use this instead because this is just a single variant but if you want multiple variants facing North south west and east like we want here then you are going to want to use this new json and you want to replace the mod id again with your custom mod id you want to do that for all of them and you want to replace the item name again With the name of your item which in my case is oven and everything else you can leave the same if you’re trying to get the same rotation effect okay that’s all good we can close out of this next thing you want to do is come over to our uh Models go to item you want to right click and once again new file and we want to name this again just oven.json add a repository and in the description there will be another paste bin here for the block item json just copy this it’s exactly what we’re Used to you should already have some actually if you’ve made a regular block item and again replace the mod id with tutorial the name of your mod id and uh the item name again just oven that’s our item so and it’s just a simple parent it’s just directing to the parent All right file save all now now is when it gets a little bit tricky so um the block json here normally we set a block.json you know like ruby underscore block here for our blocks our block package and you can see this is really simple But again we want a custom model so what we need to do is get that file that we we got from our block bench again this is what we saved to our desktop here let me open it up so you can see we talked about this just a few minutes ago And we changed these uh these values here you’re going to want to use this instead as your your block json so you want to take this hover over intellij and then just drag it right into your models.block folder again it’s models and then your block folder and refactor And add a repository and now it is in there oven.json and again make sure that your mod id is here with a colon and then replace this name with the name of your uh your item or your block and again ours is oven so yeah now just A couple of things left to do we should definitely go up to our lang folder here go to ian underscore us.json and make a new entry here for our our new block so we can name it i’m just going to copy what i have above for our block block.tutorial.the name of your block Which is oven and i’m just going to name it stone fire oven or that’s a little too much let’s just do oven there we go all right so we have it named and then also very important do not forget this step you want to open up your textures here We do need to add the texture textures uh go to blocks and you want to drag your oven.png again making sure it has the same name as you set for everything else you want to drag that custom texture into your blocks inside of textures refactor add the repository And there we go so now our block is in the game it’s all ready and set to go with our custom model there will be a couple problems so definitely keep watching because we are going to work through those in a second here but let’s run the game and test it out All right so we’re inside of the game now and if we come to our creative inventory we can go to our custom tab here and we can get our new block that we just created our oven block and you can see that just like we set in Block bench it does have a perfect model in our hand in first person mode it looks good and when we throw it on the ground it’s all proportional so all that stuff that you set in blockbench is working great and if we place it we can see that it does have our sound And the model is working now i did want to show you guys some issues here uh first before we fix them just so you know what’s going on and how to fix these things so the reason that uh this texture is clipping here in the bottom is because as you can see Uh the game thinks that this block here despite the model that we set is uh its voxel shape is a full block and you can see here if we put a full block next to it you can see the voxel shape is pretty much exactly like a full block So what we need to do is go back into intellij and tell the game and forge essentially that this block is actually this model so we’re gonna set this uh this voxel shape to our model and that will get rid of all this texture clipping and we’re also gonna mess around with Some shadows so definitely stick around and i’ll see you back in intellij all right so what you want to do is come to your custom block class mine is called oven that we just made recently and inside of here what we’re going to do is create a couple variables For our voxel shapes so what we need to do first though is actually get those voxel shapes from our block bench so go back to block bench where you have your model all set up if you didn’t save it or you don’t have this window open you can just import it From the json you made and add the textures again and what we want to do is first take all of these cubes here that are in your your outliner there can’t be any other groups they have to all just be cubes with no folders ctrl a to highlight all of them and you Want to uh well actually let’s make a folder first make a ad group here with outliner and you want to name this group voxel shapes and it has to be exactly like this with a capital v and a capital s so make sure you have a package named voxel shapes And you want to highlight all of your cubes and just throw them into this package so every single cube in your model should be inside of this uh this folder here called voxel shapes once you have that you want to come to file export and we’re going to export a voxel shape now We’re going to do this for every single direction north south west and east so we’re going to have to do each one which is really tedious i know but you can see that our block right now is um is facing north because of this giant end here so we can do north first By doing file export voxel shape and we can save to our desktop let’s just name this one north and uh hit save all right so it’s saved successfully now we need to highlight all of our cubes we need to go to transform rotate rotate wide plus 90 And that will rotate our our block to the right so now it is facing the east direction so now we can do file export export voxel shape and we want to name this east go to desktop save and all good now we have to keep doing this for every direction So flip it again flip it to the south now so it’s the opposite of north uh file export export voxel shape and again we’re gonna name the south and save it to our desktop and one more time we have to transform rotate it to the west and again we can See that because north is facing this way and our block is facing west and we can do file export export voxel shape and just type west hit desktop all right so now on your desktop you should have four files one for north one for uh east one for south and one for west Now inside of each of these files is a little bit of code that you’re gonna use inside of the game so uh go over to your intellij and right below your facing variable here we want to make a couple variables let’s first make our private static final Voxel shape voxel shape and we’re going to name this shape underscore n and this stands for voxel shape underscore north this is going to equal the code that you just uh generated from block bench so to get what this equals go to your north.java that you just made from blockbench Right click edit notepad and you want to copy all this code here and then just paste it right in oh that’s my recording software you want to paste it right into your variable here and you want to make sure to import stream you want to import voxel shapes as well And you want to implement or import sorry i boolean function all right and the last thing we need to do is at the end of all of this code right before the last semicolon just do dot get so we actually get the voxel shape now what this is doing is setting this Voxel shape to the uh the cuboid that we made in the game or in block bench rather facing the direction of north and we can just bring all these up here just to make it a little bit cleaner for everyone but you’re gonna have to do this for Every single direction so north west south and east so get ready it’s going to take a little bit of time but there we go all right so this is all good uh now we need to do the same thing with public static final voxel shape uh this one is going to be shape Underscore east so shape underscore e is going to equal and it’s going to equal the code from the east.java that we generated so right click edit notepad you want to copy all this code just like last time and paste it in and again make sure we get that dot get And we can clean this up as well just so that it looks a little bit nicer and it’s more readable because i don’t want it all to be so blocky like this okay there we go now i’m just going to copy it this time just copy what you have up here And we’re just going to change the name to let’s do south next and this is going to equal the code from our south.java that we generated again right click copy and then paste it in i know it’s super tedious but just bear with me and then At the end again dot gets very important method to add and we’re going to clean this up just like last time again this is not necessary but i just want to do this so it looks nice and readable all right and then last one finally We can uh just copy this again and this one is going to be shape underscore uh west so shape underscore w is equal to go to west.java open this up copy and you want to paste it in and again add that.get method at the end and we’re gonna make it all pretty all Nice and pretty just like all the other ones and then we are almost set to go okay so now that we have our voxel shapes we need to actually set them in the game so to do that because our block is directional we do need to override the get shape method So just come over here and you want to add override get shape uh get shape let’s find it there we go get shape hit okay and again we want to get rid of this super here we wanted to return something custom so let’s actually get rid of this whole line here We want to have a switch case statement for the direction that’s facing and then based on the direction we can return the voxel shape as necessary so we want to do switch and then the uh the variable we’re going to pass in is going to be our states Our block state dot gets and then we’re going to pass in the facing value so again this is getting where the block is facing when you place it and then based on this knowledge we’re going to have four cases first case is gonna be north uh if the uh Facing direction is north then we want to return uh just as you would expect shape underscore n so we wanna return the north facing shape if it’s facing north then we can do the same thing for the other directions so same thing for case south or sorry Case we should do it in order case east is going to return shape underscore e and again one more time uh sorry two more times actually case uh south is going to return uh shape underscore s and then last one finally case west is going to return shape underscore w all right great And we do actually need a default just in case none of these are are returned which is probably never going to happen but just in case we do want a default that is just going to return the north shape so shape underscore n this is going to prevent any issues from Happening in the game semicolon all right so we’re all done with uh the shape and direction of our block one more thing i want to talk about before we check it out in the uh in the game is you can actually override a method if you’d like Uh down here at override and again this is optional called get ambient occlusion light value uh and this value if we get rid of the super method if we go to this um you can return a value between zero and uh one a float between zero and One and what this is going to do is determine how strong the shadow is so if you’d like to modify the shadow this is where you’ll do it there will be some more info in the description i think but the lower the value this is so like if it’s zero or 0.1 The more shadow you’re gonna get if you were to set this to one that would pretty much remove the [ __ ] like the shadow entirely from the block um and you can mess around with this yourself i’m gonna set this to 0.6 so there’s like a moderate shadow when we place the block down But it’s not too strong of a shadow and the reason i mention this is because when you set a custom voxel shape sometimes it can get rid of the shadow so you might want to set one yourself and again this does return a float so 0.6 f float But you can set this to whatever you like and i am now going to run the game and let’s test out our brand new block alright so we’re inside of the game now and if we take our custom block and we place it down you can see that everything is working Perfectly now there is no more seeing through the ground and as you can see when we hover over our block here the uh the voxel shape is now perfectly aligned with the actual block and it’s hard to see because the texture is black but one way you can test this is If you see when we walk over our block when we walk over the chimney it does treat it as an entirely new step up so that doesn’t mean that the voxel shape is actually set because otherwise the game would just think that this is just like a a singular block with No no extra details on it so yeah that’s one way that you can check but now you have a perfectly working uh custom block with your own model in the game all right so that’s gonna do it for this tutorial thanks guys so much for watching just remember that if you want your Block your custom block to drop something or drop itself then you are gonna have to make another loot table and i’ve got other videos on that that you can check out so don’t forget to add those things if you want a fully working block uh but thanks guys so much for watching And i will see you in the next episode You Video Information
This video, titled ‘Minecraft 1.16: Forge Modding Tutorial – Custom Block Models (#13)’, was uploaded by TechnoVision on 2020-07-14 02:04:39. It has garnered 22546 views and 642 likes. The duration of the video is 00:35:54 or 2154 seconds.
Learn to code a Minecraft mod from scratch in this complete tutorial series! In this episode, we create advanced blocks models with directionality, shadows, and custom voxel shapes.
— Important Links —
● Blockbench: https://blockbench.net/ ● Blockstate JSON: https://pastebin.com/vdLgK1wB ● Item JSON: https://pastebin.com/XFXkKsyP ● Blockbench Tutorial: https://youtu.be/XqzxL_-XjA0
● Discord: https://discord.gg/ZsB3Eha ● GitHub Repository: https://github.com/TechnoVisionDev/Minecraft-1.16-Modding-Tutorial.git
— Music —
● Chill Out Media – Minute Mix
— My Channel —
● Subscribe: http://tinyurl.com/zbc7mwy ● Instagram: https://www.instagram.com/tomm.peters ● Twitter: https://twitter.com/TechnoVisionTV
#minecraft #modding #tutorial