Minecraft Blogs / Article

Modding Tutorial 1: Adding a NPC

  • 2,866 views, 2 today
  • 6
  • 1
  • 5
Verfugungstrupp's Avatar Verfugungstrupp
Level 52 : Grandmaster Droid
111
Welcome to the my first java encoding tutorial for Minecraft. Before we start, you need the following:
+Eclipse
+Minecraft Coder pack
~Add the Audio Mod and Modloader to the Minecraft Coder Pack jars before decompiling
... Lets Begin.
First, make a java file called "mod_..." and then whatever you want to name your npc. NOTE: when I type in
"[Whatever]", get rid of the square brackets and type in the name of your npc. Also, don't type in the equals signs i put below here, they just represent a new section. Delete the Asterisks.
then type in:
==========================================================================

package net.minecraft.src;

import java.util.Map;

public class mod_[Whatever] extends BaseMod
{
public void load()
{
ModLoader.registerEntityID(Entity[Whatever].class, "[Whatever]",
ModLoader.getUniqueEntityId());

ModLoader.addSpawn(Entity[Whatever].class, 1, 1, 5, EnumCreatureType.monster*);
}
public void addRenderer(Map map)
{
map.put(Entity[Whatever].class, new RenderBiped(new ModelBiped(), 0.5F));
}

public String getVersion()
{
return "[Whatever]"**;
}

}

==================================================================
*can be changed from monster to creature or to water creature for underwater animals
**type in the version of your mod
==================================================================
You'll get an error on line 9, 12, and 16. Ignore them, we'll fix them later.
Next, create another java file named "Entity..." and then type in whatever you want your mod to be called, as said above. Same notes as said before apply here.
Type in:
==================================================================

package net.minecraft.src;

public class Entity[Whatever] extends EntityMob
{
private static final int HeldItem = Item. [Whatever] *.shiftedIndex;

public EntityEnclaveSoldier (World world)
{
super (world);
texture = " [Whatever] **";
attackStrength = 2***;
moveSpeed = 0.5F****;
}
public int getMaxHealth()
{
return ***;
}
public String addName()
{
return " [Whatever] ";
}
protected String getHurtSound()
{
return " [Whatever] ******";
}
protected String getDeathSound()
{
return " [Whatever] *****";
}

protected int getDropItemId()
{
return Item.[Whatever]*.shiftedIndex;
}
}
==============================================================
*after typing in Item. , you'll get a list of options to choose from

**Drag and drop the .png skin file into the net.minecraft.src package for your character, and in the quotations, have the name of that file with .png at the end

***any integer you want

****any integer you want, and then end it with a capital F

*****Drag and drop any .ogg sound file into the net.minecraft.src package and in the quotations add the name of your sound file with .ogg at the end
==============================================================
Go to your main Minecraft Coder Pack folder and run the following batch files in order.
+recompile.bat
+reobfuscate.bat
And then go into Minecraft Coder PackeclipseClientbinnetminecraftsrc
Extract the java files that were converted to class and then the png images and ogg sound files to go with it. Put them all in a .zip folder and Enjoy!
Tags

Create an account or sign in to comment.

1
10/14/2012 1:14 pm
Level 24 : Expert Modder
DanielMurphy
DanielMurphy's Avatar
does it work on minecraft 1.3.2
1
10/16/2012 8:00 pm
Level 52 : Grandmaster Droid
Verfugungstrupp
Verfugungstrupp's Avatar
yes
1
10/17/2012 1:09 pm
Level 24 : Expert Modder
DanielMurphy
DanielMurphy's Avatar
Have you got a video ?
1
07/03/2012 7:02 pm
Level 47 : Master Lad
Doggle
Doggle's Avatar
Thanks, really, really helpful. Make more of these please! I would love to make a mod with this stuff and try and improve it and that!
1
07/03/2012 7:40 pm
Level 52 : Grandmaster Droid
Verfugungstrupp
Verfugungstrupp's Avatar
Thanks.
I'll definitely post more
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome