Jump to content

[1.8] various questions about Entites and Why zombies dont atack this


Recommended Posts

Posted

Good days

im cleaning the little issues about mi entityes

and have some questions

 

video

 

-the first thing that anoys me is the armor model has not synced armas whith entity model arms so the mob arms are most of the time out of the armour arms, but no trouble whith legs or pants or boots or helmets 

is way to solved this or better rip off the arms from mi armours ?

 

-the second thing is the entity not swinging the ItemSwords on atack, for this entity i made a custom Model so i could control when  the entity aim their arms to fire guns and bows,  the entity Model is a copyPaste from PlayerRender Model anything else has been touch but still not swing. and think i have to make that for mi own but no idea of the values i must pace to this.swingProgress  ?

 

-the thirt thing is the zombie class and zombiePigman totally ignores this entiy even when this is atacking a zombie or pigman

for the other side skeletons and blazes atack the entity only when the entity atack first

is way to make this thing  an entityVillager tameable and whith the ability to shoot arrows ?

this entity now is just a copy paste from wolf class adding some things from skeleton class

 

render model

package mercenarymod.entidades;


import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelBiped;
import net.minecraft.client.model.ModelRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.entity.Entity;
import net.minecraft.util.MathHelper;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

@SideOnly(Side.CLIENT)
public class ModelBipedMercenary extends ModelBiped
{
    public ModelRenderer bipedHead;
    /** The Biped's Headwear. Used for the outer layer of player skins. */
    public ModelRenderer bipedHeadwear;
    public ModelRenderer bipedBody;
    /** The Biped's Right Arm */
    public ModelRenderer bipedRightArm;
    /** The Biped's Left Arm */
    public ModelRenderer bipedLeftArm;
    /** The Biped's Right Leg */
    public ModelRenderer bipedRightLeg;
    /** The Biped's Left Leg */
    public ModelRenderer bipedLeftLeg;
    /** Records whether the model should be rendered holding an item in the left hand, and if that item is a block. */
    public int heldItemLeft = 0;
    /** Records whether the model should be rendered holding an item in the right hand, and if that item is a block. */
    public int heldItemRight = 0;
    
        
    public boolean isSneak;
    /** Records whether the model should be rendered aiming a bow. */
    public boolean aimedBow;
    private static final String __OBFID = "CL_00000840";

    public ModelBipedMercenary()
    {
        this(0.0F);
    }

    public ModelBipedMercenary(float p_i1148_1_)
    {
        this(p_i1148_1_, 0.0F, 64, 32);
    }

