[Applause] Hobbies rock would say well do you know a Minecraft muncher today I’m going to teach you how to have your very own custom structure to the game so first of all let’s go and build a structure that’s what you can see behind me you can see the structure getting built and Yeah so you structure needs to be within a 32 by 32 by 32 radius because we’re actually using structure block for this tutorial so yeah if we actually go inside you should be able to see that I have a chest with no items in a furnace and a brewing stamp now what we’re Actually gonna be doing is we’re gonna be filling in these inventories with data like items and stuff so it’s like say in the furnace let’s we’ll put some stuff in the fairness in the bring stamp the chest I want to use a loot table for the furnace and the brings down we can’t Use a loot table because that’s not a thing for furnaces and then but if you go and get ourselves some coal I think that’s what you’ll get I get ourselves one piece of coal maybe Ben never walked and a water bottle maybe you’re like yeah so yeah like say put these in absolutes Got no fuel so you won’t start and when we go and generate this we will actually have these items in there as it is it will save it would a structure block but a chest we want to do something different so once you built your stuff and you filled in your inventories how You want we could also do it in the chest and you’ll keep in exactly the same spot but we’re gonna use a loot table let’s just set the time to the array and if we go and get ourselves structure box so give a piece structure under school block there we go and what We want to do is I’m gonna place it right down here in the corner we’ll select save I don’t I’m gonna call a structure a cabin now a relative position is our position from this block I know that the bottom left should actually be here and I know it’s seven By seven five five I think so derivative position will be zero because it’s gonna be on the same level it’s gonna be that’s gonna be zero and it’s gonna be minus seven others said it if I press f3 this is the negative dead and this is Minus seven and it’s seven by five by seven now what we can actually do is we can we do dawn it should bring a box around the area they were gonna save and that’s what we’re gonna do and you see how that’s the relative position down Here got a little lines here and what we’re going to do is seeing as we’re going to be using a loot table for this I’m going to just use one of the default once we need to actually use a custom data tag name and I’ve actually got a Class which you can download from the description of the video which basically allow us to do loot tables and that lot so the way it works is we need to type in the blocks that we’re going to generate so it’s a Minecraft chest then We do a space and then we do the name of the loot table now a good thing to do if ID press control-shift H and Eclipse and I’ll bring up the loot table list you can also search the loot table list that won’t come up for you that only comes up For me because I searched it you can see a list of all the loot tables that we’ve got in the game and like so what we put here is this name here so what it registers a suit for us it’s gonna be the chests slash born bonus chest That’s the chest that I want to include but say if we change it to the end city treasure we could do that entirely say we want it to be an entity I haven’t actually set it up to spawn an entity but we can’t completely do that I’ll show you the code of what we’ve done at a moment and if you this wouldn’t have to specifically be a chest it could be a dropper or a dispenser barely over blocks I have it and you can also set a damaged values to say some Non vanilla block you can set a damaged value by doing space after this and then a damaged value so yeah so if you just mark this that will actually work good a structure generator okay so there’s one last thing that we need to do before we actually finish with this we need to Actually give ourselves a structure void now if we go on into here and we do turn on invisible blocks you can see all the blocks it’ll set as air and inside we do want all of this to be air we don’t want to have over blocks spawning inside but on the outside We want these not to be air you want needs to be whatever the ground is so if we just put where all these are thoughtless and no structure voyages so basically marketers don’t set this to air it can all just block when saving all the other blocks like the air will Be saved inside so if we just pull it all in this structure voids like so and you see inside that these are all at blocks now we don’t Collider these because it won’t actually save so so nothing visible blocks like so and all we do is cliff we just press Save and yep we’ve saved it we can now save the game we can close it we don’t need it anymore and yes let’s head over to the code once it’s finished that there guy so this is a class that you’ll be able to download and it’s got It it will do everything that he needs it to do basically it will basically generate the structure that you pass into it so the structure name is a name that we called the structure when saving so that was just cabin and what it basically does is structures are Referred to as templates in Minecraft so we need to get the template manager and basically get the template we automatically pass in the mod ID if your Model T isn’t in reference just passed put it in here and yes so what we do is we actually check whether it can spawn At this place which uses its method down hey it checks whether the corns are valid that’s basically like say you’re on a cliff there’s a massive difference in the corners so using a variation of here so it’ll allow it for to be too much down but if there’s any greater Than that it will not allow it and say you know this isn’t why don’t generate at all and then we’ll do is replace it you’re a random rotation we add the blocks to the world we then get all the data blocks that’s all the data structure blocks so that’s one way we Filled in the chest and that lock with the data and what we’ll do is we’ll pass the data it gets the block before the VADs but it was should minecraft chest for us we then if it was free long we add get the right state from the Metadata or was just used to default one and then if it’s got facing value we’ll set the rotation to the opposite of the rotation of the structure so it faces towards you when you go in is how that’s set up and then we set the block that We’re going to set and a talented team we’ll set loo table correctly from what we said so that’s the generator we need to actually make a eyeballed generator see if we just call this structured Jen in a new class and we head into here this needs to implement I world Generator then it will get us to add a new method like so and we’re getting out of construction as well and a private structure generator like so and we’re just going to call it cabin generator and then if in the constructor we’ll just fill in the Stroop the cabin Generator so this just equals a new cabin structure generator and it’s just cabin is the name of the structure now in generate what we need to do is do a switch of the world dot provider dot get dimension and what we’ll do is we only gonna generate in the overworld which is Dimension ID 0 and we’re just gonna run the generator and break like say what we wanted to do the never that’s just case -1 and it would break and then case 1 is the end and then what we need to do is actually run a generator so what we’re Gonna do is we’re gonna add a private void I’m just going to call it run generator we’re gonna take in a structure generator and we’re just gonna call it to generate they’re gonna support in you want the lock X and the block this is ed and then we also need The world as well that would get a spawn in and finally the chance I might rearrange this like that ok and what we’ll pass into here we’ll just call it here we will run the generator and the generator is this cabin generator the world of the world the chance that’s Basically the likelihood of it spawning the bigger this number is the lower the chance so I tried it out on something like ten earlier which did quite a bit so I might put it on about 150 we’ll see how that goes will obviously all checking it in game We want to create two in Sapir called block X and that’s gonna equal to chunk X then it’s times 16 because 16 blocks for chunk and we’re gonna add a round random dot next int and the int will just be 16 so go from 0 to 16 on the end I’ll just copy and paste this for the chunk then for the blocks that I mean and like there you go and that’s all that donut so all we need to do is first we need to spawn it if we have the chance so the way I’m gonna do it is a Simple math dot random and I’ll just get a random double we times it by the chance and because we’re converting it to an integer we check if it’s zero and then that’s when we all generate so the bigger this number is the greater this is times by the less likelihood that it Will be a zero it’s basically how that works and then all ready to do is this stock not this that generator be the generator does generate we’ve got the world we need to also passing random random random will pass in the random up here so passing to random and then the Position is a new block pause we’re going to get block now the Y position we can actually get from the structured generator class and all we want to do is get the ground from above the world and that’s block X and blocks dead and then it’s just block Zed There and that should be it import block pass like so I’ll just reformat that and that should spawn in a cabin what the get ground from above does is it starts from the height of the world and it works its way down to try and find the ground now things that it Accepts as ground is stuff like grass sand snow snow layers mycelium and stone stuff that it doesn’t accept its water and flowing water this is because I actually saw it generate under water which would not in 1.13 so we don’t get anything pretty but in the future this Will probably work which would be quite cool spawning it underwater really you just need to change the generate method all you need really is this and the placement settings and the template add blocks to world and that will simply spawn your structure in you can change How it generates however way you want to and all we have to do now is register the world generator so we’ll do underneath over to DF 1 in the init method in bit of everything and all we need to do is register and it’s world generator and it’s a new structure Structured gen like so and the mod generation wait this is like where we placed like what order will it be so it’s 0 being the first thing like a mill you mean like the last like very last so we’ll put it on about to but let other stuff generate first now finally the Last thing that we need to do is we need to actually tell the game where our structure is so over in our resources assets BOE we’re going to make a new folder and it’s gonna be called structures she’s like so and then here we’re gonna place our structure now if we had over To a bit of everything folder we had him to run saves and then we opened up structure tutorial which is where the world is it should also be out again download you can see this calendar MBT I can actually open this with MBG Explorer Is a program I have I might link it in the description and there you go the structure is down there we can just debug run the game and it should generate now so let’s just wait for the game to load up the case of the game is Loaded up so if we just head into a brand new world I’m gonna call this structure gen now excuse the little loud this is a new world lag that we’re going to experience now it will just generate the world and hopefully we see our Cowen hopefully and you don’t actually have to Stick to just vanilla blocks in your structures or you can use moderate blocks and you can use / mods blocks but I would recommend not doing that and sticking to your own blocks really because if their block is not available basically renders your structure useless Okay so we should be in and second I’m just going to stop some of the lag oh [Applause] yes yes it it spawned its borned brilliant now you can’t see majority isn’t overhanging which is good and you could I’m gonna run this up to 25 again you can’t obviously modify this to how You want but you see inside we have a check with our starter loot in and it’s facing towards us is exactly what we want now if you fly about a bit we’ll hopefully see another one thank you guys for watching hope you build some awesome things if you do just Mention me on Twitter show me your amazing structures and thank you guys for watching to like comment and subscribe I’m out Video Information
This video, titled ‘Minecraft Modding Tutorial | Custom Structure (1.10.2,1.11.2)’, was uploaded by CJMinecraft on 2018-07-30 19:32:15. It has garnered 2352 views and 60 likes. The duration of the video is 00:17:44 or 1064 seconds.
So I’m back with the modding tutorials, today we are going to add a custom structure to the game using structure blocks!
StructureGenerator class: https://goo.gl/qJBn3q NBT Explorer: https://goo.gl/hedyhn World Download & Structure File: https://goo.gl/7mp4yC
Please support me if you can – https://www.patreon.com/cjminecraft Patrons see videos before everyone else! Discord – https://discord.gg/ZvhUKkd
Don’t forget to like, comment and subscribe!
Music by Ninety9Lives Elektronomia – Imagination Video Link: http://99l.tv/Imagination Channel: http://99l.tv/Subscribe Album Download Link: http://99l.tv/GoldenGun Music: https://www.bensound.com/royalty-free-music
Links: ►GitHub – https://goo.gl/c4JlXe ►Modding Tutorial Playlist – https://goo.gl/bq6sgx ►Facebook – https://www.facebook.com/CJMinecraft01/ ►Google Plus – https://goo.gl/3n1umj ►Twitter – https://twitter.com/CJMinecraft01
For modding help or if you want to contact me, email me at [email protected]
My Schedule: Monday or Thursday: ►Modding Tutorial