Hello and welcome to another tutorial in this tutorial we’re going to be covering tile entities tile entities are used for basically any block with a special function for example chests furnaces smokers and other functional blocks so in order to create a tile entity we’re going to need a custom block class So let’s right click on our parent package go to new package and type common dot block then let’s hit finish and inside of this package we’re going to create a new class i’m going to be making a quarry for this example but you can do anything that you want so let’s do Quarry block and this class is going to extend block let’s hit ctrl shift o to import net.minecraft.block.block and then hover over quarry block and add the constructor we can pass in the properties from our block init however if we make a block class for just One kind of block which is in my case quarry we can actually delete these properties and now in our super we can type abstract block dot properties dot create then we can pass in our material in my case this will be iron then a material color In my case gray then let’s set the hardness and resistance to 15 and let’s set the sound type to sound soundtype.metal so this is our basic block and the reason we actually needed to make this class is because we need to override two methods these methods are has Tile entity and for this method we’re just going to return true because this block has a tile entity associated with it and the other thing that we need to add is create tile entity for now we can leave this as it is because first we need to create our tile entity init class So under init let’s create a new class called tile entity types init and in here we’re going to create a public static final deferred registry of tile entity type and let’s call it tile entity type and this is going to be equal to deferred register.create let’s do forge registries Dot tile entities and as our mod id we can just reference our main class dot mod id and now to this deferred register let’s create some tile entities however in order to add our tile entities we need to first create the tile entity class so under common block let’s create a new package Let’s delete the block and type t short for tile entity and in here i’m going to create a new class called quarry tile entity and this is just going to extend tile entity let’s add the constructor and that’s all that we need for this class for now so let’s go back Into our tile entity init class and create a public static final registry object of tile entity type and this is going to be of the quarry tile entity we’re going to call this quarry tile entity type is equal to tile entity type dot register now we need to pass in the name Which is going to be quarry and then we need a supplier for the tile entity and instead of the null you can use tile entitytype.builder dot create however this needs to be a supplier so we can make it into a supplier like so now In here we need a tile entity so we can do quarry tile entity colon colon new and then in here we can pass in our block so in my case block init dot quarry which we haven’t made yet dot get okay so next we need to go back into our quarry entity And let’s create a new constructor which is just going to call the constructor above so let’s do this and now we can put tile entity types init dot quarry tile entity type dot get now in our block class instead of returning the super we can do tile entity types init dot Quarry tile entity dot get dot create then in our block in it let’s register the block so let’s do public static final registry object of block let’s call it quarry and let’s set it equal to block stock register quarry and then the supplier of a new quarry block now we can go back Into our tile entity types and as you can see we get an error so after this bracket we’re going to do dot build and then as the data fix type we can just pass in null and now our tile entity is completely registered the last thing we Need to do is to go into our main class and after blocking it we can call tile entity types init dot tile entity types dot register bus like so and now we can actually add functionality to our quarry so in our quarry tile entity class let’s make it implement i tickable And now we have to overwrite a function called tick and this function will be run every single time the world ticks so now let’s say we just want the quarry to break the block below it so in order to do that we need to first get the world so let’s do this.world Then let’s do dot set block state then we need to pass in the pose and remember we want to break the block below so we can do this dot pause dot down and then as a block state we just do blocks dot air dot get default state and what that’s going to do Every tick is going to set the block below to air that’s actually all we need for our quarry tile entity now we need to create the jsons so let’s create the block state of quarry and this is going to reference the quarry block model let’s fill in the lang for the quarry Let’s create the block model for the quarry like so let’s create the item model for the quarry actually for the block model i’m not going to use the quarry texture instead i’m just going to use an iron block so for that we can do minecraft colon block make sure this is singular slash Iron block now let’s create the loot table so quarry.json and this is just going to drop our quarry oh and also make sure to change this i-tickable to an i-tick-able tile entity so now we can run the game and now that we’ve loaded in if we place This block you can see that it immediately breaks any blocks below it that we try to place so that’s going to do it for this episode next episode we’re going to be expanding on this quarry by giving it a container and a gui thank you for watching and i’ll see you next time You Video Information
This video, titled ‘Minecraft Modding Tutorial 1.16 | 7.0 – Tile Entities’, was uploaded by Cy4’s Modding on 2021-02-16 21:22:44. It has garnered 9352 views and 201 likes. The duration of the video is 00:07:05 or 425 seconds.
the video quality is a bit below my usual standard, sorry. next video will be better than ever!
(ɔ◔‿◔)ɔ ♥ ~ expand me
C://Follow_Me/ Subscribe: https://www.youtube.com/channel/UCJIDXtGpf4wv1ybDzdTA_vQ/ Website: https://mcmodding.club/tutorials/
C://Help/ Discord: https://discord.gg/x9Mj63m4QG Or comment on this video!
C://Source_Code/ This Episode: https://github.com/Cy4Shot/ModdingTutorial1.16/tree/main/7.0-TileEntities All Episodes: https://github.com/Cy4Shot/ModdingTutorial1.16/