    public ModelBipedMercenary(float p_i1149_1_, float p_i1149_2_, int p_i1149_3_, int p_i1149_4_)
    {
        this.textureWidth = p_i1149_3_;
        this.textureHeight = p_i1149_4_;
        this.bipedHead = new ModelRenderer(this, 0, 0);
        this.bipedHead.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, p_i1149_1_);
        this.bipedHead.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F);
        this.bipedHeadwear = new ModelRenderer(this, 32, 0);
        this.bipedHeadwear.addBox(-4.0F, -8.0F, -4.0F, 8, 8, 8, p_i1149_1_ + 0.5F);
        this.bipedHeadwear.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F);
        this.bipedBody = new ModelRenderer(this, 16, 16);
        this.bipedBody.addBox(-4.0F, 0.0F, -2.0F, 8, 12, 4, p_i1149_1_);
        this.bipedBody.setRotationPoint(0.0F, 0.0F + p_i1149_2_, 0.0F);
        this.bipedRightArm = new ModelRenderer(this, 40, 16);
        this.bipedRightArm.addBox(-3.0F, -2.0F, -2.0F, 4, 12, 4, p_i1149_1_);
        this.bipedRightArm.setRotationPoint(-5.0F, 2.0F + p_i1149_2_, 0.0F);
        this.bipedLeftArm = new ModelRenderer(this, 40, 16);
        this.bipedLeftArm.mirror = true;
        this.bipedLeftArm.addBox(-1.0F, -2.0F, -2.0F, 4, 12, 4, p_i1149_1_);
        this.bipedLeftArm.setRotationPoint(5.0F, 2.0F + p_i1149_2_, 0.0F);
        this.bipedRightLeg = new ModelRenderer(this, 0, 16);
        this.bipedRightLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, p_i1149_1_);
        this.bipedRightLeg.setRotationPoint(-1.9F, 12.0F + p_i1149_2_, 0.0F);
        this.bipedLeftLeg = new ModelRenderer(this, 0, 16);
        this.bipedLeftLeg.mirror = true;
        this.bipedLeftLeg.addBox(-2.0F, 0.0F, -2.0F, 4, 12, 4, p_i1149_1_);
        this.bipedLeftLeg.setRotationPoint(1.9F, 12.0F + p_i1149_2_, 0.0F);
    }

    /**
     * Sets the models various rotation angles then renders the model.
     */
    @Override
    public void render(Entity merEntity, float p_78088_2_, float p_78088_3_, float p_78088_4_, float p_78088_5_, float p_78088_6_, float p_78088_7_)
    {
        this.setRotationAngles(p_78088_2_, p_78088_3_, p_78088_4_, p_78088_5_, p_78088_6_, p_78088_7_, merEntity);
        GlStateManager.pushMatrix();

        if (this.isChild)
        {
            float f6 = 2.0F;
            GlStateManager.scale(1.5F / f6, 1.5F / f6, 1.5F / f6);
            GlStateManager.translate(0.0F, 16.0F * p_78088_7_, 0.0F);
            this.bipedHead.render(p_78088_7_);
            GlStateManager.popMatrix();
            GlStateManager.pushMatrix();
            GlStateManager.scale(1.0F / f6, 1.0F / f6, 1.0F / f6);
            GlStateManager.translate(0.0F, 24.0F * p_78088_7_, 0.0F);
            this.bipedBody.render(p_78088_7_);
            this.bipedRightArm.render(p_78088_7_);
            this.bipedLeftArm.render(p_78088_7_);
            this.bipedRightLeg.render(p_78088_7_);
            this.bipedLeftLeg.render(p_78088_7_);
            this.bipedHeadwear.render(p_78088_7_);
        }
        else
        {
            if (merEntity.isSneaking())
            {
                GlStateManager.translate(0.0F, 0.2F, 0.0F);
            }

            this.bipedHead.render(p_78088_7_);
            this.bipedBody.render(p_78088_7_);
            this.bipedRightArm.render(p_78088_7_);
            this.bipedLeftArm.render(p_78088_7_);
            this.bipedRightLeg.render(p_78088_7_);
            this.bipedLeftLeg.render(p_78088_7_);
            this.bipedHeadwear.render(p_78088_7_);
        }

        GlStateManager.popMatrix();
        
        
        
        if (merEntity instanceof mobMercenario){
        
        aimedBow = ((mobMercenario) merEntity).getAimedBow(); 
        isSneak = ((mobMercenario) merEntity).getisSneak();
        heldItemRight = ((mobMercenario) merEntity).getHeldItemRight();
        heldItemLeft = ((mobMercenario) merEntity).getHeldItemLeft();
        
        }
        
    }

    /**
     * Sets the model's various rotation angles. For bipeds, par1 and par2 are used for animating the movement of arms
     * and legs, where par1 represents the time(so that arms and legs swing back and forth) and par2 represents how
     * "far" arms and legs can swing at most.
     */
    public void setRotationAngles(float p_78087_1_, float p_78087_2_, float p_78087_3_, float p_78087_4_, float p_78087_5_, float p_78087_6_, Entity p_78087_7_)
    {
        this.bipedHead.rotateAngleY = p_78087_4_ / (180F / (float)Math.PI);
        this.bipedHead.rotateAngleX = p_78087_5_ / (180F / (float)Math.PI);
        this.bipedRightArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 2.0F * p_78087_2_ * 0.5F;
        this.bipedLeftArm.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 2.0F * p_78087_2_ * 0.5F;
        this.bipedRightArm.rotateAngleZ = 0.0F;
        this.bipedLeftArm.rotateAngleZ = 0.0F;
        this.bipedRightLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F) * 1.4F * p_78087_2_;
        this.bipedLeftLeg.rotateAngleX = MathHelper.cos(p_78087_1_ * 0.6662F + (float)Math.PI) * 1.4F * p_78087_2_;
        this.bipedRightLeg.rotateAngleY = 0.0F;
        this.bipedLeftLeg.rotateAngleY = 0.0F;

        if (this.isRiding)
        {
            this.bipedRightArm.rotateAngleX += -((float)Math.PI / 5F);
            this.bipedLeftArm.rotateAngleX += -((float)Math.PI / 5F);
            this.bipedRightLeg.rotateAngleX = -((float)Math.PI * 2F / 5F);
            this.bipedLeftLeg.rotateAngleX = -((float)Math.PI * 2F / 5F);
            this.bipedRightLeg.rotateAngleY = ((float)Math.PI / 10F);
            this.bipedLeftLeg.rotateAngleY = -((float)Math.PI / 10F);
        }

        if (this.heldItemLeft != 0)
        {
            this.bipedLeftArm.rotateAngleX = this.bipedLeftArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemLeft;
        }

        this.bipedRightArm.rotateAngleY = 0.0F;
        this.bipedRightArm.rotateAngleZ = 0.0F;

        switch (this.heldItemRight)
        {
            case 0:
            case 2:
            default:
                break;
            case 1:
                this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight;
                break;
            case 3:
                this.bipedRightArm.rotateAngleX = this.bipedRightArm.rotateAngleX * 0.5F - ((float)Math.PI / 10F) * (float)this.heldItemRight;
                this.bipedRightArm.rotateAngleY = -0.5235988F;
        }

        this.bipedLeftArm.rotateAngleY = 0.0F;
        float f6;
        float f7;

        if (this.swingProgress > -9990.0F)
        {
            f6 = this.swingProgress;
            this.bipedBody.rotateAngleY = MathHelper.sin(MathHelper.sqrt_float(f6) * (float)Math.PI * 2.0F) * 0.2F;
            this.bipedRightArm.rotationPointZ = MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F;
            this.bipedRightArm.rotationPointX = -MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
            this.bipedLeftArm.rotationPointZ = -MathHelper.sin(this.bipedBody.rotateAngleY) * 5.0F;
            this.bipedLeftArm.rotationPointX = MathHelper.cos(this.bipedBody.rotateAngleY) * 5.0F;
            this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY;
            this.bipedLeftArm.rotateAngleY += this.bipedBody.rotateAngleY;
            this.bipedLeftArm.rotateAngleX += this.bipedBody.rotateAngleY;
            f6 = 1.0F - this.swingProgress;
            f6 *= f6;
            f6 *= f6;
            f6 = 1.0F - f6;
            f7 = MathHelper.sin(f6 * (float)Math.PI);
            float f8 = MathHelper.sin(this.swingProgress * (float)Math.PI) * -(this.bipedHead.rotateAngleX - 0.7F) * 0.75F;
            this.bipedRightArm.rotateAngleX = (float)((double)this.bipedRightArm.rotateAngleX - ((double)f7 * 1.2D + (double)f8));
            this.bipedRightArm.rotateAngleY += this.bipedBody.rotateAngleY * 2.0F;
            this.bipedRightArm.rotateAngleZ += MathHelper.sin(this.swingProgress * (float)Math.PI) * -0.4F;
        }

        if (this.isSneak)
        {
            this.bipedBody.rotateAngleX = 0.5F;
            this.bipedRightArm.rotateAngleX += 0.4F;
            this.bipedLeftArm.rotateAngleX += 0.4F;
            this.bipedRightLeg.rotationPointZ = 4.0F;
            this.bipedLeftLeg.rotationPointZ = 4.0F;
            this.bipedRightLeg.rotationPointY = 9.0F;
            this.bipedLeftLeg.rotationPointY = 9.0F;
            this.bipedHead.rotationPointY = 1.0F;
        }
        else
        {
            this.bipedBody.rotateAngleX = 0.0F;
            this.bipedRightLeg.rotationPointZ = 0.1F;
            this.bipedLeftLeg.rotationPointZ = 0.1F;
            this.bipedRightLeg.rotationPointY = 12.0F;
            this.bipedLeftLeg.rotationPointY = 12.0F;
            this.bipedHead.rotationPointY = 0.0F;
        }

        this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
        this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
        this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
        this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;

        if (this.aimedBow)
        {
            f6 = 0.0F;
            f7 = 0.0F;
            this.bipedRightArm.rotateAngleZ = 0.0F;
            this.bipedLeftArm.rotateAngleZ = 0.0F;
            this.bipedRightArm.rotateAngleY = -(0.1F - f6 * 0.6F) + this.bipedHead.rotateAngleY;
            this.bipedLeftArm.rotateAngleY = 0.1F - f6 * 0.6F + this.bipedHead.rotateAngleY + 0.4F;
            this.bipedRightArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX;
            this.bipedLeftArm.rotateAngleX = -((float)Math.PI / 2F) + this.bipedHead.rotateAngleX;
            this.bipedRightArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;
            this.bipedLeftArm.rotateAngleX -= f6 * 1.2F - f7 * 0.4F;
            this.bipedRightArm.rotateAngleZ += MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
            this.bipedLeftArm.rotateAngleZ -= MathHelper.cos(p_78087_3_ * 0.09F) * 0.05F + 0.05F;
            this.bipedRightArm.rotateAngleX += MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
            this.bipedLeftArm.rotateAngleX -= MathHelper.sin(p_78087_3_ * 0.067F) * 0.05F;
        }

        copyModelAngles(this.bipedHead, this.bipedHeadwear);
    }

    public void setModelAttributes(ModelBase p_178686_1_)
    {
        super.setModelAttributes(p_178686_1_);

        if (p_178686_1_ instanceof ModelBipedMercenary)
        {
            ModelBipedMercenary modelbiped = (ModelBipedMercenary)p_178686_1_;
            this.heldItemLeft = modelbiped.heldItemLeft;
            this.heldItemRight = modelbiped.heldItemRight;
            this.isSneak = modelbiped.isSneak;
            this.aimedBow = modelbiped.aimedBow;
        }
    }

    public void setInvisible(boolean invisible)
    {
        this.bipedHead.showModel = invisible;
        this.bipedHeadwear.showModel = invisible;
        this.bipedBody.showModel = invisible;
        this.bipedRightArm.showModel = invisible;
        this.bipedLeftArm.showModel = invisible;
        this.bipedRightLeg.showModel = invisible;
        this.bipedLeftLeg.showModel = invisible;
    }

    public void postRenderArm(float p_178718_1_)
    {
        this.bipedRightArm.postRender(p_178718_1_);
    }
}

 

 

