• 1

    posted a message on Mod Tutorials MCP
    Making Armor
    Open Item.java, RecipesArmor.java, and RenderPlayer.java. Let's go from easiest to hardest.

    In RenderPlayer.java, scroll down to the bottom where you see this:

       private static final String armorFilenamePrefix[] = {
       "cloth", "chain", "iron", "diamond", "gold"
        };


    At the end, add , "example" example being whatever your armor's material will be. This is what java uses to connect the armor item with the image for the armor's 3D model.

    Now, go to RecipesArmor.java. This lets you easily add all of the recipes for your armor.

    I'll type in everything I need to type, then explain.

       public RecipesArmor()
       {
          recipeItems = (new Object[][] {
             new Object[] {
                Item.leather, Block.fire, Item.ingotIron, Item.diamond, Item.ingotGold, Item.example
             }, new Object[] {
                Item.helmetLeather, Item.helmetChain, Item.helmetSteel, Item.helmetDiamond, Item.helmetGold, Item.helmetExample
             }, new Object[] 
                Item.plateLeather, Item.plateChain, Item.plateSteel, Item.plateDiamond, Item.plateGold, Item.plateExample
             }, new Object[] {
                Item.legsLeather, Item.legsChain, Item.legsSteel, Item.legsDiamond, Item.legsGold, Item.legsExample
             }, new Object[] {
                Item.bootsLeather, Item.bootsChain, Item.bootsSteel, Item.bootsDiamond, Item.bootsGold, Item.bootsExample
             }
          });
       }


    I added Item.example, Item.helmetExample, Item.plateExample etc. What Item.example does is tell minecraft what to make the recipes with, and all the other ones tell minecraft which items get those recipes. Once you get this done you are done writing all the recipes, and the last thing to code is the items themselves.

    Open Item.java, and find all of the:

    public static Item example = (new Item()).setIconCoord(, ).setItemName("");


    And add this line with all of those lines of code four times somewhere where you can easily find it:

    public static Item  = (new ItemArmor(, , , )).setIconCoord(, ).setItemName("");


    One time for each item. Name the items helmetExample, plateExample, legsExample, and bootsExample (because those are the names we used in RecipesArmor.java). ItemArmor(, , , )) Sets the properties of the armor. The first parameter is item ID which needs to be unique, second is how long it lasts, third is the render index which has to be different than the other armors' render indexes, and the fourth is the armor type (0 is helmet, 1 is chestplate, 2 is leggings, and 4 is boots). .setIconCoord(, ) connects the item with it's icon, and .setItemName("") sets the name to be used to give your armor an in-game name.

    I'll make honey armor because I already made a honey item in an earlier tutorial. I would go to RenderPlayer.java and at the end I would type:

       private static final String armorFilenamePrefix[] = {
       "cloth", "chain", "iron", "diamond", "gold", "honey"
        };


    This tells java how to find the image for the 3D model of the armor (what will show up when worn). Now I'd need to open one of the armors in temp/bin/minecraft/armor, and edit it so it will look like honey armor, and then save it in bin/minecraft/armor (you have to make the folder armor) as honey_1 for the torso and helmet, and honey_2 for the legs. I need to name it honey because that's what I wrote in RenderPlayer.java. I'll add the recipes now.

       public RecipesArmor()
       {
          recipeItems = (new Object[][] {
             new Object[] {
                Item.leather, Block.fire, Item.ingotIron, Item.diamond, Item.ingotGold, Item.honey
             }, new Object[] {
                Item.helmetLeather, Item.helmetChain, Item.helmetSteel, Item.helmetDiamond, Item.helmetGold, Item.helmetHoney
             }, new Object[] 
                Item.plateLeather, Item.plateChain, Item.plateSteel, Item.plateDiamond, Item.plateGold, Item.plateHoney
             }, new Object[] {
                Item.legsLeather, Item.legsChain, Item.legsSteel, Item.legsDiamond, Item.legsGold, Item.legsHoney
             }, new Object[] {
                Item.bootsLeather, Item.bootsChain, Item.bootsSteel, Item.bootsDiamond, Item.bootsGold, Item.bootsHoney
             }
          });
       }


    If you make multiple armor recipes, remember that you need to make the armor and the item in the same place (i.e. if you count how many things are in each array, all the honey things are the same number. If they aren't the recipes will get mixed up).

    And most importantly, I need to add the actual items.

    public static Item  helmetHoney = (new ItemArmor(105, 2, 5, 0)).setIconCoord(5, 6).setItemName("helmetHoney");
    public static Item  plateHoney = (new ItemArmor(106, 2, 5, 1)).setIconCoord(5, 7).setItemName("chestplateHoney");
    public static Item  legsHoney = (new ItemArmor(107, 2, 5, 2)).setIconCoord(5, 8).setItemName("leggingsHoney");
    public static Item  bootsHoney = (new ItemArmor(108, 2, 5, 3)).setIconCoord(5, 9).setItemName("bootsHoney");


    I typed ItemArmor because it's not a regular item, it's armor. I typed (105, 2, 5, 0) for the helmet because 105 is the next ID after honey's ID that isn't taken, and I wrote 2 because that's how strong it will be (look at other armor for examples), I wrote 5 because that's the next one that isn't taken, and I wrote 0 at the end because I want minecraft to know it's a helmet. I chose those icon coordinates because they weren't taken yet, and I had room for all of them to be vertical (not important, just organized). I wrote .setItemName("chestplateHoney") and .setItemName("leggingsHoney") because that's what Notch did for the other armors (you can write anything you want, though. You could write something completely irrelevant like cheese). Now, I just need to open items.png and draw those icons in the specified location (you can find that location by counting the columns from 0, and the rows from 0. The first parameter is columns, and second is rows).

    Now I'm done! The items aren't obtainable, though, because honey isn't obtainable yet. I could make it obtainable by adding a recipe or making hair blocks (I made them drop honey earlier) generate naturally.
    Posted in: Tutorials
  • 1

    posted a message on Mod Tutorials MCP
    Creating Ores

    First, make a block. Now open Block.java.

    Before we do anything, we need to change the block you made into an ore block. To do this, go to the block property lines of code in Block.java, and find the block you made. Change (new Block()) to (new BlockOre()). Now your block is an ore, so minecraft knows to look at BlockOre.java for more information on the block. Open BlockOre.java now, because we need to add some code there.

    Find this part of the code:

       if(blockID == Block.oreExample.blockID)
       {
           return Item.example.shiftedIndex;
       }


    In this code, minecraft checks which ore you broke, and then it returns an item. if(blockID == Block.oreExample.blockID) Checks if the ore is "oreExample", and if it is, it returns Item.example.shiftedIndex. If it's not, it just skips the line and checks if it's a different ore until it finds the right one.

    Copy that somewhere with all the other ones, and we can start making the block an ore.

    I'll make a hair block that drops honey, because I already made a hair block and a honey item in earlier tutorials. To do that, I would type this:

       if(blockID == Block.hair.blockID)
       {
           return Item.honey.shiftedIndex;
       }


    Now we should have a hair block that drops honey! Note that it won't be obtainable unless you add a recipe for it, or make it generate naturally.
    Posted in: Tutorials
  • 1

    posted a message on Mod Tutorials MCP
    Generating Blocks Naturally

    Open ChunkProviderGenerate.java. That's all you'll need to edit.

    Scroll down to the codes that are like this:

        for(int e = 0; e < ; e++)
        {
            int e1 = k + rand.nextInt(16);
            int e2 = rand.nextInt() + ;
            int e3 = l + rand.nextInt(16);
            (new WorldGenMinable(Block.example.blockID, )).generate(worldObj, rand, e1, e2, e3);
        }


    *Breathes in exaggeratedly* Don't worry about the integer e, it's just a temporary variable. In the for loop, you type e < (however many times you want the loop to run).The variable e1 sets the x position, e2 the y position, and e3 the z position. You shouldn't mess with the lines e1 and e3 are on, because it's already how it should be. The line with e2 sets the minimum and maximum height (from bedrock) your block can generate in (the number you put in the parameter gives the maximum height, and after the plus is minimum height. Minimum height is optional). WorldGenMinable is a different .java that has a method called generate, which was made specifically for generating ores (I say that because it replaces stone with the block to be generated, so the generated block will be underground). Block.example.blockID tells java which block to generate, and the second parameter in WorldGenMinable is an integer (it controls how many of the block can be together). *Gasps for air* Now just copy the code and paste it somewhere with all the other blocks of code like it, somewhere where you can easily find it.

    I'll make sponge generate commonly right under dirt. To do that, I would need to type this code:

        for(int e = 0; e < 64; e++)
        {
            int e1 = k + rand.nextInt(16);
            int e2 = rand.nextInt(124) + 118;
            int e3 = l + rand.nextInt(16);
            (new WorldGenMinable(Block.example.blockID, )).generate(worldObj, rand, e1, e2, e3);
        }


    This code would loop 64 times (which is quite a lot of times), randomly placing sponge four to ten blocks underneath the minimum height for dirt (which is 128).

    That's it, really. It's complicated, but doesn't take much time to do. Have fun!
    Posted in: Tutorials
  • 1

    posted a message on Mod Tutorials MCP
    Making a Simple Item

    First, open Item.java in src. Then, open items.png in temp/bin/gui with a photo editor like paint.net. Do NOT use paint. Paint doesn't support transparency. Lastly, open en_US.lang in temp/bin/lang (with notepad). In Item.java scroll down to where you see lots of:

    public static Item = (new Item()).setIconCoord(, ).setItemName("");


    The public static Item part initializes the item, and the rest sets the properties. new Item() sets the ID of the item (this HAS to be unique). .setIconCoord(, ) tells java where to look for the icon in items.png (first parameter is columns, second parameter is rows). .setItemName("") sets the name that is used to set the in-game name of your item.

    Now copy that line of code, and paste it somewhere with all the other lines like it. Make sure it's somewhere where you can easily find it. Now we're ready to start coding!

    I'll add honey. Why not? I'd type:

    public static Item honey = (new Item(104)).setIconCoord(3, 9).setItemName("honey");


    I typed new Item(104) and .setIconCoord(3, 9) because they weren't already taken. You can type whatever you want in .setItemName(""), but it's way easier to remember if it's the same as the name of your block.

    Now all that's left to do is give the honey an in-game name, and draw its icon. I'll start with the in-game name. Go to en_US.lang and scroll down to all of the:

    item.example.name=Example
    item.example.desc=


    This sets the in-game name of your item. Paste that code somewhere with all the other item.'s, preferably somewhere you can easily find it. Replace the example's with whatever your item is named. Capitalize words after the equal sign, because that will show up in the game. Don't add spaces. I honestly don't know what the item.example.desc does, but I bet it's necessary, so leave it in. Save the edited en_US.lang in a lang folder in your bin (you have to create the lang folder, and only put en_US.lang in it).

    Now lets draw the icon.

    Go to the item.png that you should have open already with a program that isn't paint. Draw the image in the spot you specified (the coordinates). You can find that spot by counting the rows and columns starting from 0. Once you find the location you specified, draw your icon in there. Make sure it is centered (each icon has a 16x16 pixel square to be drawn in)

    That should be all, and now your item is in the game! Make sure you test it, because mistakes can easily be made. And remember, if this is all you do, there is no way to obtain your item. If you want to be able to obtain it, add a recipe, or make an ore that drops it.
    Posted in: Tutorials
  • 1

    posted a message on Mod Tutorials MCP
    Creating Simple Blocks

    First, open Block.java in src. Then, open terrain.png in temp/bin with a photo editor like paint.net. Do NOT use paint. Paint doesn't support transparency. Lastly, open en_US.lang in temp/bin/lang (with notepad). In Block.java scroll down to where you see lots of:

    public static final Block example


    Those lines of code initialize the blocks. Without them, no blocks would be in the game.

    Just copy that code in some place with all the other block initializing codes (I prefer adding mine to the end), and change example to the name of your block.

    Scroll down again to the part of the code with:

    example = (new Block(,)).setHardness().setStepSound().setBlockName("example");


    Those lines of code give properties to the blocks. The name of the block you initialized should be the same as the first word in this line. (new Block(,)) sets the ID and texture ID of the block (ID needs to be unique). .setHardness and .setStepSound() are self-explanatory. .setBlockName("example") sets the name that will be used to set the in-game name of your block.

    I'll add a hair block. I was out of ideas... I'd type:

    hair = (new Block(97, 185)).setHardness(0.8F).setStepSound(soundClothFootstep).setBlockName("hair");


    I typed new Block(97, 185) because 96 is the last block ID, and the 185 texture ID isn't taken. I wrote .setHardness(0.8F) because I want the hair block to be easily breakable (The higher the number, the stronger the block. Look at other examples to get an idea of which number is how soft). I typed .setStepSound(soundClothFootsep), but you can replace Cloth with Powder, Wood, Gravel, Grass, Stone, Metal, Glass, Cloth, or Sand. You can type whatever you want in .setBlockName(""), but it's much easier to remember if it's the same as the name of your block.

    Now all that's left to do is give our block an in-game name, and draw its image. I'll start with the in-game name. Go to en_US.lang and scroll down to all of the:

    tile.example.name=Example
    tile.example.desc=


    This sets the in-game name of your block. Paste that code somewhere with all the other tile.'s, preferably somewhere you can easily find it. Replace the examples with whatever your block is named. Capitalize the one after the equal sign, because that will show up in the game. Don't add spaces. I honestly don't know what the tile.example.desc does, but I assume it's necessary. Save the edited en_US.lang in a lang folder in your bin (you have to create the lang folder, and only put en_US.lang in it).

    Now lets add the image.

    Go to the terrain.png that you should have opened earlier with a program that isn't paint. Draw the image in the spot you specified (the texture ID). You can find that spot by counting from left to right, top to bottom, starting from 0. Once you find the square you specified, draw your texture in there (the left and top purple lines get covered, but the other ones don't).

    Close everything and you should be done! Make sure you test it, because mistakes can easily be made.
    Posted in: Tutorials
  • 1

    posted a message on Mod Tutorials MCP
    Adding Recipes

    First, open CraftingManager.java in the src. Scroll down to where you see a bunch of:

    addRecipe(new ItemStack(Block.example, 1), new Object[] {
                "", "", "", Character.valueOf(''), Block.example
            });


    These lines of code add recipes. The part where it says Block.example, 1 (can also be Item.example, 1)tells java how many of what item to give you when you craft the recipe. The part with all the "",'s tells java how the recipe will look. The Character.valueOf(''), Block.example part tells java what the symbols in the quotations stand for.

    Just copy that code in some place with all the other addRecipe methods. I prefer adding mine to the end. Now we can start adding the recipe.

    Lets add a recipe that lets you craft a sponge block with a 2x2 of wool. I would type:


    addRecipe(new ItemStack(Block.sponge, 1), new Object[] {
                "##", "##", Character.valueOf('#'), Block.cloth
            });


    That would be all I need to do (note that cloth is what wool is called, so I wrote cloth instead of wool). In the quotations, you have to make sure the amount of characters in all quotations are equal. For example:

    // I can't type this:
    "###", "#", "#",
    // But typing this would work:
    "###", " # ", " # ",


    That's the end of this tutorial. Hope you find it helpful.
    Posted in: Tutorials
  • 2

    posted a message on Mod Tutorials MCP
    Mod Tutorials!

    I've moved on to C++, so these tutorials are discontinued.
    I'm assuming you already have a workspace.


    The Tutorials


    Recipes

    Shaped Recipes
    How to add a shaped crafting recipe to the game.


    Blocks

    Creating Simple Blocks
    How to create a very simple block that drops itself when broken.

    Creating Ores
    How to make ores (i.e. a block that drops an item)


    Items

    Making a Simple Item
    How to create simple items like diamond.

    Making Armor
    How to make a wearable set of armor.


    Natural Generation

    Natural Surface blocks
    How to naturally generate blocks you make.

    Posted in: Tutorials
  • To post a comment, please .