Hello and welcome back to another tutorial today we’re going to be creating basic blocks and items as well as the creative tab and looking at tags and jsons let’s start by finishing up our main class so that we can start work on our blocks and items so the first Thing we’re going to do is make a variable for the mod ids that we can access that from anywhere so let’s create a public so it could be access from anywhere static final string mod id and this is going to be equal to tutorial mod and this has to be The same thing that you set up here so now whenever we want our mod id we can just get it from the main class next i just want to quickly make a creative tab to put all of my stuff in so let’s create a public static final Creative mode tab and this is going to be called tutorial tab and let’s set this equal to a new creative mode tab and you can see this is going to give us an error so let’s hover over this and add a string argument and this Is going to be our creative tab id i’m just going to put mod id because i’m only going to have one creative tab but you want this to be different every time you make a creative tab for the icon we’re going to have to create an item First but i’m going to put at only in open this and write dist dot client if you have an import area you can now press ctrl shift o to import everything if you want to create another creative tab you can just copy and paste this down here change this name to like Tutorial blocks or something and then you’re going to want to add something to the id because you don’t want these two ids to be the same but i’m going to delete that and now we can start work on our items so in our com.cy4.tutorial mod we’re going to Right click on that go to new and click package and i’m going to write dot and then init and press finish and this is going to create a new init package now let’s right click on that and create a new class called item init and in here we’re going to create all The items for our mod so next we’re going to need to create something called a deferred register and this is a register that just holds all of the items that we have in our mod and this is once again going to be public static and final so we need a deferred register And you can press ctrl space to bring up the search window and if you press enter you’ll see that it defaults to something like this we can replace this with item because we’re going to be registering items let’s name the register items and let’s set it equal to deferred register And then we can delete all this stuff dot create and then we want to select the second one over here and the first thing this is going to take is forge of registries dot items so we know that it’s an item registry and the next thing is going to be the Mod id variable that we set before so let’s do tutorial mod which is the main class dot mod id and you can see that this isn’t imported so we can press ctrl shift o to import item and then select net.minecraft world item item and there we go next let’s create a function which Will register our item so this is going to be private because we only need this in this class and it’s going to be static and we’re going to say that the t has to extend item and then we can press ctrl space and type registry object of t So what’s happening here is that this method will have to return a registry object of something that extends item and now we can type register and in here we’re going to pass in a final string name which is going to be the name of the item and a final Supplier of t called item and all we have to do in here is return items dot register name and item so now we can make our example item let’s create a public static final registry object of item and this is going to be called an example item and let’s set this to Register the name for our item so this is going to be lowercase and we’re not gonna have spaces we’re just gonna have tabs let’s add a semicolon here and then we need a supplier for our item and to make a supply we can add brackets and Then an arrow and then here we want to create a new item and this needs properties so we can hover over this and add our property to do that let’s create a new item dot properties and this is going to be the properties for our items So after this we can add a dot and then add different properties so we can say no repair we can give it a rarity we can make it fire resistance we can add durability but the thing i’m going to do is do tab to add it to a creative tab And then i’m going to select tutorial mod dot tutorial tab which is the tab that we created before so next in our tutorial mod i’m going to create an icon so i’m going to return a new item stack of item init dot example item dot get so Now the icon for our creative tab is going to be the item and what we’re doing here is we’re getting the item which is a registry object of item and then we can get dot get which is actually returning the item variable and then we’re creating a new item stack And passing it into the tab next we need to register our item init and for that we’re going to needs the mod event bus to do that let’s create an i event bus called bus and this is going to be equal to fml java mod loading context and you Can press ctrl space dot get dot get mod event bus then we can do item init dot items so the deferred register and then we can register that to the bus and there we go now all the items will load into the game next we need to Create textures and models for that item so in our source main resources let’s create a new package called assets dot and then your mod id so tutorial mod and in a couple of episodes i’ll show you how to automate all these jsons but for now we’re going to create them manually So in here let’s create a new package called dot lang another new package called dot models dot item another new package called dot models dot block then another new package called dot textures dot item and a package called dot textures dot block and finally we’re going to add One more package called dot block states there we go so let’s start off with the lang in here let’s create a new file called en underscore us dot json and this is the file which is going to give our item its name so let’s open brackets like this press Tab and in here we’re going to do item dot tutorial mod so our mod id dot example item and this example item is the same as the one we put in the register function colon then more of these and then the name of our item so it’s going to be example Item and that’s it for our lang file next let’s create the item model so under the models item let’s create a new file and this is going to be called example underscore item so it has to have that same name that we used in the register dot json And then we’re going to once again open these and here we’re going to set a parent and this is the parent item model and this is just going to be item slash generated which is the standard item model next we need to give it a texture To use so let’s create a new thing called textures and open brackets once again and we need a layer 0 which is the main texture and then we need to pass in a path for that texture and this is going to be tutorial mod colon item slash example item and This is just going to pick the example item texture that’s going to be located in textures.item over here so now we just need to add that item texture so here i’ve created our example item texture and this is a png file and it is 16 by 16 which is the standard dimension in Minecraft you can make 32 by 32 but that is wrong and i’m not doing that so i’m just going to drag this file into our textures.item folder and click ok and there we go so now if we run the game and you can see that we have another creative tab That isn’t actually named so we need to fix that but we have our example item now let’s fix the creative tab and start work on the block so to fix that we’re going to add a comma here and create a new thing called item group dot tutorial Mod which is the id that we set in our creative mode tab and we’re going to set this equal to tutorial mod tab and that is it now let’s start work on the block in our init package let’s create a new class called block init and we’re going to go To our item init and we’re going to copy the deferred register and let’s change the item to block the items to blocks and the items over here to blocks then we can press ctrl shift o to import net.minecraft.world.level.block.block next i want to get the deferred register Of the items as well so let’s copy paste this start bit change the block to items change this to items and set it equal to item init dot item press ctrl shift o and import item and this is going to let let us register both blocks and items for our Blocks in one class next let’s create a couple of functions let’s go to our item init and copy paste this over here and we’re going to change this item to a block and change this to blocks as well and we’re going to call this register block then we’re going to copy this and Put it below and we’re going to change the register block to just register and we’re going to change a couple of things up we need to change this in our register block to something that extends t and we need to rename this to block like so then in Here we need the the exact same thing with block and this is going to be a function of registry object of t and so we need to put a comma here supplier of something that extends item and this is going to be our item let’s press ctrl shift o to import java.util.function.function Then we can remove this and we can say a registry object of t which is our object is going to be equal to register block of the name and the block then we do items dot register the name and item dot apply the block and then We’re going to return obj and what this is going to do is register our block with the name of the block and register an item based on the block that is given now we can create a block so let’s create a public static final registry object of block and this is Going to be our example block is equal to so we can either call register block if we don’t want to have an item associated with it or register if we do so i want an item so i’m going to use register and this is going to need the name once Again so example block then we need a supplier for the blocks let’s create a new block like so and then we need to add an argument for the properties and inside the block we’re going to create a block behavior dot properties dot of and then we pass In a material so i’m going to use material.metal because i’m going to have a metal block and a material color this is the color that will show up on the map so i’m going to set this to purple and that’s actually it now we need a Function for the item so as you can see over here this function first takes a registry object for the block so let’s call this object and we’re going to create a function like so and this function is going to create a new item for that block and in here we’re going To pass in new item dot properties like we did before and then this is the same thing as before so i’m going to set a tab for tutorial mod dot tutorial tab but this actually has to be a supplier so we need to add another one of these so now what We’re doing is creating a block with this name then we’re giving it a block with a material of metal and a purple color on the map and then we’re saying that we’re going to create a new item over here which is going to be in our tutorial tab now we Need to register our block in it and we want to make sure to do this after the items so let’s go to tutorial mod and under here all we have to do is add block init dot blocks dot register bus like so then we can save that and start Making the jsons and the block is going to have a couple more jsons than before so let’s create our block state in our block states package let’s create a new file this is going to be called example block so the name we set before dot json let’s open some brackets and what the Block state does is it chooses between different models based on the state of the block so let’s create a new thing called variance which is going to be a list of all the possible models so in our variance we can do any block state so this is for any different state of The block we’re going to use the same model and that model is going to be tutorial mod colon block slash example block which is going to reference a model in our models dot block package now let’s create our models dot block so in models block let’s create a new file And this is going to be called exampleblock.json and this is our block model so once again let’s open brackets and there’s a lot of different things you can do i recommend checking the minecraft wiki but we’re going to give this a parent which is going to be block slash cube Underscore all which means all the textures are going to be the same on every side of the cube next let’s add the textures just like we did in our item model and instead of using a layered zero here we’re going to have all so all of the sides are going to Have the texture tutorial mod colon block slash example block which is now going to reference the texture in our textures.block package and before we put the texture in let’s now edit our en dot u s dot json and in here we’re going to use block dot tutorial mod dot example block Is going to have the name example block and there we go i’ve created our example block texture which is also 16 by 16 and you can see it over here so let’s drag that into our textures.block and there we go however before i can do That i need to add a couple more stuff to the block so in our source main resources we’re going to create a new package and this is going to be data dot tutorial mod so here we have our texture pack and also we have over here a data pack in Here let’s create a new package called loot underscore tables dot blocks and this has to be plural and in here let’s create a new file called example block dot json and we want to just make sure that it drops the default block when it’s mined so let’s create a type and This is going to be of type minecraft colon block and then we have pools and this is going to be a list so we use square brackets and then we’re going to have one singular pool so let’s just open more brackets and this pool is only Going to have one roll so let’s do rolls colon 1.0 comma and then we need the entries for this roll so let’s add another list and in here we only have one singular entry and this is going to be a type of minecraft colon item so we’re going to drop an item with The name of tutorial mod colon example block so we would just want to drop our example block when it is mined and there we go that’s our loop table back in our block in it let’s give it a strength so after we set the color dot to purple We can add a dot and then we can give it a bunch of different stuff we can make it emit light we can make it have no collision etc i’ll cover this in detail in the next episodes but we’re going to do dot strength and this is going to be its Blast resistance and how difficult it is to mine i’m going to set this to 3.0 f but you can play around with this number if you’d like to let’s also give this a sound type so let’s do sound type dot metal and this is just some basic stuff that We can do once again i’ll be covering more of this in the next episode once again in our data package let’s create a new package and then we’re going to delete everything up until data and here we’re going to do data dot minecraft because what we want to do is Edit the tags for which blocks are minimal with an x and which are minimal with a pickaxe so let’s do data.minecraft.tags.blocks and press enter in here let’s create a new package called dot minable and in here we’re going to create a new file called pickaxe Top jason and you can change this to ho axe or shovel but i’m just going to leave this as pickaxe and we want to set replace to false because we want to keep all the vanilla stuff that’s in the game already then let’s add our values and This is going to be a list so let’s put in some value i’m going to add our tutorial mod example block and if you want to add more values you can just add a comma and add more lines like so but i only have one block so i’m just going to leave This for now so now our block is only minable with a pickaxe and you can do the exact same thing for different tools you just have to rename the file over here and we made a small mistake in the block init class this item actually needs to be a block item So let’s press ctrl shift o to import that and before the item.properties we need to add the block which is going to be object dot get like so and finally we need to create an item model for our block as well so that knows how to render in the inventory so Let’s create a new file called example block dot json and this is going to be a bit shorter than the item model for an item because all it’s going to have is the parent for our block model so our parent is tutorial mod colon block slash example block so that’s just Going to set our item model to be the same as our block model and in our block init i’m going to add dot requires correct tool for drops and then to set the mining level in our data we’re going to create a new file and we’re going to Click on blocks and call this needs iron tool dot json and you can set this to whatever you want so needs diamond tool or needs stone tool but i’m just going to copy everything from our pickaxe.json and paste it in here and that is it now We can run the game and in the game we can see that we have our example block and you can mine it with a pickaxe but if you mine it with an axe it won’t actually drop and the same goes for stone tools there you go that’s going to do it for This video if you need any help join the discord the link is in the description along with the source code and textures used in this video in the next episode we’re going to cover advanced blocks and items so that’s custom classes for the blocks and the items as well as block Properties and block states thank you for watching and i’ll see you next time Video Information
This video, titled ‘Minecraft Modding Tutorial 1.18 | #2 – Blocks + Items’, was uploaded by Cy4’s Modding on 2022-01-03 12:50:01. It has garnered 51567 views and 1156 likes. The duration of the video is 00:20:47 or 1247 seconds.
Hallo! Blocks, Items, Creative Tabs, JSONS, Textures, Tags…. wow. xD
(ɔ◔‿◔)ɔ ♥ ~ expand me
C://Help/ Discord: https://discord.gg/x9Mj63m4QG Or comment on this video!
C://Source_Code/ https://github.com/Cy4Shot/Modding-Tutorial-1.18
C://Follow_Me/ Subscribe: https://www.youtube.com/channel/UCJIDXtGpf4wv1ybDzdTA_vQ/ Website: https://cy4shot.github.io/
C://Time_Stamps/ 00:00 – Intro 😀 00:09 – Main Class 00:38 – Creative Tabs 01:47 – ItemInit 05:01 – Creative Tab Icon 05:32 – Registering ItemInit 06:04 – Item JSONs 08:18 – Item Texture 08:41 – Item Testing 08:57 – Creative Tab JSONs 09:17 – BlockInit 13:32 – Block JSONs 16:57 – Block Properties + Tags 20:00 – Block Testing 20:13 – Outro