package mercenarymod.entidades;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import com.google.common.base.Predicate;

import mercenarymod.items.MercenaryModItems;
import mercenarymod.utilidades.chat;
import net.minecraft.block.Block;
import net.minecraft.block.state.BlockState;
import net.minecraft.block.state.IBlockState;
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.EntityAIBeg;
import net.minecraft.entity.ai.EntityAIFollowOwner;
import net.minecraft.entity.ai.EntityAIHurtByTarget;
import net.minecraft.entity.ai.EntityAILeapAtTarget;
import net.minecraft.entity.ai.EntityAILookIdle;
import net.minecraft.entity.ai.EntityAIMate;
import net.minecraft.entity.ai.EntityAINearestAttackableTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtByTarget;
import net.minecraft.entity.ai.EntityAIOwnerHurtTarget;
import net.minecraft.entity.ai.EntityAISwimming;
import net.minecraft.entity.ai.EntityAITargetNonTamed;
import net.minecraft.entity.ai.EntityAIWander;
import net.minecraft.entity.ai.EntityAIWatchClosest;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.monster.EntityGhast;
import net.minecraft.entity.monster.EntityIronGolem;
import net.minecraft.entity.monster.EntityMob;
import net.minecraft.entity.monster.EntityPigZombie;
import net.minecraft.entity.monster.EntitySkeleton;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityHorse;
import net.minecraft.entity.passive.EntityRabbit;
import net.minecraft.entity.passive.EntitySheep;
import net.minecraft.entity.passive.EntityTameable;
import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.projectile.EntityArrow;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.item.EnumDyeColor;
import net.minecraft.item.Item;
import net.minecraft.item.ItemFood;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.pathfinding.PathNavigateGround;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;

public class mobMercenario extends EntityTameable implements IRangedAttackMob {
/** Float used to smooth the rotation of the wolf head */
private float headRotationCourse;
private float headRotationCourseOld;
/** true is the wolf is wet else false */
private boolean isWet;
/** True if the wolf is shaking else False */
private boolean isShaking;
/**
 * This time increases while wolf is shaking and emitting water particles.
 */
private float timeWolfIsShaking;
private float prevTimeWolfIsShaking;
private static final String __OBFID = "CL_00001654";

public float height = 1.8F;

private int heldItemLeft = 1;
/**
 * Records whether the model should be rendered holding an item in the right
 * hand, and if that item is a block.
 */
private int heldItemRight = 0;

public boolean isSneak = false;
/** Records whether the model should be rendered aiming a bow. */
private boolean aimedBow = false;
private int aimedBowTick = 0;

private int onUpdateTick = 0;

private InventoryBasic mercenaryInventory;

private EntityLivingBase shootingEntity;
private int shootingEntityId = 0;

private Entity targetEntity;
private int targetEntityId = 0;

private int[] ignorar = { 0 };

// inventario de la shootingEntity
private int mainInventorySize = 5;
private ItemStack[] mainInventory = new ItemStack[mainInventorySize];

private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 10, 30.0F);
private EntityAIAttackOnCollide aiAttackOnCollide = new EntityAIAttackOnCollide(this, EntityMob.class, 1.2D, false);

// #################################################################################################################
public mobMercenario(World worldIn) {
	super(worldIn);
	this.setSize(0.6F, 1.8F);

	((PathNavigateGround) this.getNavigator()).func_179690_a(true);
	this.tasks.addTask(1, new EntityAISwimming(this));
	this.tasks.addTask(2, this.aiSit);
	// this.tasks.addTask(3, new EntityAILeapAtTarget(this, 0.4F));
	// this.tasks.addTask(4, new EntityAIAttackOnCollide(this, 1.0D, true));

	this.tasks.addTask(5, new EntityAIFollowOwner(this, 1.0D, 10.0F, 2.0F));
	this.tasks.addTask(6, new EntityAIMate(this, 1.0D));
	this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
	// this.tasks.addTask(8, new EntityAIBeg(this, 8.0F));
	this.tasks.addTask(9, new EntityAIWatchClosest(this, EntityPlayer.class, 8.0F));
	this.tasks.addTask(9, new EntityAILookIdle(this));
	this.targetTasks.addTask(1, new EntityAIOwnerHurtByTarget(this));
	this.targetTasks.addTask(2, new EntityAIOwnerHurtTarget(this));

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

	// this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this,
	// EntitySkeleton.class, false));
	this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPigZombie.class, true));
	// this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this,
	// EntityIronGolem.class, true));

	this.setTamed(false);

	this.targetTasks.addTask(4, new EntityAITargetNonTamed(this, EntityAnimal.class, false, new Predicate() {
		private static final String __OBFID = "CL_00002229";

		public boolean func_180094_a(Entity p_180094_1_) {
			return p_180094_1_ instanceof EntitySheep || p_180094_1_ instanceof EntityRabbit;
		}

		public boolean apply(Object p_apply_1_) {
			return this.func_180094_a((Entity) p_apply_1_);
		}
	}));

	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 EntityCreeper;
		}

		public boolean apply(Object p_apply_1_) {
			return this.func_179945_a((Entity) p_apply_1_);
		}
	}, 6.0F, 1.0D, 1.2D));

	//this.setCurrentItemOrArmor(0, new ItemStack(Items.bow));
	// this.setCurrentItemOrArmor(0, new
	// ItemStack(MercenaryModItems.fusilSCARH,1,1));
	//this.setCurrentItemOrArmor(0, new ItemStack(MercenaryModItems.subfusil90PNF, 1, 14));

	this.setCurrentItemOrArmor(0, new ItemStack(MercenaryModItems.subfusilMP5T5, 1, );
	// this.setCurrentItemOrArmor(0, new
	// ItemStack(MercenaryModItems.maid_P90,1,3));
	// this.setCurrentItemOrArmor(0, new
	// ItemStack(MercenaryModItems.subfusil90PNF,1,14));

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

}

