Welcome to your ninth minecraft modding tutorial for minecraft 1.2.5 this is sega1121 and let’s go ahead and get started so in the last tutorial i talked to you guys about how to add a good texture and in this tutorial i want to talk to You guys about how to add a tool to the game or a weapon for that matter although i’ll probably do another tutorial on weapons um so this tutorial may be split up into several uh shorter tutorials because there is a lot to cover when you’re adding a new tool Um though i may be able to get it all in one tutorial i’m mainly worried about upload time because the 25 minute video takes like seven hours to upload not good um and excuse me if you hear any background noise just disregard it um yeah so Um the first thing we need to do is we need to create a material class for our um our tools and weapons for that matter so just go ahead and create a new class we’ll name it tutorial uh material and finish and here we are now this is going to be a slightly Different file instead of public class tutorial material we want to change first off class to enum now if you guys know java based off of my java tutorials i haven’t covered this yet this is pretty much saying that you are creating a new kind of data sort of I just look it up okay it’s hard to explain sort of um but so after you do that we have a significant amount to type so the first thing you need to do is you want to have the kind of your material so i’m just going to go ahead and do tutorial Now you probably want it to be in all caps so that you know that it’s an enum you don’t have to but you can and then you want quotation marks the name comma and five forty comma five hundred comma eight actually no i’ll do the four f comma six comma nine And then semicolon and you’ll see it’s giving us an error don’t worry about that error right now um i won’t talk about what all this means right now i’ll talk about it later so hang tight then we just need to declare a few variables so private final int harvest level And i’m just going to put these all on one line comma max uses comma efficiency on prop i missed got efficiency didn’t die proper material comma oh no no no no no we don’t want that damage versus entity comma enchantability semicolon and there we go now just go down private final float Uh e efficiency on proper material and then finally we need private static final m not md tutorial material all tool materials and there we go so now we can start doing some method coding so go ahead and create a constructor private tutorial material and then string f int i into j in k Float f int l and i one and then close off the method and ah okay disregard that error too so now we just need to do harvest level equals i max uses equals k e efficiency on proper material equals f oops not f l just f and we have damage versus entity Equals l and in chance ability equals i1 and i missed about that didn’t i ah oh there we go so now i’m going to explain what it all means so harvest level equals i um you’re pretty much saying up here when we said five that is our harvest level and harvest level is Pretty much like the level of block it can mine for example a stone pickaxe cannot mine diamond and a stone pickaxe has a harvest level of i believe two um i know a diamond pickaxe has a harvest level of five so that’s what i’m doing Now this 40 i don’t really know what it does um so yeah just leave that not really sure what it’s useful for now 500 is our max uses that should be relatively obvious how many times the tool is used before breaks 4f is the efficiency on proper material and this is pretty much The how good it is on the material that it mines for example a pickaxe in minecraft is better on stone than wood and that is its proper material and then it has its efficiency i’m leaving the set for f now the damage versus entity is obviously how much damage it deals And then inch and ability not really sure what that changes i just leave it at nine because that is apparently the default um i looked into the material class for minecraft so then we just need to do a bunch of getter methods public int get max uses and then return max uses and Then public float get efficiency on proper material return fish and see on proper material this is rather boring okay so public int get damage versus entity return damage versus and t and then we need oops public and get harvest level return harvest level oops and then finally if i scroll down there public Public and get enchantability return enchantability oops there we go so then we get to do something a little bit more interesting static and then just go in all tool materials equals parentheses and just close this off with a semicolon new tutorial material so the name of your class square brackets and then Um whatever this is called braces i think it is and then you want to put in here all of your materials so this is tutorial and then you would separate them by commas now if you want to have more than one materials then excuse any background noise by the way Then you would just put a comma and put the name of your material so tutorial 2 for example okay that’s really loud um i hope you guys can’t hear it you probably can um and so just go ahead and do that and there we go we have our material class i Need to delete this comma now we need to create a new class name and this will be tutorial item tool okay and finish and there we go now we need to import java.util.array and there we go now in here we have a lot of stuff so First we need to declare a few variables so private block locks effective against and this will be pretty much uh what blocks is this tool effective against public float efficiency on proper material that obviously is sort of what we just did public int damage versus entity Oh you know what i forgot we need extends item up here and there we go there’s the warning and then protected tutorial material which is what we just had and then tool material there we go so now we need to have a constructor pro tech dead if i can type and then tutorial Item tool and then into i and j tutorial material um i’m just m no tm um you can name that whatever you want and then block block that’s what i’m naming it because i feel it is easier to type and i misspelled this didn’t i yay okay there we go oops So now in here we want super i so just pretty easy and then we need to set a bunch of stuff so efficiency on proper material hopefully this is the last time i have to type this equals for f and that’s not right or whatever um and then tm equals no no Tool material equals cm and then we need blocks effective against equals lock and what is this i misspelled it i can’t type today apparently and then max stack size equals one now if you want your tool to be able to stack then you change the max stack size to um whatever you have To whatever you have there then we have set max damage and then tm dot get max uses um that well whatever um efficiency on proper material equals tm dot get efficiency on proper material and as a matter of fact we can just i i knew this didn’t look right Right we can just delete that then we need damage versus entity equals j plus tm dot get damage versus entity now we need a um and i think i explained everything i need to explain there so now we need a new method so public float get strength versus lock item stack is is Is that’s is not is block block and then we go down here and now we need a little for loop and that is four and i equals zero i is lesson lock effective against dot length i plus plus again excuse background noise um and in here if blocks effective against And then i inside uh square brackets equal equal block return efficiency on proper material and there we go and what did i do wrong i just did that oh and then return 1.0 f there we go so this is pretty simple it’s just going through your blocks effective against Array and i will explain that later and then it’s saying if a if this block is in that array then make it more efficient so then you need public boolean hit entity item stack is entity living el entity living el 2 and now we need i oops i s dot damage item 2 El 2 and then return true and there we go no more error now we need public boolean on block destroyed and i’m sorry if this tutorial isn’t very uh it’s very blah there’s just a lot of typing that has to go into it and we have items stack i s and i And in here we have wait a second yeah item stack oops no i s dot i’m sorry i have this all written down and so as i’m typing this in here it’s slightly different from what i have written down um to make it easier to type and so we have dot damage item One yeah return true so these two pretty much you’re saying if you hit an enemy then remove um two damage from whatever item it is that you’re holding and then return true and if you just destroyed a block remove one life point from whatever item you’re holding and then return true okay so Then we need public uh int get damage versus entity entity e and then return damage versus entity and then we need public ruling is full 3d return true so in this method if it if you don’t want your item to not be 3d or if you want your item to Not be 3d i don’t know why you would but if you don’t want it to be 3d then just return false i don’t know why you would though so public and then we just need public int get item in chantability and we need return again excuse background noise tool material dot get Enchantability and we are done here okay so then we need to create the last class and that is our item class so this is just going to be tutorial item tool what oh yep tutorial tool there so in here it’s just a normal item class so in except ins Except instead of extends item we want extends tutorial item tool since that is the kind of tool that our item is so then we just want private static effective against and then protected tutorial tool and i tutorial tutorial material and then tm now we just do super i three tm blocks effective against Now um what we want here is to what did i misspell again okay and in doing this long tutorial i’m quite tired i forgot what this three means so this three means that it is the damage that this tool does to um the entity that you hit against the um against whatever um No not against anything i’m sorry i’m a bit tired as i do this tutorial as you can probably tell so finally in this class static then just blocks effective against equals new lock then just do our little trick here and then here you would want To put all of the blocks that your block is effective against so let’s go ahead and say block dot dirt block dot stone and block dot wood and there we go so now just go into mod tutorial and we just need to create um our new item um and so We we know how to do that already so public static final item tutorial tool equals new tutorial no yeah tutorial tool and we have our item id so 2001 and then the material so we want tutorial material dot tutorial and then we just go in mod loader dot add name tutorial tool tutorial Tool and i forgot something again so we need dot set item name tutorial tool and so then we just um texture wise i’m going to just go ahead and use a texture i’ve made for a new mod i’m making um a little spear texture so i’m going to drag this in copy files And then we need tutorial tool dot icon index equals mod loader dot add override slash gui items dot png and this is slash alvin spear i believe uh yes dot png we need to add a little recipe i’m just going to copy this paste this and it’ll be s and S but we want space around it so yeah that’s um how you add the space in a recipe if you want say sticks in the center then you put put space s space and that means you want it in the center and then s item dot stick And there we go so now we should have our new item hopefully it doesn’t give us any errors oh dear and i must have messed it up somehow um oh run yeah there we go no slash in there single player um new world two okay so And sorry you guys can’t hear this um regular minecraft noises are going on i don’t want to have to spend the time video editing wise to um get the sound because that does take a long time and we have tutorial item oh duh just need to go in here Produces one and it produces two all right now hopefully it works regular minecraft noises sticks tutorial tool and let’s see okay i must have done something wrong um you know what maybe that um hmm maybe that was important let’s put that back so put back the efficient material equals 4f And this is just a little bit of debugging here and um yeah so hopefully that works um if not then i will ah okay so it works for one of them oh because these are graphs right okay yep so it works yay wait so that means if i do delete this Because it is useless and go into here and include lock dot graph and then hit run while this is going to be a long video then that means it will yay so there we have it we have our new tool yay so um i hope you all enjoyed thank you for Watching don’t forget to subscribe and i’ll see you next time bye Video Information
This video, titled ‘[1.2.5] Minecraft Modding Tutorial 9: Adding a New Item’, was uploaded by Sciguy1121 on 2012-04-30 23:17:41. It has garnered 2332 views and 25 likes. The duration of the video is 00:32:53 or 1973 seconds.
This is my 9th Minecraft modding tutorial. In this tutorial, I will teach you how to add a new item to Minecraft.