Thread: Basic Modding!

Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    Physcadelic's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Australia <3
    Posts
    4,450
    Reputation
    323
    Thanks
    828
    My Mood
    Breezy
    I am a beginner modder, but I realised that modding (basic mods) aren't as difficult as you might think. This is my tutorial on how to Decompile Minecraft and create a mod. Yay!

    The Tools
    We are going to need some tools!
    -A clean minecraft.jar (NOT CRACKED.)
    -Some basic coding knowledge. Don't get scared, it's only very basic.
    -Minecraft Coders Pack (Will be referred to as MCP)
    -Java Development Kit. (Get this one of the website, it is too big to upload). Java SE Downloads Trusted website.
    -Notepad++
    -Know how to install mods
    -How to add a PATH VARIABLE

    Let's Get Started!
    1. Get MCP up and running! Unzip to any location on your computer.
    2. Use HeartView's tutorial to find your .minecraft folder. https://www.mpgh.net/forum/422-minecr...ft-folder.html
    3. Copy the "bin" and "resources" folder to the jars folder in MCP.
    4. Run 'decompile.bat'
    5. Now navigate to MCP\sources\minecraft\net\minecraft\src* Whoa! That's a lot of files!
    6. Right click on any file you wish to mod and select open with Notepad++. For the tutorial I will be showing you how to make skeletons not
    burn during the day.
    7. Find EntitySkeleton.class this is the file we are going to mod.
    8. D: That's a lot of code! Can you see what might make a skeleton burn during the day?!

    Code:
    package net.minecraft.src;
    // Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
    // Jad home page: https://www.kpdus.com/jad.html
    // Decompiler options: packimports(3) braces deadcode 
    
    import java.util.Random;
    
    public class EntitySkeleton extends EntityMobs
    {
    
        public EntitySkeleton(World world)
        {
            super(world);
            texture = "/mob/skeleton.png";
        }
    
        protected String getLivingSound()
        {
            return "mob.skeleton";
        }
    
        protected String getHurtSound()
        {
            return "mob.skeletonhurt";
        }
    
        protected String getDeathSound()
        {
            return "mob.skeletonhurt";
        }
    
        public void onLivingUpdate()
        {
            if(worldObj.isDaytime())
            {
                float f = getEntityBrightness(1.0F);
                if(f > 0.5F && worldObj.canBlockSeeTheSky(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)) && rand.nextFloat() * 30F < (f - 0.4F) * 2.0F)
                {
                    fire = 300;
                }
            }
            super.onLivingUpdate();
        }
    
        protected void attackEntity(Entity entity, float f)
        {
            if(f < 10F)
            {
                double d = entity.posX - posX;
                double d1 = entity.posZ - posZ;
                if(attackTime == 0)
                {
                    EntityArrow entityarrow = new EntityArrow(worldObj, this);
                    entityarrow.posY += 1.3999999761581421D;
                    double d2 = entity.posY - 0.20000000298023224D - entityarrow.posY;
                    float f1 = MathHelper.sqrt_double(d * d + d1 * d1) * 0.2F;
                    worldObj.playSoundAtEntity(this, "random.bow", 1.0F, 1.0F / (rand.nextFloat() * 0.4F + 0.8F));
                    worldObj.entityJoinedWorld(entityarrow);
                    entityarrow.setArrowHeading(d, d2 + (double)f1, d1, 0.6F, 12F);
                    attackTime = 3;
                }
                rotationYaw = (float)((Math.atan2(d1, d) * 180D) / 3.1415927410125732D) - 90F;
                hasAttacked = true;
            }
        }
    
        public void writeEntityToNBT(NBTTagCompound nbttagcompound)
        {
            super.writeEntityToNBT(nbttagcompound);
        }
    
        public void readEntityFromNBT(NBTTagCompound nbttagcompound)
        {
            super.readEntityFromNBT(nbttagcompound);
        }
    
        protected int getDropItemId()
        {
            return Item.arrow.shiftedIndex;
        }
    
        protected void dropFewItems()
        {
            int i = rand.nextInt(3);
            for(int j = 0; j < i; j++)
            {
                dropItem(Item.arrow.shiftedIndex, 5);
            }
    
            i = rand.nextInt(3);
            for(int k = 0; k < i; k++)
            {
                dropItem(Item.bone.shiftedIndex, 1);
            }
    
        }
    
        public ItemStack getHeldItem()
        {
            return defaultHeldItem;
        }
    
        private static final ItemStack defaultHeldItem;
    
        static 
        {
            defaultHeldItem = new ItemStack(Item.bow, 1);
        }
    }
    That's right!

    Code:
    public void onLivingUpdate()
        {
            if(worldObj.isDaytime())
            {
                float f = getEntityBrightness(1.0F);
                if(f > 0.5F && worldObj.canBlockSeeTheSky(MathHelper.floor_double(posX), MathHelper.floor_double(posY), MathHelper.floor_double(posZ)) && rand.nextFloat() * 30F < (f - 0.4F) * 2.0F)
                {
                    fire = 300;
                }
    9. Now, if the code checks if it is daytime...then sets a skeleton on fire if it is...how could be make it so that it checks if it is daytime and doesn't set on fire?

    Of course!

    Code:
    fire = 0;
    So now when it's daytime, instead of Mr. Skeleton being bombarded with 300 watts of fire power...he receives 0. Yay!

    You can probably see lots of other little variables, play around with them!


    10. Now we have finished coding and are ready to add our mod into Minecraft.
    11. Open up your 'conf' folder and find 'client_obfuscation.txt'
    12. Delete the contents of this file and add our modded file into it. Remember, we modded EntitySkeleton so add that to the text document.
    13. Go back into your main MCP folder and find 'recompile.bat'. Unless you added random stuff or included a non-applicable variable, you should get no errors.
    14. If you don't get any errors, run 'reobf.bat'
    15. Now the moment of truth! Find your folder called final_out\minecraft. You should see a class file.
    16. Open up minecraft.jar and delete META-INF, if it is there. Drag and drop your class file in and close it.
    17. Open up Minecraft and load any world. Find yourself (or spawn) a skeleton and notice something. :O He isn't burning?!
    18. You have created an extremely basic mod, but it's a great start! Good job.

    If you have any errors or questions, post them here. This tutorial took a while to write, so thank and/or rep would be appreciated (:

    *Src means Source, in coding terms.

    Virus Scans : Online Virus Scanner

    Others aren't working, feel free to scan it for yourself and edit this post, @JamesA1994

    R.I.P a great GM




    Quote Originally Posted by Assalamu alaikum View Post
    what? maybe stop talk with riddles and with words i am not even know.

  2. The Following 9 Users Say Thank You to Physcadelic For This Useful Post:

    dimy (04-22-2011),Fogest (04-10-2011),FullStatic (04-10-2011),hoothoot (04-11-2011),joquelekok (09-05-2011),Thane. (04-10-2011),[MPGH]Thunder (04-11-2011),Unknown-C (05-03-2011),Vynlamor (06-01-2011)

  3. #2
    Heartview's Avatar
    Join Date
    May 2010
    Gender
    male
    Location
    KY Cygni
    Posts
    9,202
    Reputation
    717
    Thanks
    2,890
    Pretty cool. The only reason I never started was because I didnt feel like downloading the JDK. I might start making a few tweak mods and putting them up for lolz. Though most of the stuff I think of would require a little bit more than just 'basic' knowledge.
    Texture Mods


    Obedear, the sky is low

  4. #3
    FullStatic's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Minecraft Section
    Posts
    935
    Reputation
    -41
    Thanks
    55
    My Mood
    Aggressive
    Im going to start modding bro .
    Awesome. im going to make the monsters burn at night and chill in the day .

  5. #4
    Jailbroken671's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    13 28 N, 144 47 E
    Posts
    9,021
    Reputation
    704
    Thanks
    2,073
    My Mood
    Devilish
    why cant modding be like CA mods...

  6. #5
    Physcadelic's Avatar
    Join Date
    Aug 2010
    Gender
    male
    Location
    Australia <3
    Posts
    4,450
    Reputation
    323
    Thanks
    828
    My Mood
    Breezy
    Quote Originally Posted by Jailbroken671 View Post
    why cant modding be like CA mods...
    I wish haha. It's really not that difficult, in fact I found making my first MC mod easier than my first .rez mod. If you only look at small portions of text at a time, it becomes easy ;D

    R.I.P a great GM




    Quote Originally Posted by Assalamu alaikum View Post
    what? maybe stop talk with riddles and with words i am not even know.

  7. #6
    FullStatic's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Minecraft Section
    Posts
    935
    Reputation
    -41
    Thanks
    55
    My Mood
    Aggressive
    it REALLY isnt. i mean to get your head around all the LITTLE things is challenging but after that the only hardship is facing errors ;D

  8. #7
    Thunder's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    North
    Posts
    13,773
    Reputation
    2920
    Thanks
    3,655
    Great tutorial, I'll definitely make a one

    [X]
    Crossfire minion since 06-12-2011
    Minecraft minion since 06-20-2011
    Moderator since 08-17-2011
    Global Moderator since 09-10-2011
    Super User since 08-27-2012
    [X] [X] [X]

  9. #8
    hoothoot's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    44
    Reputation
    10
    Thanks
    1
    My Mood
    Cool
    I downloaded every item in the check list and followed every step but im getting a problem when I start to decompile the files. It goes through the steps (In CMD) but gets an error " 'Jar' is not recognised as an internal or external command' " Ive installed Java Development Kit and I had Java installed anyway. So at this step (after pressing any key to continue) I go to sources but nothing is there? .... Can you tell me what the problem is?

  10. #9
    FullStatic's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Minecraft Section
    Posts
    935
    Reputation
    -41
    Thanks
    55
    My Mood
    Aggressive
    you need to path the java so CMD can find it
    Just go here and learn how to do it easy.
    https://www.mpgh.net/forum/422-minecr...dder-easy.html

  11. #10
    hoothoot's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    44
    Reputation
    10
    Thanks
    1
    My Mood
    Cool
    ohhh.. right thanks a lot . This tutorial is really good.

  12. #11
    FullStatic's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Minecraft Section
    Posts
    935
    Reputation
    -41
    Thanks
    55
    My Mood
    Aggressive
    Thats ok.
    I got insprastion from this tutorial, but i didnt copy no re-write it.
    i made my own that is easyer and totally different.

  13. The Following User Says Thank You to FullStatic For This Useful Post:

    hoothoot (04-11-2011)

  14. #12
    hoothoot's Avatar
    Join Date
    Aug 2009
    Gender
    male
    Posts
    44
    Reputation
    10
    Thanks
    1
    My Mood
    Cool

    Smile

    Quote Originally Posted by ********** View Post
    Thats ok.
    I got insprastion from this tutorial, but i didnt copy no re-write it.
    i made my own that is easyer and totally different.
    Yeah I really like it. Helped me out a lot and gave me inspiration to start learning
    how to mod (games like minecraft).

  15. #13
    FullStatic's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Minecraft Section
    Posts
    935
    Reputation
    -41
    Thanks
    55
    My Mood
    Aggressive
    Well Thanks. Il adding that into my thread.

  16. #14
    I enjoy the sight of humans on their knees
    MPGH Member
    Thane.'s Avatar
    Join Date
    Feb 2011
    Gender
    male
    Location
    The Closet
    Posts
    1,970
    Reputation
    82
    Thanks
    85
    My Mood
    Inspired
    I am having a small prob. I got JDK, and the directory installed, folders in jars folder, but when I decompile it says "Cant change directory C:\ blah blah

  17. #15
    FullStatic's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Location
    Minecraft Section
    Posts
    935
    Reputation
    -41
    Thanks
    55
    My Mood
    Aggressive
    You didnt Make a path
    go to my tut and find the video in it.
    that should do ya .

Page 1 of 2 12 LastLast