// #################################################################################################################
@Override
protected void applyEntityAttributes() {
	super.applyEntityAttributes();
	this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.30000001192092896D);

	if (this.isTamed()) {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
	} else {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
	}

	this.getAttributeMap().registerAttribute(SharedMonsterAttributes.attackDamage);
	this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(2.0D);
}

// #################################################################################################################
@Override
/**
 * Sets the active target the Task system uses for tracking
 */
public void setAttackTarget(EntityLivingBase p_70624_1_) {
	super.setAttackTarget(p_70624_1_);

	if (p_70624_1_ == null) {
		this.setAngry(false);
	} else if (!this.isTamed()) {
		this.setAngry(true);
	}
}

// #################################################################################################################
@Override
protected void updateAITasks() {
	this.dataWatcher.updateObject(18, Float.valueOf(this.getHealth()));
}

// #################################################################################################################
@Override
protected void entityInit() {
	super.entityInit();
	this.dataWatcher.addObject(18, new Float(this.getHealth()));
	this.dataWatcher.addObject(19, new Byte((byte) 0));
	this.dataWatcher.addObject(20, new Byte((byte) EnumDyeColor.RED.getMetadata()));

	// variables del render
	// a aimedBow boolean
	// s isSneak boolean
	// r heldItemRight int 0~4
	// l heldItemLeft int 0~1

	int lrsa = 0;
	this.dataWatcher.addObject(21, lrsa);

}

// #################################################################################################################
@Override
protected void playStepSound(BlockPos p_180429_1_, Block p_180429_2_) {
	this.playSound("mob.wolf.step", 0.15F, 1.0F);
}

// #################################################################################################################
@Override
/**
 * Handles updating while being ridden by an entity
 */
public void updateRidden() {
	super.updateRidden();

	if (this.ridingEntity instanceof EntityCreature) {
		EntityCreature entitycreature = (EntityCreature) this.ridingEntity;
		this.renderYawOffset = entitycreature.renderYawOffset;
	}
}

// #################################################################################################################
@Override
/**
 * Called when the mob's health reaches 0.
 */
public void onDeath(DamageSource cause) {


	//dropear contenidos 

	ItemStack gun = this.getHeldItem();
	if (gun != null & !this.worldObj.isRemote) {


		double dx = this.posX;
		double dy = this.posY + 2;
		double dz = this.posZ;


	// leer slots del arma

	NBTTagCompound tagCompund = gun.getTagCompound();

	if (tagCompund != null)

	{

		NBTTagList nbttaglist = tagCompund.getTagList("Inventory", 10);


		for (int i = 0; i < nbttaglist.tagCount(); ++i) {
			ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttaglist.getCompoundTagAt(i));

			if (itemstack != null) {

				this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, dx , dy , dz , itemstack ));			


			}
		}
		nbttaglist = new NBTTagList();
		tagCompund.setTag("Inventory", nbttaglist);
		gun.setTagCompound(tagCompund);


	}

	this.worldObj.spawnEntityInWorld(new EntityItem(this.worldObj, dx , dy , dz , gun ));	


	}


}

// #################################################################################################################
//@Override
/**
 * (abstract) Protected helper method to write subclass entity data to NBT.
 */


   /**
     * (abstract) Protected helper method to read subclass entity data from NBT.
     */
    public void readEntityFromNBT(NBTTagCompound tagCompund)
    {
        super.readEntityFromNBT(tagCompund);
        
        tagCompund.setBoolean("Angry", this.isAngry());
        tagCompund.setByte("CollarColor", (byte) this.getCollarColor().getDyeDamage());


        this.setCombatTask();
    }

    /**
     * (abstract) Protected helper method to write subclass entity data to NBT.
     */
    public void writeEntityToNBT(NBTTagCompound tagCompound)
    {
        super.writeEntityToNBT(tagCompound);
    }

    /**
     * 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 void writeEntityToNBT(NBTTagCompound tagCompound) {
	super.writeEntityToNBT(tagCompound);
	tagCompound.setBoolean("Angry", this.isAngry());
	tagCompound.setByte("CollarColor", (byte) this.getCollarColor().getDyeDamage());


	NBTTagList nbttaglist = new NBTTagList();

	mainInventory[0]=this.getEquipmentInSlot(0);
	mainInventory[1]=this.getEquipmentInSlot(1);
	mainInventory[2]=this.getEquipmentInSlot(2);
	mainInventory[3]=this.getEquipmentInSlot(3);
	mainInventory[4]=this.getEquipmentInSlot(4);


	for (int i = 0; i < this.mainInventorySize; ++i) {
		ItemStack itemstack = mainInventory[i] ;

		if (itemstack != null) {
			nbttaglist.appendTag(itemstack.writeToNBT(new NBTTagCompound()));
		}
	}
	tagCompound.setTag("Inventory", nbttaglist);

}*/

// #################################################################################################################
//@Override
/**
 * (abstract) Protected helper method to read subclass entity data from NBT.
 *//*
public void readEntityFromNBT(NBTTagCompound tagCompund) {
	super.readEntityFromNBT(tagCompund);


	this.setAngry(tagCompund.getBoolean("Angry"));

	if (tagCompund.hasKey("CollarColor", 99)) {
		this.setCollarColor(EnumDyeColor.byDyeDamage(tagCompund.getByte("CollarColor")));
	}


	NBTTagList nbttaglist3 = tagCompund.getTagList("Inventory", 10);

	for (int i = 0; i < nbttaglist3.tagCount(); ++i) {

		NBTTagCompound nbttagcompound3 = nbttaglist3.getCompoundTagAt(i);
		int j = nbttagcompound3.getByte("Slot") & 255;

		if (j >= 0 && j < mainInventorySize) {
			mainInventory[j] = ItemStack.loadItemStackFromNBT(nbttagcompound3);

			if (mainInventory[j] != null) {
				//System.out.println("mainInventory[" + j + "]" + mainInventory[j].getUnlocalizedName());
				// chat.chatga(shootingEntity, "mainInventory["
				// + j + "]" +
				// mainInventory[j].getUnlocalizedName());
			}

		}

		this.setCurrentItemOrArmor(0, mainInventory[0]);
		this.setCurrentItemOrArmor(1, mainInventory[1]);
		this.setCurrentItemOrArmor(2, mainInventory[2]);
		this.setCurrentItemOrArmor(3, mainInventory[3]);
		this.setCurrentItemOrArmor(4, mainInventory[4]);

	}


	this.setCombatTask();

	this.setCanPickUpLoot(true);
	// this.func_175552_ct();

}*/

