MC Modding
Please register and join the community!

[1.8.1] Human NPC

View previous topic View next topic Go down

[1.8.1] Human NPC

Post by Strengthowns on Thu Jun 16, 2011 6:46 am

Human NPC

Spoiler:
EntityNamehere
Code:
package net.minecraft.src;

public class EntityNamehere extends EntityCreature
{

   public EntityNamehere(World world)
   {
      super(world);
      texture = "/Namehere.png";
                moveSpeed = 0.5F;
                attackStrength = 2;
                isImmuneToFire = false;
   }

   protected int getDropItemId()
   {
      return Item.swordStone.shiftedIndex;
   }
        public boolean canBreatheUnderwater()
        {
                return false;
        }
        protected boolean canDespawn()
        {
                return false;
        }
        public void onEntityDeath()
        {
                //If you know what you're doing, you can make it
                //do cool things. e.g. explode like creeper.
        }
}

mod_Namehere
Code:
package net.minecraft.src;
 
import java.lang.reflect.Method;
import java.util.Map;
 
public class mod_Namehere extends BaseMod
{

    public mod_Namehere()
    {
        ModLoader.RegisterEntityID(EntityNamehere.class, "Namehere", ModLoader.getUniqueEntityId());
        ModLoader.AddSpawn(EntityNamehere.class, 8, 4, 10, EnumCreatureType.creature);
    }

    public void AddRenderer(Map map)
    {
        map.put(EntityNamehere.class, new RenderBiped(new ModelBiped(), 0.5F));
    }
   
   public String Version()
    {
        return "1.7.3";
    }
}

Help: EntityNamehere

1. At the top, you can make it extend any of these: EntityCreature, EntityMob, EntityWaterMob. This changes the way it moves and it's behaviour.

2. Change whatever you want at the top like movespeed etc. The attack strength is how many half hearts of damage it does. If you want it immune to fire then make it "true".

3. The rest is self explaining. The texture is the exact same as what you'd use as your own skin.

4. Make the canBreatheUnderwater "true" if you want it to well...breathe underwater.

5. If you never want it to despawn other than by being killed, set the canDespawn to "true".

6. Take out the attackStrength if it isn't a hostile mob.

Help: mod_Namehere

1. At this part, change the Namehere between these " symbols to what you want it to be called in-game.
Code:
ModLoader.RegisterEntityID(EntityNamehere.class, "Namehere"

2. The 8 on the next line is the probability of the amount being spawned. If you have other NPC's in the same mod_Namehere file, think of it as a pie chart. Say one has 4 and one has 7, it will divide the total (11) between them. So the one with 4 has a probability of 4/11 chance of spawning.

2.1. The 4 is the minimum spawned per chunk.

2.2. The 10 is the max spawned per chunk.

3. For the enumcreatureblabla, you can make it one of these: monster, creature, waterCreature. This is how/where it spawns.


Extra:
Spoiler:

Making it Hold Something
1. If you want it to hold something, then make your EntityNamehere like this:
Code:
package net.minecraft.src;

public class EntityNamehere extends EntityCreature
{

   public EntityNamehere(World world)
   {
      super(world);
      texture = "/Namehere.png";
   }

   protected int getDropItemId()
   {
      return Item.swordStone.shiftedIndex;
   }
   
   public ItemStack getHeldItem()
    {
        return defaultHeldItem;
    }
   
   private static final ItemStack defaultHeldItem;
   
   static
    {
        defaultHeldItem = new ItemStack(Item.swordStone, 1);
    }
}

2. Just change the Item.swordStone to whatever you want.
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Human NPC

Post by MrCreeper07 on Sun Oct 23, 2011 3:33 pm

do you know how to combine different codes to do something? I wanted my Ben npc to hold a diamond sword and have "Ben" on the top of his head but i can't figure it out. i tried just combining it and it had errors. i could only get it to say "Ben" one time and not say that and have a diamond sword.

love your tutorials just registered! im a beginerer modder.

Thanks
-Ben
avatar
MrCreeper07
Member

Posts : 18
Join date : 2011-10-23

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by Strengthowns on Mon Oct 24, 2011 1:22 am

Just combine it? It should work fine?
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Human NPC

Post by breakyorself on Mon Oct 24, 2011 5:21 am

I get an error at:
Code:
 attackStrength = 2;
The error says it`s not a variable.
avatar
breakyorself
Member

Posts : 60
Join date : 2011-10-19

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by Strengthowns on Mon Oct 24, 2011 6:38 am

Get rid of that line, as it's not needed if your mob is peaceful. Also, please post in the help section for help.
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Human NPC

Post by austin56101 on Mon Oct 24, 2011 9:23 am

Do you know a way were you can like make it so you can pay them like gold or somthing , then they follow you and they kill dangerous mobs

Also it would be cool if you can give them like a specific things
Like u give them a sertain sword, armor, ect..
Smile
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by Strengthowns on Tue Oct 25, 2011 1:34 am

Have a look in the wolf code, it should have everything you need. I'm not tooo sure about the giving them specific things..
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Human NPC

Post by austin56101 on Tue Oct 25, 2011 1:37 am

Ooo! Good idea! Very Happy
Then I'll look and pig zombie for the weapon!
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by Strengthowns on Tue Oct 25, 2011 1:43 am

Yep, use the chatbox for live help next time.
avatar
Strengthowns
Admin

Posts : 79
Join date : 2011-06-14
Location : Right here!

View user profile http://www.mcmodding.4umer.com

Back to top Go down

Re: [1.8.1] Human NPC

Post by austin56101 on Tue Oct 25, 2011 2:10 am

o i was on iphone and it didnt show
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by bottz2 on Wed Oct 26, 2011 2:44 am

hey do you know how to add custom sounds with audio mod

bottz2
Member

Posts : 14
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by austin56101 on Wed Oct 26, 2011 2:48 am

i dont but ill find a tut


it didnt let me post a link so i copied/pasted it


How to add Music or Sound Effect to Minecraft with AudioMod

Custom Music

Simply place you music files into folder mod/sound in Minecraft’s folder.
Custom Sound Effects

Copy and Paste your sound effects into mod/sound.
Example, if you want to add new footstep sound effect to stone just add new stone1.ogg in mod/sound/step folder, and that’s all you need to do.
avatar
austin56101
Moderator
Moderator

Posts : 85
Join date : 2011-10-22
Age : 21
Location : Cali!

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by bottz2 on Wed Oct 26, 2011 2:50 am

how do i make i sensor with audio mod and how do i make .ogg files

bottz2
Member

Posts : 14
Join date : 2011-10-24

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by jaojake1804 on Fri Dec 16, 2011 6:48 pm

how would i get it to replace blocks instead of delete them.
etc. replace sand with gravel, dirt with stone

jaojake1804
Member

Posts : 10
Join date : 2011-10-26

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by jaojake1804 on Fri Dec 16, 2011 6:49 pm

when exploding i mean, mine explodes and i want it to replace blocks, instead of delete them

jaojake1804
Member

Posts : 10
Join date : 2011-10-26

View user profile

Back to top Go down

Re: [1.8.1] Human NPC

Post by Sponsored content


Sponsored content


Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum