Hatena
Planet Minecraft
Youtube
To start things off, here's a quick tutorial on how to make your own Minecraft human npc.
First things first. You need to download Minecraft Coder Pack or mcp for short. You also need modloader to make these or they won't work. Here are the templates for your mod.
mod_YourNameHere.java
package net.minecraft.src; import java.util.Map; public class mod_HumanNPC extends BaseMod { public void load() { ModLoader.registerEntityID(EntityNamehere.class, "IngameEntityName", ModLoader.getUniqueEntityId()); ModLoader.addSpawn(EntityNamehere.class, 12, 14, 18, EnumCreatureType.creature); } public void addRenderer(Map map) { map.put(EntityNamehere.class, new RenderBiped(new ModelBiped(), 0.5F)); } public String getVersion() { return "1.1"; } }
EntityYourNameHere.java
package net.minecraft.src; import java.util.Random; public class EntityNamehere extends EntityCreature { public EntityNamehere(World world) { super(world); texture = "/image.png"; moveSpeed = 0.5F; attackStrength = 4; //take this line out if this class doesn't extend EntityMob. } public int getMaxHealth() { return 20; } //you need audio mod to make your own sound for these next 3 lines protected String getLivingSound() { return "mob.villager.default"; } protected String getHurtSound() { return "mob.villager.defaulthurt"; } protected String getDeathSound() { return "mob.villager.defaultdeath"; } protected int getDropItemId() { return Item.ingotIron.shiftedIndex; } protected boolean canDespawn() { return false; } }
Understanding the code.
mod_Yournamehere.java
net.minecraft.src;
This will tell mcp where the mod is. It needs to be in the src folder and must have .java at the end of the name.
public class mod_HumanNPC extends BaseMod
This identifies it as a modloader mod and tells the Entity file that this is the base code.
ModLoader.registerEntityID(EntityNamehere.class, "IngameEntityName", ModLoader.getUniqueEntityId());
That code will give it is In-game Name. If you want to spawn it with single player commands mod or spawner gui mod, it needs the name or the mod won't work.
ModLoader.addSpawn(EntityNamehere.class, 12, 14, 18,
That will tell if it's modloader. The 12, 14, and 18 will tell the mod how rare it is. The default code is common.
EnumCreatureType.creature);
This will tell it what type of mob it is. For example, creature behaves like a pig or a cow, monster is like a zombie or a spider, and watercreature is like a squid. It spawns in water. Make sure the term creature or other types are in lower case!
public String getVersion()
This just tells it what version of Minecraft it will be on.
EntityNamehere.java
public class EntityNamehere extends EntityCreature
Entity Creature is like last time, but instead for the monster, it's Mob.
super(world); texture = "/image.png"; moveSpeed = 0.5F; attackStrength = 4;
Texture is the skin it has.
moveSpeed tells how fast or slow it goes.
attackStrength tells how strong it attacks. Delete it if it's a creature or a watercreature.
public int getMaxHealth() { return 20; }
This tells the mod how much health it has.
protected String getLivingSound() { return "mob.villager.default"; }
This tells what sound it makes when it's living.
protected String getHurtSound() { return "mob.villager.defaulthurt"; }
protected String getDeathSound() { return "mob.villager.defaultdeath"; }
This is the sound it makes when it dies.
protected int getDropItemId() { return Item.ingotIron.shiftedIndex; }
This code is what item or block it drops.
protected boolean canDespawn() { return false; } }
Finally this is the code that tells if it can despawn, as in disappear after a while. Change it to say "true" if you want it to despawn.
That's how to make a Minecraft ncp.
Thanks for reading my first post, and I hope you enjoy my blog.
No comments:
Post a Comment