// #################################################################################################################
//@Override
   /**
     * 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();
        }
    }
*/
// #################################################################################################################
@Override
/**
 * Returns the sound this mob makes while it's alive.
 */
protected String getLivingSound() {
	return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}

// #################################################################################################################
@Override
/**
 * Returns the sound this mob makes when it is hurt.
 */
protected String getHurtSound() {
	return "mob.wolf.hurt";
}

// #################################################################################################################
@Override
/**
 * Returns the sound this mob makes on death.
 */
protected String getDeathSound() {
	return "mob.wolf.death";
}

// #################################################################################################################
@Override
/**
 * Returns the volume for the sounds this mob makes.
 */
protected float getSoundVolume() {
	return 0.4F;
}

// #################################################################################################################
@Override
protected Item getDropItem() {
	return Item.getItemById(-1);
}

// #################################################################################################################
@Override
/**
 * Called frequently so the entity can update its state every tick as
 * required. For example, zombies and skeletons use this to react to
 * sunlight and start to burn.
 */
public void onLivingUpdate() {
	super.onLivingUpdate();

	if (!this.worldObj.isRemote && this.isWet && !this.isShaking && !this.hasPath() && this.onGround) {
		this.isShaking = true;
		this.timeWolfIsShaking = 0.0F;
		this.prevTimeWolfIsShaking = 0.0F;
		this.worldObj.setEntityState(this, (byte) ;
	}

	if (!this.worldObj.isRemote && this.getAttackTarget() == null && this.isAngry()) {
		this.setAngry(false);
	}
}

// #################################################################################################################

/**
 * sets this entity's combat AI.
 */

public void setCombatTask() {

	this.tasks.removeTask(this.aiAttackOnCollide);
	this.tasks.removeTask(this.aiArrowAttack);
	ItemStack itemstack = this.getHeldItem();



	if (armasDisparables.esDisparable(itemstack)) {
		this.tasks.addTask(4, this.aiArrowAttack);
	} else {
		this.tasks.addTask(4, this.aiAttackOnCollide);
	}
}

// #################################################################################################################

/**
 * Attack the specified entity using a ranged attack.
 */
@Override
public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_) {

	ItemStack itemstack = this.getHeldItem();
	targetEntityId = target.getEntityId();


	if(itemstack != null){
	Item cosa = itemstack.getItem();
	if (cosa == Items.bow) {

		EntityArrow entityarrow = new EntityArrow(this.worldObj, this, target, 1.6F, (float) (14 - this.worldObj.getDifficulty().getDifficultyId() * 4));
		int i = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, this.getHeldItem());
		int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, this.getHeldItem());
		entityarrow.setDamage((double) (p_82196_2_ * 2.0F) + this.rand.nextGaussian() * 0.25D + (double) ((float) this.worldObj.getDifficulty().getDifficultyId() * 0.11F));

		if (i > 0) {
			entityarrow.setDamage(entityarrow.getDamage() + (double) i * 0.5D + 0.5D);
		}

		if (j > 0) {
			entityarrow.setKnockbackStrength(j);
		}
		this.worldObj.spawnEntityInWorld(entityarrow);

	}
}

	this.targetEntity = target;



	//noEstaMuyLejosNiEstaObstruido(this, target, 30.0F);


	this.swingItem();



}

// #################################################################################################################
boolean noEstaMuyLejosNiEstaObstruido(Entity ea, Entity eb, float limite) {
	boolean salida = true;

	float distancia = ea.getDistanceToEntity(eb);
	if (distancia > limite) {
		salida = false;
	}


	System.out.println("distancia="+distancia+"/"+limite);
	System.out.println("salida="+salida);

	if (salida) {

		Vec3 vec31 = new Vec3(ea.posX, ea.posY + ea.getEyeHeight(), ea.posZ);
		Vec3 vec3 = new Vec3(eb.posX, eb.posY + eb.getEyeHeight(), eb.posZ);


		System.out.println("0");
		MovingObjectPosition movingobjectposition = this.worldObj.rayTraceBlocks(vec31, vec3, false, true, false);

		System.out.println("1");
		vec31 = new Vec3(ea.posX, ea.posY + ea.getEyeHeight(), ea.posZ);
		vec3 = new Vec3(eb.posX, eb.posY + eb.getEyeHeight(), eb.posZ);


		if (movingobjectposition != null) {
			vec3 = new Vec3(movingobjectposition.hitVec.xCoord, movingobjectposition.hitVec.yCoord, movingobjectposition.hitVec.zCoord);

		System.out.println("hitvector="+vec3);
		System.out.println("Blocke="+this.worldObj.getBlockState(new BlockPos(vec3)  ).getBlock().getUnlocalizedName() );

		}
		System.out.println("2");



		// ### Aqui estoy modificando para obtener la segunda entidad
		Entity entity = null;

		ArrayList<Entity> entidades = new ArrayList<Entity>();
		entidades.clear();

		List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().addCoord(this.motionX, this.motionY, this.motionZ).expand(1.0D, 1.0D, 1.0D));
		double d0 = 0.0D;
		ArrayList<Double> distancias = new ArrayList<Double>();

		distancias.clear();

		int i;
		float f1;

		for (i = 0; i < list.size(); ++i) {
			Entity entity1 = (Entity) list.get(i);

			if (!excepciones(entity1)) // if false
			{
				System.out.println("exepcion = "+entity1.getName());

				//salida = false;
			}

		}




		System.out.println("3");

             		



		int distanciab = (int)distancia;

		// rotacion Horizontal en radianes
		double rotacionYaw = ea.rotationYaw;
		// rotacion Vertical en radianes
		double rotacionPitch = ea.rotationPitch;



		double eax = ea.posX;
		double eay = (ea.posY + ea.getEyeHeight());
		double eaz = ea.posZ;

		double nposX = 0;
		double nposY = 0;
		double nposZ = 0;

		BlockPos bpos = new BlockPos(nposX,nposY,nposZ);
		IBlockState ibx = Blocks.web.getDefaultState();

            //float distancia=1.0F;
            
            rotacionYaw = ((this.rotationYaw / 180.0F) * 3.1415926 ); //rotacion Horizontal  en radianes
            rotacionPitch = ((this.rotationPitch / 180.0F) * 3.1415926  ); //rotacion Vertical en radianes

            if (rotacionYaw < 0)
            {
            	rotacionYaw = (2 * 6.2831852) + rotacionYaw;
            }
           
            rotacionYaw = rotacionYaw - 1.5707963; //correccion de -90 grados
            
            if (rotacionYaw < 0)
            {
            	rotacionYaw = (2 * 6.2831852) + rotacionYaw;
            }
            
            
            //System.out.println("rotacionPitch ="+ (rotacionPitch) );
            //System.out.println("rotacionYawn  ="+ (rotacionYaw) );
            

		for (int d = 1; d < distanciab ; d ++  )
		{

            nposX = eax - (double)(   Math.cos( rotacionYaw ) ) * (Math.cos(rotacionPitch) * d ) ;
            nposY = eay - ( Math.sin(rotacionPitch) * d )  ;//0.10000000149011612D +
            nposZ = eaz - (double)(   Math.sin( rotacionYaw ) ) * (Math.cos(rotacionPitch) * d ) ;

//System.out.println("  "+);
//System.out.println("\n\n");
//System.out.println(" d="+d);
//System.out.println("posX = "+nposX);
//System.out.println("posY = "+nposY);
//System.out.println("posZ = "+nposZ);

bpos = new BlockPos(nposX,nposY,nposZ);
//this.worldObj.setBlockState(bpos, ibx);


		}




		//######


}

	System.out.println("4");

