Amazon Ad

Thursday, February 2, 2017

Tools

Hello, my name is Alex and I am going to show you how to create a mod for minecraft forge 1.11.2. There's not a lot of tutorials on 1.11 so I am creating one for those that want to get started.

WARNING: IF YOU DO NOT KNOW ANYTHING ABOUT JAVA, PLEASE LEARN THE BASICS BEFORE ATTEMPTING TO FOLLOW ANY MODDING TUTORIALS!!!!!


Now we get into the more complicated stuff. Tools are beginner to intermediate in minecraft modding. Let's get started.

Firstly, create five new Items in your ItemHandler. Call them, tutPickaxe, tutSword, tutAxe, tutSpade, and tutHoe. We will initalize them like this:


1
2
3
4
5
tutPickaxe = new ItemTutPickaxe("tut_pickaxe", MaterialHandler.TUTORIAL, CreativeTabHandler.tabTools);
tutSword = new ItemTutSword("tut_sword", MaterialHandler.TUTORIAL, CreativeTabHandler.tabCombat);
tutSpade = new ItemTutSpade("tut_spade", MaterialHandler.TUTORIAL, CreativeTabHandler.tabTools);
tutHoe = new ItemTutHoe("tut_hoe", MaterialHandler.TUTORIAL, CreativeTabHandler.tabTools);
tutAxe = new ItemTutAxe("tut_axe", MaterialHandler.TUTORIAL, CreativeTabHandler.tabTools);

Create the classes necessary for fixing these errors, but make their super classes ItemPickaxe, ItemSword, ItemSpade, ItemHoe, ItemAxe, respectively. Add the constructors and add the first parameter for the constructors String name, and the last parameter takes in a creative tab instance. We need to add the registry names for each of these so let's set them in the constructors:


1
2
setUnlocalizedName(name);
setRegistryName(name);
setCreativeTab(tab);

Put these two lines of code in each of the constructors. Next, we must create the MaterialHandler class that we will use to handle all of our tool and armor materials. We will create, in there, a static ToolMaterial called TUTORIAL. We will initalize it using the following code:


1
public static ToolMaterial TUTORIAL = EnumHelper.addToolMaterial("tutorial", 3, 2500, 5F, 5F, 20);

EnumHelper is how we add constants to the list of tool materials. We give it an unlocalizedName, harvest level, durability, damage float, efficiency float, and an enchantability.

The harvest level is the level in which our tools harvest at, diamond being 3.

The durability is how many uses this tool material has. It is how many times you can click with it before it breaks.

The efficiency is how fast the tool mines blocks. Diamond is 8F.

The damage float is how many hearts of damage it does to entities. Diamond is 3F,

The enchantability is how well it is enchanted. Gold is 20, and that is very high.

Next we have to register the items and render them. So let's create the item models necessary for them. Copy from diamond tools in Referenced Libraries > forgeSrc > assets > minecraft > models > item.

Create the five files, named after your registry name, and paste in the JSON code form each of their respective diamond cousins' files.

Also, make some textures. Rename "items/diamond_<tool>" to "tut:items/tut_<tool>".

Don't forget to go to our creative tabs handler and set the tab icons for each of the tabs.then set each of the tools to their respective tabs.

With some recent updates, we have to make a change to our ItemTutAxe class. In the super() call, we need to set an efficiency and damage floats. We can achieve this by calling on our material's efficiency and damage floats.


1
super(material, material.getDamageVsEntity(), material.getEfficiencyOnProperMaterial());

This allows us to pass through our material's damage and efficiency without having to hard code it in.

Let's run the game and test out our newly created tool set!




Looks like we gotta add some names. Let's go into our "en_US.lang" file and add them.


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
tile.tut_block.name=Tutorial Ore
item.tut_item.name=Tutorial Item
item.tut_sword.name=Tutorial Sword
item.tut_pickaxe.name=Tutorial Pickaxe
item.tut_axe.name=Tutorial Axe
item.tut_hoe.name=Tutorial Hoe
item.tut_spade.name=Tutorial Shovel
itemGroup.tab_blocks=Mod Blocks
itemGroup.tab_items=Mod Items
itemGroup.tab_tools=Mod Tools
itemGroup.tab_combat=Mod Combat

Now if we run the game, they should be fully functioning and named. Now if only we could craft them! *hint himt*

5 comments:

  1. I've been following along just fine till I got to this example. Is the completed source code available for this one specifically? btw, kudos for setting this up such that the user needs to go through it to learn it.

    ReplyDelete
  2. How do you use OreDictionary values in recipes?

    ReplyDelete
  3. my tools don't have durability. the material is not working

    ReplyDelete
  4. i'm also getting an error when i replace super(name, tab); in ItemTutAxe with super(material, material.getDamageVsEntity(), material.getEfficiencyOnProperMaterial()); its saying material cannot be resolved

    ReplyDelete