HelpNation Tutorials

Would you like to react to this message? Create an account in a few clicks or log in to continue.
HelpNation Tutorials

Learn how to mod, make, read, or just review modding tutorials and mods!


    Creating Your First Block (Without ModLoader)

    Or1g1n_Of_Death
    Or1g1n_Of_Death
    Forum Founder
    Forum Founder


    Posts : 24
    Join date : 2011-11-05
    Location : My Computer

    Creating Your First Block (Without ModLoader) Empty Creating Your First Block (Without ModLoader)

    Post  Or1g1n_Of_Death Sat Nov 05, 2011 3:52 pm

    Basic Modding! *Making A Block*

    Modding Disclaimer:

    I, Or1g1n_Of_Death, do not take any responsibility for anything that might happen to your computer or any device you use while making code that may be unwanted. Anything saying I will be sued, etc. Will be deleted and you will be told to review this section.

    Just in case you didn't exactly get what I first said...

    Or1g1n_Of_Death is not responsible for anything that happens to your device you use to mod with, that you may not want. Thank you, have a nice day.

    Signed,
    ~Or1g1n; The King king


    Back To Modding!

    We are going to be doing a few key things in this part, mainly just adding a block with some effects.

    You are probably going to want a word engine designed for coding! I highly suggest NotePad++ for it's reliability, and it's easy to use features! I'm not sure of an exact link, as I got it quite a while ago. Eclipse should work, as well (Haven't used it.). Notepad original will work, but it my be a bit more difficult to do, but it WILL work!

    First step, will be to open your code engine and then click "File" then click "Open". Navigate to where your MCP folder is, and then go into C:\Users\User\FileLocation\mcp44\src\minecraft\net\minecraft\src. Now, we are going to make a mimick of stone, except it will have some cool slipperiness effects added. This will NOT be ModLoader compatible, I plan on writing a tutorial of that later on!

    Now, in the src folder, go ahead and find "BlockStone.java" and open it. It should look something like this. I've added some things in starting with //, don't worry, it doesn't mess up the code, it's just comments.


    Code:

    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode

    package net.minecraft.src;                //This just shows where the file was located.

    import java.util.Random;

    // Referenced classes of package net.minecraft.src:
    //            Block, Material

    public class BlockStone extends Block    //This tells the computer what this is doing, and how to.(Pretty Much)

    {

        public BlockStone(int i, int j)   
        {
            super(i, j, Material.rock);        //Tells the block's material.
        }

        public int idDropped(int i, Random random)
        {
            return Block.cobblestone.blockID;    //Lists the items dropped upon block's destruction.
        }
    }

    Now, there is a high chance you know what none of this means. That's cool, I'm still learning what some of it means entirely. Well, let's go ahead and name our block, I'm gonna name it SpeedStone, since it will be sliding us around. What we want to do, is change everything in the code that says "BlockStone" to "BlockSpeedStone". Let's go ahead and change the item it drops, to "Stone". It should look like this:

    Code:

    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode

    package net.minecraft.src;                //This just shows where the file was located.

    import java.util.Random;

    // Referenced classes of package net.minecraft.src:
    //            Block, Material

    public class BlockSpeedStone extends Block    //This tells the computer what this is doing, and how to.(Pretty Much)

    {

        public BlockSpeedStone(int i, int j)   
        {
            super(i, j, Material.rock);        //Tells the block's material.
        }

        public int idDropped(int i, Random random)
        {
            return Block.stone.blockID;    //Lists the items dropped upon block's destruction.
        }
    }

    Now, if you look inside of BlockIce.java's code, you will find this:

    Code:

    public BlockIce(int i, int j)
        {
            super(i, j, Material.ice, false);
            slipperiness = 0.98F;
            setTickOnLoad(true);
        }

    Well, let's go ahead and add the "Slipperiness" part into our block's code, except let's change it to 0.1F. This may sound like it might not do much, but it actually effects it in an opposite manner. Our block should look like this now:

    Code:

    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: http://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode

    package net.minecraft.src;                //This just shows where the file was located.

    import java.util.Random;

    // Referenced classes of package net.minecraft.src:
    //            Block, Material

    public class BlockSpeedStone extends Block    //This tells the computer what this is doing, and how to.(Pretty Much)

    {

        public BlockSpeedStone(int i, int j)   
        {
            super(i, j, Material.rock);        //Tells the block's material.
            slipperiness = 0.1F;
        }

        public int idDropped(int i, Random random)
        {
            return Block.stone.blockID;    //Lists the items dropped upon block's destruction.
        }
    }

    Now, how would we change the block's normal properties? Well, first you'll want to save this block. You would save it as "BlockSpeedStone.java". This IS case sensitive! Make sure it is JUST like the name of your block! Now, let's go ahead and head into Block.java and then scroll down. You should see various things that look just like this:

    Code:

    public static final Block stone;

    At the bottom of that list, (make sure there is still one with that format within one line.) go ahead and copy that in and change "stone" to "SpeedStone". Now, scroll down some more, and when you see things with this format, that's where you need to be:

    Code:

    stone = (new BlockStone(1, 1)).setHardness(1.5F).setResistance(10F).setStepSound(soundStoneFootstep).setBlockName("stone");

    Well, we're gonna make one of these, except in our block format. You see the part at the beginning after the first "BlockStone" where it has (1, 1))? Well, this is the integer format for our texture and ID. The first one is your int i, and the second is your int j. int i is the ID number, which has to be unique, and int j is the texture number, which can be reused. We're going to go ahead and add some light to our block, and we'll also keep the texture the same, and this should be how it's formatted:

    Code:

    SpeedStone = (new BlockSpeedStone(110, 1)).setHardness(1.5F).setResistance(10F).setLightValue(1.0F).setLightOpacity(3).setStepSound(soundStoneFootstep).setBlockName("SpeedStone");

    Now, what this does is illuminates the block. the ".setLightOpacity(3)" is basically just how clear or thick the light is. If you want, you can go ahead and choose to illuminate the block the way you want it to, with specified settings. Like, say you want it to be a dim alternative for glowstone, well, then you can set the value of ".setLightValue()" to around 0.3F or so. Whatever floats your boat.

    Let's Talk Textures!

    As you may have noticed, I said something about the int j, or the integer for your Block Texture. Well, I'm not to great with this, since pretty much the only way I know how to get the texture that you made to work, you modify the minecraft.jar's terrain.png. As you saw, I chose for the int j to be 1, which is the same as stone. If you want to change it, that's fine. But, you'll have to follow a specific rule. You have to make the texture, and then the int j has to be the exact texture's spot. Let me explain this some more.


    Well, as you see in the photo below, there are numerous open, or "Purple" spaces in this terrain.png. Well, you have to choose one of those open spaces to use for your block's texture. The way they are numbered, is the very first one in the top-left corner, is 0. The next to the right would be 1, and the next to the right would be 2, and so forth. I went ahead and chose space 30, as it was empty. It's the block directly next to the brown mushroom.


    Creating Your First Block (Without ModLoader) 30719121157


    Some More Block Stuff

    Ok, well, now that we have the properties for our block set up, now we need a recipe for it. The way we would make this, we would open up our text editor again, and then open up the "craftingmanager.java" Now, scroll down until you see numerous things in this format:

    Code:

    addRecipe(new ItemStack(Item.paper, 3), new Object[] {
                "###", Character.valueOf('#'), Item.reed
            });

    Once again, you may not know what this means, that's still ok, as it's easily explained. addRecipe is quite obvious, and ItemStack just tells you how much of what item the recipe creates. The are that is "###" is what the item consists of. Basicly, saying "###" means you need 1 row of that item. Meaning, "###" "###" "###" would say you need three rows of one item. This could also be done in different variables, such as "LSA" "SAL" "RBQ" which would make the item consist of multiple items, but this is rarely done in vanilla mc. Now, "Character.valueOf('#'), Item.reed" is telling you that "###" means you need 3 sugar cane, or reeds, to make one paper. Hence your normal in-game recipe. Well, let's go ahead and paste that into our text editor on a new page, and change "Item.paper" to "Block.SpeedStone". Go ahead and keep the "###" the same but change "Item.reed" to "Block.dirt". This is solely for testing, you can change the recipe afterwards.

    Hmm... You seem to realize something... WAIT! Our block hasn't been named! Well, here's the way we name it for everybody to see! Just navigate to the folder in your MCP, tem, and then go into bin, then minecraft, then lang, and finally, en.US.lang. Now, scroll down and look for things that look like this:


    Code:

    tile.stone.name=Stone
    tile.stone.desc=

    Well, this is pretty much self explanatory. But, as it seems, "tile.stone.desc=" Isn't a fully developed feature of the game yet or something. So, let's go ahead and make one of our own, you should replace anything that says stone with SpeedStone. It should end up like this:

    Code:

    tile.SpeedStone.name=SpeedStone
    tile.SpeedStone.desc=

    And... hey... It's done! What you want to do to test it, is run "recompile.bat" and then run "startclient.bat" proceed with making the recipe you set up (3 dirt) and then plop it down! And then, bask in the success you now have! Hooray! Now, you may be thinking, "These are .java files, not .class files. So... how do we put them in our Minecraft?" Simple! Just run "reobfuscate.bat" and then look in the "reobf" folder. Open "minecraft" and then Wala! Your modified class files!

      Current date/time is Thu Nov 21, 2024 10:01 am