return salida;

}

// #########################################################################################################################3
boolean excepciones(Entity ent) {
	int entId = ent.getEntityId();
	//// System.out.println("\n\n\n");
	//// System.out.println("mundo="+this.worldObj.isRemote);
	//// System.out.println("entidad="+entId);
	//// System.out.println("thisId="+thisId);
	//// System.out.println("shId="+shootingEntityId);

	if (entId == shootingEntityId) {
		return false;
	}

	int ignLength = ignorar.length;

	for (int ig = 0; ig < ignLength; ig++) {

		//// System.out.println(" array["+ig+"]ignorar="+ignorar[ig]);
		if (entId == ignorar[ig]) {
			return false;
		}
	}

	return true;
}

// #################################################################################################################
@Override
/**
 * Called to update the entity's position/logic.
 */
public void onUpdate() {
	super.onUpdate();

	if (onUpdateTick < 2) {

		shootingEntityId = this.getEntityId();

		//readEntityFromNBT(this.getEntityData());

	}

	this.headRotationCourseOld = this.headRotationCourse;

	if (this.func_70922_bv()) {
		this.headRotationCourse += (1.0F - this.headRotationCourse) * 0.4F;
	} else {
		this.headRotationCourse += (0.0F - this.headRotationCourse) * 0.4F;
	}

	// actualizar variables del render atravez del dataWacher
	// variables del render
	// a aimedBow boolean
	// s isSneak boolean
	// r heldItemRight int 0~4
	// l heldItemLeft int 0~1

	int lrsa = 0;

	if (!this.worldObj.isRemote) {

		if (aimedBow) {
			lrsa = lrsa + 1;
		}
		if (isSneak) {
			lrsa = lrsa + 10;
		}
		if (heldItemRight > 0) {
			lrsa = lrsa + (heldItemRight * 100);
		}
		if (heldItemLeft > 0) {
			lrsa = lrsa + (heldItemLeft * 100);
		}

		this.dataWatcher.updateObject(21, lrsa);
	} else {
		lrsa = this.dataWatcher.getWatchableObjectInt(21);

		aimedBow = false;
		if ((lrsa % 10) > 0) {
			aimedBow = true;
		}

		isSneak = false;
		if (((lrsa % 100) / 10) > 0) {
			isSneak = true;
		}

		heldItemRight = ((lrsa % 1000) / 100);
		heldItemLeft = ((lrsa % 10000) / 1000);

	}

	// ##################################
	// corregir altura del disparo
	if (targetEntity != null) {
		shootingEntity = this;

		aimedBowTick = 10;

		/*
		 * System.out.println("\n\n\n");
		 * 
		 * System.out.println("#sh="+shootingEntity.getName() );
		 * System.out.println("#tg="+targetEntity.getName() );
		 * 
		 * System.out.println("tg height="+targetEntity.height);
		 * System.out.println("tg eye="+targetEntity.getEyeHeight());
		 */

		double x = shootingEntity.posX;
		double y = shootingEntity.posY;
		double z = shootingEntity.posZ;

		float yaw = shootingEntity.getRotationYawHead(); // shootingEntity.rotationYaw;
		float pitch = shootingEntity.rotationPitch;

		// System.out.println("pitch1 = "+pitch);

		// shootingEntity.height;

		this.posY = shootingEntity.posY + (double) shootingEntity.getEyeHeight() - 0.10000000149011612D;
		double d0 = targetEntity.posX - shootingEntity.posX;
		double d1 = (targetEntity.posY + targetEntity.getEyeHeight()) - (shootingEntity.posY); /// 3.0F
																								/// targetEntity.getEntityBoundingBox().minY
																								/// +
																								/// (double)
																								/// //+
																								/// shootingEntity.getEyeHeight()
		double d2 = targetEntity.posZ - shootingEntity.posZ;
		double d3 = (double) MathHelper.sqrt_double(d0 * d0 + d2 * d2);

		if (d3 >= 1.0E-7D) {
			float f2 = (float) (Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
			// float f3 = (float) (-(Math.atan2(d1, d3) * 180.0D /
			// Math.PI)); //-
			float f3 = (float) ((Math.tan(d1 / d3)) * 180.0D / Math.PI); // -

			float f4 = (float) ((Math.atan(d1 / d3) * -1) * 180.0D / Math.PI); // -
																				// *
																				// 180.0D
																				// /
																				// Math.PI1

			/*
			 * System.out.println("altura = "+d1); System.out.println(
			 * "distancia = "+d3);
			 * 
			 * System.out.println("f3 = "+f3); System.out.println("f4 = "
			 * +f4);
			 */
			pitch = f4; // pitch -
			// System.out.println("pitch2 = "+pitch);

		}

		shootingEntity.setPositionAndRotation(x, y, z, yaw, pitch);

		// terminar una vez este muerto el objetivo
		if (!targetEntity.isEntityAlive()) {
			targetEntity = null;
		}

	}
	// ##################################

	if (this.isWet()) {
		this.isWet = true;
		this.isShaking = false;
		this.timeWolfIsShaking = 0.0F;
		this.prevTimeWolfIsShaking = 0.0F;
	} else if ((this.isWet || this.isShaking) && this.isShaking) {
		if (this.timeWolfIsShaking == 0.0F) {
			this.playSound("mob.wolf.shake", this.getSoundVolume(), (this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F);
		}

		this.prevTimeWolfIsShaking = this.timeWolfIsShaking;
		this.timeWolfIsShaking += 0.05F;

		if (this.prevTimeWolfIsShaking >= 2.0F) {
			this.isWet = false;
			this.isShaking = false;
			this.prevTimeWolfIsShaking = 0.0F;
			this.timeWolfIsShaking = 0.0F;
		}

		if (this.timeWolfIsShaking > 0.4F) {
			float f = (float) this.getEntityBoundingBox().minY;
			int i = (int) (MathHelper.sin((this.timeWolfIsShaking - 0.4F) * (float) Math.PI) * 7.0F);

			for (int j = 0; j < i; ++j) {
				float f1 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
				float f2 = (this.rand.nextFloat() * 2.0F - 1.0F) * this.width * 0.5F;
				this.worldObj.spawnParticle(EnumParticleTypes.WATER_SPLASH, this.posX + (double) f1, (double) (f + 0.8F), this.posZ + (double) f2, this.motionX, this.motionY, this.motionZ, new int[0]);
			}
		}
	}

	// ### AimedBow ticks

	if (!this.worldObj.isRemote) {
		if (aimedBowTick > 0 | aimedBow) {
			aimedBow = true;

			if (aimedBowTick < 2) {
				aimedBow = false;
			}
			aimedBowTick--;
		}
	}

	onUpdateTick++;

}

// #################################################################################################################

/**
 * True if the wolf is wet
 */
@SideOnly(Side.CLIENT)
public boolean isWolfWet() {
	return this.isWet;
}

// #################################################################################################################
/**
 * Used when calculating the amount of shading to apply while the wolf is
 * wet.
 */
@SideOnly(Side.CLIENT)
public float getShadingWhileWet(float p_70915_1_) {
	return 0.75F + (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70915_1_) / 2.0F * 0.25F;
}

// #################################################################################################################

@SideOnly(Side.CLIENT)
public float getShakeAngle(float p_70923_1_, float p_70923_2_) {
	float f2 = (this.prevTimeWolfIsShaking + (this.timeWolfIsShaking - this.prevTimeWolfIsShaking) * p_70923_1_ + p_70923_2_) / 1.8F;

	if (f2 < 0.0F) {
		f2 = 0.0F;
	} else if (f2 > 1.0F) {
		f2 = 1.0F;
	}

	return MathHelper.sin(f2 * (float) Math.PI) * MathHelper.sin(f2 * (float) Math.PI * 11.0F) * 0.15F * (float) Math.PI;
}

// #################################################################################################################
@SideOnly(Side.CLIENT)
public float getInterestedAngle(float p_70917_1_) {
	return (this.headRotationCourseOld + (this.headRotationCourse - this.headRotationCourseOld) * p_70917_1_) * 0.15F * (float) Math.PI;
}

// #################################################################################################################
@Override
public float getEyeHeight() {
	return 1.74F;
}

// #################################################################################################################
@Override
/**
 * The speed it takes to move the entityliving's rotationPitch through the
 * faceEntity method. This is only currently use in wolves.
 */
public int getVerticalFaceSpeed() {
	return this.isSitting() ? 20 : super.getVerticalFaceSpeed();
}

// #################################################################################################################
@Override
/**
 * Called when the entity is attacked.
 */
public boolean attackEntityFrom(DamageSource source, float amount) {
	if (this.isEntityInvulnerable(source)) {
		return false;
	} else {
		Entity entity = source.getEntity();
		this.aiSit.setSitting(false);

		if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) {
			amount = (amount + 1.0F) / 2.0F;
		}

		return super.attackEntityFrom(source, amount);
	}
}

// #################################################################################################################
// se ejecuta cuando hace ataque fisico normal auna criatura
@Override
public boolean attackEntityAsMob(Entity p_70652_1_) {
	boolean flag = p_70652_1_.attackEntityFrom(DamageSource.causeMobDamage(this), (float) ((int) this.getEntityAttribute(SharedMonsterAttributes.attackDamage).getAttributeValue()));

	if (flag) {
		this.func_174815_a(this, p_70652_1_);
	}

	p_70652_1_.setFire(10);

	return flag;
}

// #################################################################################################################
@Override
public void setTamed(boolean tamed) {
	super.setTamed(tamed);

	if (tamed) {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(20.0D);
	} else {
		this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(8.0D);
	}

	this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(4.0D);
}

// #################################################################################################################
@Override
/**
 * Called when a player interacts with a mob. e.g. gets milk from a cow,
 * gets into the saddle on a pig.
 */
public boolean interact(EntityPlayer player) {
	ItemStack itemstack = player.inventory.getCurrentItem();

	if (this.isTamed()) {
		if (itemstack != null) {
			if (itemstack.getItem() instanceof ItemFood) {
				ItemFood itemfood = (ItemFood) itemstack.getItem();

				if (itemfood.isWolfsFavoriteMeat() && this.dataWatcher.getWatchableObjectFloat(18) < 20.0F) {
					if (!player.capabilities.isCreativeMode) {
						--itemstack.stackSize;
					}

					this.heal((float) itemfood.getHealAmount(itemstack));

					if (itemstack.stackSize <= 0) {
						player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null);
					}

					return true;
				}
			} else if (itemstack.getItem() == Items.dye) {
				EnumDyeColor enumdyecolor = EnumDyeColor.byDyeDamage(itemstack.getMetadata());

				if (enumdyecolor != this.getCollarColor()) {
					this.setCollarColor(enumdyecolor);

					if (!player.capabilities.isCreativeMode && --itemstack.stackSize <= 0) {
						player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null);
					}

					return true;
				}
			}
		}

		if (this.isOwner(player) && !this.worldObj.isRemote && !this.isBreedingItem(itemstack)) {


			if (player instanceof EntityPlayer)
			{
				chat.chatda(player,  this.getName()+" is Waiting "+ !this.isSitting() );
			}
			this.aiSit.setSitting(!this.isSitting());

			this.isJumping = false;
			this.navigator.clearPathEntity();
			this.setAttackTarget((EntityLivingBase) null);
		}
	} else if (itemstack != null && itemstack.getItem() == Items.bone && !this.isAngry()) {
		if (!player.capabilities.isCreativeMode) {
			--itemstack.stackSize;
		}

		if (itemstack.stackSize <= 0) {
			player.inventory.setInventorySlotContents(player.inventory.currentItem, (ItemStack) null);
		}

		if (!this.worldObj.isRemote) {
			if (this.rand.nextInt(3) == 0) {
				this.setTamed(true);

				//UUID uuid = player.getUniqueID();
				String Suuid = player.getUniqueID().toString();


				NBTTagCompound targetNBT = this.getEntityData();
				targetNBT.setString("OwnerUUID", Suuid); //

				NBTTagCompound playerNBT = player.getEntityData();
				playerNBT.setString("OwnerUUID", Suuid); //


				this.navigator.clearPathEntity();
				this.setAttackTarget((EntityLivingBase) null);
				this.aiSit.setSitting(true);
				this.setHealth(20.0F);
				this.setOwnerId(player.getUniqueID().toString());
				this.playTameEffect(true);
				this.worldObj.setEntityState(this, (byte) 7);
			} else {
				this.playTameEffect(false);
				this.worldObj.setEntityState(this, (byte) 6);
			}
		}

		return true;
	}

	return super.interact(player);
}

