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)
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?!
That's right!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); } }
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?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; }
Of course!
So now when it's daytime, instead of Mr. Skeleton being bombarded with 300 watts of fire power...he receives 0. Yay!Code:fire = 0;
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
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)
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.![]()
Im going to start modding bro.
Awesome. im going to make the monsters burn at night and chill in the day.
why cant modding be like CA mods...
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
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?
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
ohhh.. right thanks a lot. This tutorial is really good.
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.
hoothoot (04-11-2011)
Well Thanks. Il adding that into my thread.
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
You didnt Make a path
go to my tut and find the video in it.
that should do ya .