Jump to content

[1.8] CustomEntityes some questions abouhow to make it follow me and du stuff, ?


perromercenary00

Recommended Posts

 

good days this morning i learn how to make a custom entity

and  i have some question about what i can do and whath not

 

this is what i have until now

 

ambisious i wanna make something like a little maid mod but more bitch and a little yandere, and alredy realize how to make she use the guns of mi mod in the video she spawn whit an mp5t5 and shooot it but there is some troubles

 

i want this to follow me around but the AI method

this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F));

is only in the tameable class

 

i declare the class of this mob whith

public class yunoMercenaria extends EntityMob implements IRangedAttackMob  {

i need the IRangedAttackMob to make work the fireguns so icould' not get ride of it

 

but if i declare it like tameable

public class yunoMercenaria extends EntityTameable implements IRangedAttackMob  {

it dont crash it dont show any error but the mob dont spawn in the world the same happend if i try to make it EntityVillager

it just work if i declare it like EntityMob

 

???

so in this case is some hidden trick need to make an entityTameable ?? or  i have to make workaround and do some custom new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F)); method compatible whith  EntityMob class

 

the other ting is that yuno hate itself soo if there is more than one they kill each other,

???

is some way to set some target entitys exception ore something like ?

 

yuno code

this code is just a bunch of copypaste from vainilla entityes and the tutorial from

http://www.minecraftforum.net/forums/mapping-and-modding/mapping-and-modding-tutorials/1571558-1-7-2-forge-add-new-block-item-entity-ai-creative

package mercenarymod.entidades;

import com.google.common.base.Predicate;

import mercenarymod.items.MercenaryModItems;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityAgeable;
import net.minecraft.entity.EntityCreature;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.entity.SharedMonsterAttributes;
import net.minecraft.entity.ai.EntityAIArrowAttack;
import net.minecraft.entity.ai.EntityAIAttackOnCollide;
import net.minecraft.entity.ai.EntityAIAvoidEntity;
import net.minecraft.entity.ai.EntityAIFleeSun;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIRestrictSun;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.monster.EntityZombie;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.DifficultyInstance;
import net.minecraft.world.World;

public class yunoMercenaria extends EntityMob implements IRangedAttackMob  { //EntityMob

    private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F);	
    private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.2D, false);
private boolean canPickUpLoot=false;

public yunoMercenaria(World worldIn) {
super(worldIn);


this.tasks.addTask(1, new EntityAISwimming(this));
//this.tasks.addTask(2, new EntityAIRestrictSun(this));
//this.tasks.addTask(2, this.field_175455_a);
this.tasks.addTask(3, new EntityAIFleeSun(this, 1.0D));



this.tasks.addTask(3, new EntityAIAvoidEntity(this, new Predicate()
{
    private static final String __OBFID = "CL_00002203";
    public boolean func_179945_a(Entity p_179945_1_)
    {
        return p_179945_1_ instanceof EntityWolf;
    }
    public boolean apply(Object p_apply_1_)
    {
        return this.func_179945_a((Entity)p_apply_1_);
    }
}, 6.0F, 1.0D, 1.2D));



//this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 5.0F));
this.tasks.addTask(4, new EntityAIWander(this, 1.0D));
this.tasks.addTask(6, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));

this.tasks.addTask(6, new EntityAILookIdle(this));

this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, false, new Class[0]));
this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityMob.class, true));
//this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityIronGolem.class, true));

if (worldIn != null && !worldIn.isRemote)
{
    this.setCombatTask();
}

//this.setCurrentItemOrArmor(0, new ItemStack(MercenaryModItems.cuchillomercenario,1,0));
this.setCurrentItemOrArmor(0, new ItemStack(MercenaryModItems.subfusilMP5T5,1,1));
//this.setCurrentItemOrArmor(0, new ItemStack(Items.bow));

}

@Override
protected void applyEntityAttributes()
{
 super.applyEntityAttributes();
this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
this.getEntityAttribute(SharedMonsterAttributes.followRange).setBaseValue(32.0D);
this.getEntityAttribute(SharedMonsterAttributes.knockbackResistance).setBaseValue(0.50D);
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D);
this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D);
}

public boolean isAIEnabled()
{
 return true;
}

@Override
public float getRenderSizeModifier()
{
    return 0.5F;
}

@Override
public boolean canPickUpLoot()
{
    return this.canPickUpLoot;
}