// #################################################################################################################
@Override
@SideOnly(Side.CLIENT)
public void handleHealthUpdate(byte p_70103_1_) {
	if (p_70103_1_ ==  {
		this.isShaking = true;
		this.timeWolfIsShaking = 0.0F;
		this.prevTimeWolfIsShaking = 0.0F;
	} else {
		super.handleHealthUpdate(p_70103_1_);
	}
}

// #################################################################################################################
@SideOnly(Side.CLIENT)
public float getTailRotation() {
	return this.isAngry() ? 1.5393804F : (this.isTamed() ? (0.55F - (20.0F - this.dataWatcher.getWatchableObjectFloat(18)) * 0.02F) * (float) Math.PI : ((float) Math.PI / 5F));
}

// #################################################################################################################
@Override
/**
 * Checks if the parameter is an item which this animal can be fed to breed
 * it (wheat, carrots or seeds depending on the animal type)
 */
public boolean isBreedingItem(ItemStack stack) {
	return stack == null ? false : (!(stack.getItem() instanceof ItemFood) ? false : ((ItemFood) stack.getItem()).isWolfsFavoriteMeat());
}

// #################################################################################################################
@Override
/**
 * Will return how many at most can spawn in a chunk at once.
 */
public int getMaxSpawnedInChunk() {
	return 8;
}

// #################################################################################################################
/**
 * Determines whether this wolf is angry or not.
 */
public boolean isAngry() {
	return (this.dataWatcher.getWatchableObjectByte(16) & 2) != 0;
}

// #################################################################################################################
/**
 * Sets whether this wolf is angry or not.
 */
public void setAngry(boolean angry) {
	byte b0 = this.dataWatcher.getWatchableObjectByte(16);

	if (angry) {
		this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 | 2)));
	} else {
		this.dataWatcher.updateObject(16, Byte.valueOf((byte) (b0 & -3)));
	}
}

