I’ve added a lot of blocks to Minecraft and people often go about asking me how to add their own blocks to the game and unfortunately it’s not quite as simple as you might expect I’ve made some tutorials on the rather simple ways so you can add custom items to the game to Get their textures to display and whatnot I’ll link that video in the iard in the top right it is the start of how you’re going to go about adding your own blocks so definitely check that out before you watch this video unfortunately adding blocks to the game Is a whole lot more complicated than simply adding items and so this tutorial will teach you everything you need to know about my method of adding blocks to the game oh and I did specify that this is my method of doing it because unlike adding custom items where there’s Literally only one way to do it for custom blocks there are probably an infinite amount of ways to do it my method causes pretty minimal lag however it is a little bit complicated to set up before before we dive into the method that we’re going to use let’s start by Understanding a bit of why we need to use this method and get a brief overview of how this method is going to work as you know I like to start with adding all of the context that you guys need before you start the actual development all right so let’s explain what the problem Is so here we have a Minecraft block this is an oak log and I can place it in the world and I can break it and if I was in survival mode and I broke it I would get the item back and here we have a custom Block it’s my sword TNT from The more TNT pack I can place it in the world it uh texture will appear it has a collision box I can jump on and when you break it you will get the item seems pretty simple right if you’ve watched my custom items tutorial you might be Thinking at this point that okay I have an oak log why don’t I just give the oak log custom model data and then I’m done well let’s try that so I’ve updated my resource pack so if I give myself an oak log with custom model data you’ll see That when I get the item it shows up as the custom crafting table from um my other datab backs well perfect cool we’ve done custom blocks right we have an oak log we have our custom crafting table but now when we place it into the World it still shows up as an oak log the item we have changed to make look like a custom crafting table but the block is still regular and that’s because we have the ab ility to change the item model of everything with custom model data but the block model which is Separate that’s what’s in the world here is not able to be changed with custom model data we could make it so that every Oak log in the world uses this model here for the custom crafter however that’s obviously not a good method because you will very quickly run Out of blocks that you can use and so that’s where the method we’re going to talk about in this video comes in so in this tutorial we are going to be Mak making a red emerald block that can be placed down into the world it will have A collision box and when you break it you get the item back so without further Ado let’s jump right into it step one making our blocks model before we get started with actually making the blocks code let’s start with a model so we have something to work with but before we do That let’s explain what we’re actually using to display the blocks textures so the concept here is pretty simple we want to place an actual block into the world for example let’s use a red stained glass which it has a collision box right and we can break it and we Could place it in the world so we want an actual block and then we want to display a texture over this block and we can do that with an item display item displays let you create something that sure looks like a block but it’s actually an entity that you can pass Right through so in this case it’s an entity that has a scale of 1 .1 so it’s slightly bigger than a regular block and then uh the item that’s being displayed by the item display is an item frame with a custom model data of whatever our Our model is in this case it’s going to be one yours is going to be different than that so then from here the concept actually really straightforward if we were to line up our item display and we summon it to be in line with the grid And then you place a block inside of it for the most part it will look about right this isn’t quite lined up perfectly uh but the method that I’m going to be using later in this video will line it up actually perfectly but in this situation you’ll see that uh at Least three of the faces end up looking perfectly fine all right so with that in mind let’s briefly talk about how to set up your own item model that will service our block texture all right so in our resource pack we basically just set it up almost Exactly like my custom items tutorial so I would watch that tutorial if you haven’t already I’m not going to be covering everything that was covered in that tutorial because of how similar it is but if you go to your assets folder your Minecraft folder and then in your Models folder we want to go to the item folder and then create an item frame. Json model inside of the item frames model we are going to have it a override for custom model data and if we have a custom model data of one we are going to Have it instead load the model of tutorial SL red emerald block and I have made like I said a tutorial on how to set up all the custom model data so that is as far as I’ll go check out the item tutorial if you want more info but what This means is in game if we have an item frame it will look perfectly normal but if we give ourself an item frame with custom model data 1 it will display as this model and if we look back at our resource pack if you go to the tutorial Folder and you find the red emerald block this is a pretty simple model that’s basically just a cube that has uh our texture in here if we load it in block bench you’ll see that it displays pretty much exactly as you would expect where it’s just a simple Cube and I mean You could make this Cube Yourself by just creating a new boxal going uh 16 on the the size of all of these and then just applying the texture to it like so and and that’s all there is to it and for the texture itself it’s simply in The Minecraft uh it’s in the Minecraft textures tutorial folder it doesn’t really matter where this is as long as it’s referenced in your models file okay so that is the end of Step One by the end of step one just make sure that you have an item frame still displaying as Normal but if you give yourself an item frame with whatever custom model data you went with that it displays so and with that we are going to move on to step two step two is detecting the placement of the item frame all right so at this point in the process you’ve Probably figured this out but we are going to be using item frames to detect when and where we place the block that’s cuz item frames have a couple unique properties that can be really helpful so of course we can place them on any side Of a block and uh they line up nicely in the center of the block and can just be pretty much just they work like a block right but they also are an entity that we can but the most important part is actually the entity tag part of the item frame The item frame item interestingly enough if you give it to yourself with this uh entity tag you can make it so when you place it it has say like a stone block in it but that’s not all you can put all sorts of data into this entity tag field So this command here is going to give us a custom model data one item frame like we had uh earlier but it’s also going to have an entity tag that’s going to tell us it should be invincible and invisible and fixed and silent and have some tags tags Are going to be really important because they’re going to let us actually detect the item frame that was placed into the world and what exactly it’s supposed to be so in this case we have a tag of uh was. item frame block and was do red Emerald block and if we give oursel this we place it down you’ll actually notice that uh this is going to work exactly uh like our our red emerald block because of that extra data that that we gave it so that is the general idea for step two Let’s make it as a data pack all right so we need to start of course with a data pack in this case we’re going to be making the was custom blocks tutorial data pack so just normal stuff pack. MC meta the data folder I have a Minecraft Folder already set up and I’m going to want to have the Pack name folder so I’m going to go with w. block for this uh but of course you’ll want to name this whatever your pack name is I have a tutorial on how to set up data packs uh In general but uh in this case it would probably be whatever your your name is and then whatever the the pack that you’re trying to make is called inside of the block folder uh we’re going to make three folders we’re going to need an advancements folder this is Advancements plural we’re going to need a functions folder function plural and then we’re going to need a loot tables folder this is loot tables plural divided or separated by an underscore we’re going to be starting with the functions and then we’ll do advancements and then finally end with loot tables so In the functions folder we are going to start by making this uhmc function file and I’m just going to call it give items this is how we’re going to be getting our custom blocks for now inside of our give items function we only need one Command for now this this is going to be to give us our block so in this case we are going to give oursel an item frame and then have it have a whole lot of data and so for what’s important is going to be I mean your display name This can be however you want the name to appear in game uh this would be something you would have learned about in the items tutorial as well uh we’ll need the custom model data so that the the model that we made shows up so make sure that this value here matches Whatever custom model data in your item frame model is and then we need this entity tag that I mentioned a little bit earlier technically all that is needed from this entity tag is these tags right here the invulnerable invisible fixed silent and facing 1B all of these are Not necessarily needed but I would suggest adding them in case something goes wrong you will at least uh not have item frames in your world that are are not there but just for for the sake of uh but just for the sake of being able to easily see what’s happening I’m going To remove the invisible part of this hit save and then go over into Minecraft so if everything went well we can run/ function walls. block cool and give items and we will get our red emerald block and we can place it down into the world and it is an item frame because I Made it non invisible you can actually see it but it is there but the important thing and you can double check this if you run a data get command and you’re looking at it you can just select the entity hit enter and you’ll see that this entity has our tags that were in The give command so it has was. item frame block and was. red emerald block and so these are what you’re going to be using to detect them so uh definitely change obviously was to be whatever name you’re going with and then I would leave item frame block as the same and then Whatever you want your block to actually be referenced as uh go here so obviously we are making the red emerald block in this tutorial but uh whatever you are making as a block uh make that the the same name okay so we can place item frames they have data that tells us what It is now what now that we have an item frame that we can detect the location of now we just need to detect when we should look for that item frame and to do that we are going to create an advancement and we’re going to call this Placed item frame uh you could call call us whatever you want but might as well make your names very very apparent inside a placed item frame we are going to do uh basically just one thing we are going to set up a requirement that’s a trigger of item used on block and it’s Going to look to the player and match their tool to see if they used a glow item frame or a regular item frame uh I think I set it up like this because I use both of them for for blocks but uh uh you’re probably just using item frame So you could probably uh delete this and then if this condition was met we are going to run a function called uh was. block colon placed item frame this function doesn’t yet exist so let’s create that but first we can double check that this advancement actually correctly loaded by just trying to Grant Oursel only and uh if we were to run this you don’t want to but uh you’ll see that the advancement does exist so it is all set up right if it doesn’t exist look for typos in your advancement and realize you can download the template data pack that I’m going through in this Tutorial and just edit it rather than trying to type everything yourself it’s going to be a whole lot easier so now that we have an advancement that is calling a function let’s actually make the function that it’s calling so we can go back to our functions folder and Create the placed item frame function inside of this function we only actually need to lines of code the first thing you should always think about when you are using an advancement is that you should revoke it at the very start of uh whatever function you’re running so that Is this line here and then our second one is actually really simple we’re just going to execute as all entities that have the tag of w. item frame Block in a 10 block radius of us and then we’re going to execute add them and then run another function so if you think about What is happening here whenever we place this custom item frame that we have that has this tag here we get an advancement and when we get this advancement it runs a function and the function looks for everything that has this tag so it basically looks for the Block or the it looks for the item frame that we just placed and because it’s looking in a 10 block radius it’s always going to find it cuz the player doesn’t have a long enough enough reach to uh place it further than that and so then At that location it is going to do whatever is in the check placed item frame we don’t currently have this function so let’s quickly make it so we can create the check placed item frame and this is going to be another really simple function so what we want to do in Here is we are going to kill it uh Kill The Entity so in this case the item frame is going to die but we’re going to do it at the end uh but before before we do that we’re going to execute as the item frame that we were just checking But in this case we’re going to look to see what type of block it is so basically we’re checking so first we checked for all that have this tag and now we’re checking for all that have this tag and if that step is a little confusing we’re doing this because for Performance reasons it’s a whole lot better to look for all entities that have a certain tag and then run a list of tags that are unique to the specific entity because suppose we have 10 different types of emerald blocks that we’ve made we can look for only one single tag of Just a custom block and then once we’ve determined what it is we can say okay is it the blue emerald block is it the green emerald block is it the yellow emerald block right so in your code here what you would want to do is you could Copy this a couple times and we could say we’re looking for a blue emerald block or we’re looking for the yellow Emerald block uh I’ve realized green emerald block doesn’t really make much sense because uh they kind of already are green but yeah and then uh in that situation We are going to run a function called uh red emerald block place or in this case it would be blue emerald block place and then we have yellow emerald block place but we’re only going to keep one of these for now but that is how you would have multiple blocks set up my Assumption with this tutorial is most of you we’re not going to be stopping at just one block you’ll probably be making multiple so I’m going to try to explain how you could set up multiple using this method so now we’re able to detect if a red emerald block has been placed we Know where it’s been placed so now we just need to run a function when we have the block place to do a thing so we just need to create a function in the red emerald block folder called place so I mean that’s simple enough just create a folder called a red emerald Block and then put a function in here all right so we just create our place function and when we load it you’ll see we have another very very straightforward function this one actually only needs to do two things so we’re going to start by setting a block At the location and this is going to be whatever base block we want our block to be so earlier we were looking at Red stained glass I’m going to go with that for the tutorial do realize this could in theory be anything you want secondly What we want to do is we’re going to summon an item display and this is the same item display that we were looking at earlier in the tutorial so we have a tag of uh that it’s a custom block red emerald block and there’s uh the transformation showing that we have like The translation down a little or up a little bit we have a a slightly increased scale and then this is the cool part the item display displays the item frame that we used to place the block so same model we just get to uh display it right here and so if we try This in game now in theory it still doesn’t work when we try this in Minecraft make sure that you probably run the advancement revoke command for the place item frame function I ran into an issue where I had already placed it and uh this didn’t work but now in theory when we place These cool we have a custom block we can place it and it is beautiful or yeah it’s a very red emerald definitely there’s a little bit of jankiness unfortunately with like the the outline you can sometimes you through it a little bit but overall it looks pretty good only problem Is yeah uh we can’t break it as of yet uh these are of course still item displays so we’d have to kill them to get rid of them but that is the end of step two so at the end of step two in theory you should be able to detect Where the item frame that we’re placing is and then summon an item display at the location one thing to note if we use a block that does not let light through it we are going to get slightly different results so if we were to say use Stone you’ll see when we place these Down into the world they are very very dark and that’s because the item displays are displaying with light level zero you can fix this by adding the brightness tag to your item display so we can set it so that the brightness of each item display is always a sky level 15 and a block level 15 and if we try this one in game you’ll see that whenever I place the blocks they are now very very bright and that that is with them being Stone the only problem with this is like if we set the time to uh night you’ll See that these ones are still the same brightness while uh the glass one that we had earlier does actually adjust in light level so if you are needing a solid block this unfortunately is the best you can do right now but if you are are fine with the block uh the base Block being transparent like a glass or whatever uh definitely go with this method but yeah that is the end of step two let’s move on to step three step three detecting when the block should break so because our block is actually an item display and because uh the base block can be Broken we need to detect when the base block gets broken so that we can break the item display and get rid of it and give your item back so to do that I gave uh the item display two tags we have one that just says it’s a custom block uh so You’ll want it to be your name and then just custom block or something like that and then we want another one to say what type of custom block it is so in this case it’s a was. red emerald block but this would just be whatever you’ve been Calling your custom block and so now we’re going to need to create a lot of functions so the first one we need is a tick function because we do need these to have a bit of code running at them at all times and just a reminder with a Tick function we’ll need to set up a Minecraft folder with a tags folder with a functions folder with a tick. Json file and in your tick. Json file you will just need to reference whatever you call your pack and the tick functions name so in this case we have tick. MC Function we only actually need one single command in here it’s pretty simple and straightforward we’re just going to execute as all entities that are item displays that have the tag of w. custom block or whatever the the tags you went for your custom blocks uh and then we’re going to execute at their Location and run another function and so the idea here is so basically saying if we’re a custom block we should run something as a custom block so we need that function we called it as blocks and we can check this one out in the as blocks folder we just need one single Command per block so this is going to be executed as all red emerald blocks to then run our red emerald tick function so this is where you could add multiple of these and you would add your your blue emerald and your yellow Emerald right and that would run uh as your blue Emerald and then your yellow Emerald would run as the yellow emerald and so that’s how you could set up multiple blocks this way of course the reason why we’re doing it this way is just for performance reasons but in this case we are running a function called red Emerald block in the red emerald block folder so let’s create that all right so navigating to the red emerald block folder we can create the red emerald block. MC function and open it up and funny enough there’s actually only one command we technically need for this uh The rest would be for doing whatever functional thing you want your block to do if you just want it to be a block you only need one command and that’s really straightforward we’re just going to say execute unless the block that we’re currently in is red stained glass or of Course this would be uh whatever base block you chose to go with if it’s not that block we just run a function to break we don’t currently have this Brak function so let’s create it all right so we can create the break function this is also in the red emerald block folder and This function just needs to do three things so we need to uh spawn a loot table into the world uh of the red emerald block so that we can get our block back we could use a summon command to summon the item into the world but if You use a loot table it gets random motion that looks a whole lot better but if you were to summon the item it’s just going to fall straight down looks a lot dumber and so uh going with a loot table is the way to go the second thing that We need to do is we need to get rid of the red stained glass that just appeared if the player mined it with silk touch or or if it’s a different block they might have just gotten it so in this case we’re just going to execute us all Items within two blocks of the item display uh we’re going to make sure that there’s only one of them we’re getting the nearest one that has some NBT to it the MBT we’re looking for is if it’s on the ground uh we’re going to ignore it So this means it’s going to be in the air and then age of zero is the main one that that’s important here this means it can only have existed for one game tick and then we just say okay is it a red item or a red stained glass if it is we Are going to kill it and then we end this by having the item display kill itself okay so I know that might have been a lot but we just set up a tick function that then calls an as blocks function and that as a blocks function Finds the red emerald and runs the red Emerald’s tick and then the red emeralds tick if it decides that there’s no block there will kill itself and drop the loot so if we can try this out we’ll see our block can still place but now when we break it nothing happens because I Didn’t reload but if I were to actually reload you’ll see when we break it it will just disappear but nothing is dropped that’s cuz our final step is to set up that loot table so if we go into our loot tables folder and we create the Red emerald block. Json file this is our loot table that we are going to be running now the loot table itself is rather straightforward we’re BAS basically just saying we’re going to drop one item frame that has a bunch of NBT attached to it that NBT is all just What was in our give items folder it’s literally just this right here uh the only difference is if we go back to to this you’ll notice like if I if I put them side by side there are backs slashes wherever there’s a quotation mark so funny enough you could literally Just select all of the quotation marks and then go to the left of them and do a backs slash and uh this will be the exact same thing as what’s in here and so we could actually copy this over and check that out and see that yeah nothing Changed and I’ve mentioned this before but mizoe has a really good loot table generator if you’re wanting to do it that way you can go to uh his loot table generator and then use the function to set NBT uh right right here and then just Paste the nvt of of the item there and it will do all of the backslashes for you uh and set up your whole loot table I’ll have this Linked In the video’s description cool so now that we have this loot table we can just double check That in our break function uh that we are running the loot table and assuming it exists it will work in Minecraft so back in Minecraft if I actually reload this time you’ll see we can place this down and when we break it we get the item and it does have slightly different NBT it seems right because uh this one here has the invisible tag and this one doesn’t but if we change our give command to have the invisible tag like it should when we go back into Minecraft you’ll see when we run the function to give oursel the item that it will stack Up properly though I’d actually need to you know reload and then yeah it’ll stack up with that one and now we can remove these and you’ll see that they all uh stack up nicely and because we’re like I said using a loot table they will pop out with a bit of random motion Which is consistent with what items or blocks always do in Minecraft and uh yeah that is all there is to that tutorial uh I know whole lot of steps pretty complicated but in theory once you’ve done one there’s just a bit of copy pasting you need to do and then Some editing here and there and uh you can get it to work and what’s cool about this method is that you can actually do all sorts of stuff besides of course just have it be a decorative block because we’re running a function at the location let’s say we want to I don’t Know display a flame particle uh two blocks above the block well this would normally be pretty difficult to do but that was all that was needed to uh make that happen and so making functional blocks that actually do cool stuff is really simple uh just Figuring out what you want it to do when a condition is mad or whatever will uh get you a quite cool result so obviously particles displaying above the block is pretty boring but there’s all sorts of stuff that you can do and if you’ve ever seen my machines data pack you would Know that there are very few limits for what you can have these custom blocks do uh yeah definitely mess around with that and come up with some cool stuff well that’s all I have for this tutorial hopefully you were able to follow along and uh get a functional block out of it If you weren’t feel freee to join my Discord and ask for help there if I have a chance I will definitely lend a hand but that’s all I got so if you enjoyed the tutorial definitely leave a like on it subscribe if you want to not miss out On future tutorials and other content coming to the channel and I’ll see you guys all in the very next video thanks for watching Video Information
This video, titled ‘How to Add Custom Blocks to Minecraft Datapack Tutorial’, was uploaded by WASD Build Team on 2023-12-23 01:00:17. It has garnered 433 views and 33 likes. The duration of the video is 00:29:47 or 1787 seconds.
Loot Table Generator: https://misode.github.io/loot-table/
Download the tutorial datapack: https://www.dropbox.com/scl/fi/qbwhf4922n0hs4w7fi21x/WASD-Custom-Blocks-Tutorial.zip?rlkey=my0dsksli6lf6wvepg1udqvks&dl=1
Download the Tutorial resource pack: https://www.dropbox.com/scl/fi/uvp81esu9xi7j8vvm1sr7/Custom-Blocks-Tutorial-Resource-Pack.zip?rlkey=dejwf2h7u9zwcvgd5j9k22c3y&dl=1
Discord Link: https://discord.gg/yqk4VfA
Join our Patron server by supporting us on Patreon: Get exclusive datapack updates and entire packs. https://www.patreon.com/WASD_Build_Team
Learn about all the donation perks: https://wasdbuildteam.website/donate/
**My Favorite Minecraft Server Host** https://bisecthosting.com/WASD Use Code “WASD” for 25% off your first month!
Chapters 00:00 – Intro 0:59 – Context 3:09 – Step 1 6:58 – Step 2 20:39 – Step 3 29:11 – Outro