/**
* Attack the specified entity using a ranged attack.
*/
@Override
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    
    for (int i = 0; i < 3 ; i++ ){ //shoot four times 
    	
    	System.out.println("Atacando a "+p_82196_1_.getName());

mercenarymod.items.armasdefuego.balas.bala9mm_entity bala9mm = new mercenarymod.items.armasdefuego.balas.bala9mm_entity(this.worldObj, this, p_82196_1_, 10F, 1.0F);

int spell0 = 0;//EnchantmentHelper.getEfficiencyModifier(playerIn);
int spell1 = 0;// EnchantmentHelper.getFortuneModifier(playerIn);
int R = ((int) (Math.random() * 20)) + spell1;

int tipomunicion = 3;//getInttag(pistola, "tipomunicion");  

int cantDeEntidadesAfectadas=1;
float damageM = 0.0F;
float damageI = 0.0F;
float precision = 0.0F;

switch (tipomunicion) 
{
default: damageM = 0.0F ; damageI = 0.0F ; cantDeEntidadesAfectadas=0; break; //Empty bullet
case 1:	 damageM = 2.5F ; damageI = 0.0F ; cantDeEntidadesAfectadas=1; break; //bala9mm_Hierro
case 2:	 damageM = 3.0F ; damageI = 0.0F ; cantDeEntidadesAfectadas=1; break; //bala9mm_redstone
case 3:	 damageM = 3.5F ; damageI = 0.0F ; cantDeEntidadesAfectadas=1; break; //bala9mm_obisidana
}

bala9mm.setPrecision(precision);
bala9mm.setDamage(damageM);
bala9mm.setDamageI(damageI);
bala9mm.setCantDamage(cantDeEntidadesAfectadas);		

// critico
if (R > 18) {
	bala9mm.setIsCritical(true);
	bala9mm.setDamage(bala9mm.getDamage() * 2);
	bala9mm.setCantDamage(cantDeEntidadesAfectadas + 1);
	// chat.chatr(playerIn, "critico");
}
/*
int spell = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, pistola);
if (spell > 0) {
	bala9mm.setDamage(bala9mm.getDamage() + (float) spell * 0.5F + 0.5F);
}

spell = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, pistola);
if (spell > 0) {
bala9mm.setKnockbackStrength(spell);
}

spell = EnchantmentHelper.getEnchantmentLevel(Enchantment.knockback.effectId, pistola);
if (spell > 0) {
bala9mm.setKnockbackStrength(spell);
}

if ( tipomunicion == 2 & EnchantmentHelper.getEnchantmentLevel(Enchantment.fireAspect.effectId  , pistola) > 0) {
	bala9mm.setIsOnFire(true);
}

if ( tipomunicion == 2 & EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId  , pistola) > 0) {
	bala9mm.setIsOnFire(true);
}
*/


    
    this.playSound(	"modmercenario:subfusilMP5T5_disparo", 0.4F, 0.4F);
    this.worldObj.spawnEntityInWorld(bala9mm);
    
    
    }//fin del for 
    
    
    
}


public void setCombatTask()
{
    this.tasks.removeTask(this.aiAttackOnCollide);
    this.tasks.removeTask(this.aiArrowAttack);
    ItemStack itemstack = this.getHeldItem();

    if (itemstack != null && itemstack.getItem() == MercenaryModItems.subfusilMP5T5)  //Items.bow
    {
        this.tasks.addTask(4, this.aiArrowAttack);
    }
    else
    {
        this.tasks.addTask(4, this.aiAttackOnCollide);
    }
}

protected void func_180481_a(DifficultyInstance p_180481_1_)
{
    super.func_180481_a(p_180481_1_);
    this.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
}

/**
* Sets the held item, or an armor slot. Slot 0 is held item. Slot 1-4 is armor. Params: Item, slot
*/
public void setCurrentItemOrArmor(int slotIn, ItemStack stack)
{
    super.setCurrentItemOrArmor(slotIn, stack);

    if (!this.worldObj.isRemote && slotIn == 0)
    {
        this.setCombatTask();
    }
}

public float getEyeHeight()
{
    return  1.74F;
}

/**
* Returns the Y Offset of this entity.
*/
public double getYOffset()
{
    return super.getYOffset() - 0.5D;
}


/**
* (abstract) Protected helper method to read subclass entity data from NBT.
*/
public void readEntityFromNBT(NBTTagCompound tagCompund)
{
    super.readEntityFromNBT(tagCompund);
/*
    if (tagCompund.hasKey("SkeletonType", 99))
    {
        byte b0 = tagCompund.getByte("SkeletonType");
        this.setSkeletonType(b0);
    }
*/
    this.setCombatTask();
}

/**
* (abstract) Protected helper method to write subclass entity data to NBT.
*/
public void writeEntityToNBT(NBTTagCompound tagCompound)
{
    super.writeEntityToNBT(tagCompound);
  //  tagCompound.setByte("SkeletonType", (byte)this.getSkeletonType());
}

/*
@Override
public EntityAgeable createChild(EntityAgeable ageable) {
// TODO Auto-generated method stub
return null;
}
*/






}

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.