// #################################################################################################################

public EnumDyeColor getCollarColor() {
	return EnumDyeColor.byDyeDamage(this.dataWatcher.getWatchableObjectByte(20) & 15);
}

// #################################################################################################################
public void setCollarColor(EnumDyeColor collarcolor) {
	this.dataWatcher.updateObject(20, Byte.valueOf((byte) (collarcolor.getDyeDamage() & 15)));
}

// #################################################################################################################
@Override
public mobMercenario createChild(EntityAgeable ageable) {
	mobMercenario mobMercenario = new mobMercenario(this.worldObj);
	String s = this.getOwnerId();

	if (s != null && s.trim().length() > 0) {
		mobMercenario.setOwnerId(s);
		mobMercenario.setTamed(true);
	}

	return mobMercenario;
}

// #################################################################################################################

public void func_70918_i(boolean p_70918_1_) {
	if (p_70918_1_) {
		this.dataWatcher.updateObject(19, Byte.valueOf((byte) 1));
	} else {
		this.dataWatcher.updateObject(19, Byte.valueOf((byte) 0));
	}
}

// #################################################################################################################
@Override
/**
 * Returns true if the mob is currently able to mate with the specified mob.
 */
public boolean canMateWith(EntityAnimal otherAnimal) {
	if (otherAnimal == this) {
		return false;
	} else if (!this.isTamed()) {
		return false;
	} else if (!(otherAnimal instanceof mobMercenario)) {
		return false;
	} else {
		mobMercenario mobMercenario = (mobMercenario) otherAnimal;
		return !mobMercenario.isTamed() ? false : (mobMercenario.isSitting() ? false : this.isInLove() && mobMercenario.isInLove());
	}
}

// #################################################################################################################
public boolean func_70922_bv() {
	return this.dataWatcher.getWatchableObjectByte(19) == 1;
}

// #################################################################################################################
@Override
/**
 * Determines if an entity can be despawned, used on idle far away entities
 */
protected boolean canDespawn() {
	return !this.isTamed() && this.ticksExisted > 2400;
}

// #################################################################################################################
@Override
public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_) {
	if (!(p_142018_1_ instanceof EntityCreeper) && !(p_142018_1_ instanceof EntityGhast)) {
		if (p_142018_1_ instanceof mobMercenario) {
			mobMercenario mobMercenario = (mobMercenario) p_142018_1_;

			if (mobMercenario.isTamed() && mobMercenario.getOwnerEntity() == p_142018_2_) {
				return false;
			}
		}

		return p_142018_1_ instanceof EntityPlayer && p_142018_2_ instanceof EntityPlayer && !((EntityPlayer) p_142018_2_).canAttackPlayer((EntityPlayer) p_142018_1_) ? false : !(p_142018_1_ instanceof EntityHorse) || !((EntityHorse) p_142018_1_).isTame();
	} else {
		return false;
	}
}

// #################################################################################################################
@Override
public boolean allowLeashing() {
	return !this.isAngry() && super.allowLeashing();
}

// #################################################################################################################
public boolean getAimedBow() {
	return aimedBow;
}

// #################################################################################################################
public void setAimedBow(boolean a) {
	aimedBow = a;
}

// #################################################################################################################
public boolean getisSneak() {
	return isSneak;
}

// #################################################################################################################
public void setisSneak(boolean s) {
	isSneak = s;
}

// #################################################################################################################
public int getHeldItemRight() {
	return heldItemRight;
}

// #################################################################################################################
public void setHeldItemRight(int r) {
	heldItemRight = r;
}

// #################################################################################################################
public int getHeldItemLeft() {
	return heldItemLeft;
}

// #################################################################################################################
public void setHeldItemLeft(int r) {
	heldItemLeft = r;
}

}

 

 

 

thanks for reading

 

Posted

To address one of your questions, you want zombies to avoid your mob. This is easily done using events:

@SubscribeEvent
public void entityConstructing(EntityConstructing evt) {
   if (evt.entity instanceof EntityZombie) {
      EntityZombie zombie = (EntityZombie) evt.entity;
      zombie.tasks.add(new EntityAIAvoidEntity(zombie, new Predicate<Entity>() {
         @Override
         public boolean apply(Entity entity) {
            return entity instanceof mobMercenario && ((mobMercenario) entity).isTargetingZombies();
         }
      }, 6, 1, 1.2);
   }
}

 

Hope it helps ;)

I don't know much about modelling, so I can't help you much with that I'm afraid

catch(Exception e)

{

 

}

Yay, Pokémon exception handling, gotta catch 'em all (and then do nothing with 'em).

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.