Posted January 29, 201411 yr Hi guys I am in need of some help . I final got my mob to attack other npcs and it will attack most mobs but for some reason it will not attack creepers with this this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityZombie.class, 5, false)); I don’t know what I am doing wrong . Ok so secondly I want to turn down how much damage it deal because it currently kills most things including players in one hit and I need to make it less OP . I don’t know how to do this as most of the code is a mix and match from other minecraft mobs but I think its this ?? the rest of the code is below and in-case your wondering the reason I added a separate yAINearestAttackableTarget for each is because the npc is a Entitymob and so they attack each other please help me resolve this thanks package mcmkingdoms.mod.guard; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; import net.minecraft.client.model.ModelBase; import net.minecraft.client.renderer.entity.RenderLiving; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; 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.monster.EntityCaveSpider; import net.minecraft.entity.monster.EntityCreeper; import net.minecraft.entity.monster.EntityGiantZombie; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.EntityPigZombie; import net.minecraft.entity.monster.EntitySkeleton; import net.minecraft.entity.monster.EntitySpider; import net.minecraft.entity.monster.EntityWitch; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.passive.EntityChicken; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.projectile.EntityArrow; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; import net.minecraft.util.DamageSource; import net.minecraft.util.ResourceLocation; import net.minecraft.world.World; public class Guard extends EntityMob { private Object angerlevel; private Object Object; public Guard(World par1World) { super(par1World); this.setSize(0.9F, 1.3F); this.tasks.addTask(0, new EntityAISwimming(this)); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, EntityMob.class, 1.5D, false)); this.tasks.addTask(2, new EntityAILookIdle(this)); this.targetTasks.addTask(3, new EntityAIHurtByTarget(this, true)); this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false)); this.tasks.addTask(3, new EntityAILookIdle(this)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityCreeper.class, 5, false)); this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityZombie.class, 5, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPigZombie.class, 5, false)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityCaveSpider.class, 5, false)); this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntitySpider.class, 5, false)); this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this, EntityWitch.class, 5, false)); this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, 5, false)); this.targetTasks.addTask(7, new EntityAINearestAttackableTarget(this, EntityGiantZombie.class, 5, false)); } /** * Returns true if the newer Entity AI code should be run */ public boolean isAIEnabled() { return true; } protected void applyEntityAttributes() { super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setAttribute(100.0D); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setAttribute(0.40000000298023224D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setAttribute(2.0D); } public boolean attackEntityAsMob(Entity par1Entity) { return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), 50); } public int getTotalArmorValue() { int i = super.getTotalArmorValue() + 2; if (i > 20) { i = 20; } return i; } public boolean attackEntityFrom(DamageSource par1DamageSource, float par2) { if (this.isEntityInvulnerable()) { return false; } else { Entity entity = par1DamageSource.getEntity(); if (entity != null && !(entity instanceof EntityPlayer) && !(entity instanceof EntityArrow)) { par2 = (par2 + 4.0F) / 2.0F; } return super.attackEntityFrom(par1DamageSource, par2); } } { final int angerlevel ; angerlevel = 0; { // if public boolean } } /** * Returns the sound this mob makes while it's alive. */ protected String getLivingSound() { return "mob.cow.say"; } /** * Returns the sound this mob makes when it is hurt. */ protected String getHurtSound() { return "mob.cow.hurt"; } /** * Returns the sound this mob makes on death. */ protected String getDeathSound() { return "mob.cow.hurt"; } /** * Plays step sound at given x, y, z for the entity */ protected void playStepSound(int par1, int par2, int par3, int par4) { this.playSound("mob.cow.step", 0.15F, 1.0F); } /** * Returns the volume for the sounds this mob makes. */ protected float getSoundVolume() { return 0.4F; } /** * Returns the item ID for the item the mob drops on death. */ protected int getDropItemId() { return Item.legsIron.itemID; } // sets Armour/Weapons the mob is using public void setCurrentItemOrArmor(int par1, ItemStack ItemStack) { super.setCurrentItemOrArmor(par1,ItemStack); } { this.setCurrentItemOrArmor(0, new ItemStack(Item.swordIron)); this.setCurrentItemOrArmor(1, new ItemStack(Item.helmetIron)); this.setCurrentItemOrArmor(2, new ItemStack(Item.bootsIron)); this.setCurrentItemOrArmor(3, new ItemStack(Item.plateIron)); this.setCurrentItemOrArmor(4, new ItemStack(Item.legsIron)); } }
January 29, 201411 yr Hi Perhaps because you added two TargetTasks with priority 1? Re damage- just a random guess, make the 50 smaller? return par1Entity.attackEntityFrom(DamageSource.causeMobDamage(this), 50); I'm not sure why you haven't tried this already? -TGG
February 2, 201411 yr Author ok TGG the thing about damaged worked but now after changing the target priority to this this.targetTasks.addTask(1, new EntityAINearestAttackableTarget(this, EntityCreeper.class, 1, false)); this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityZombie.class, 2, false)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityPigZombie.class, 3, false)); this.targetTasks.addTask(4, new EntityAINearestAttackableTarget(this, EntityCaveSpider.class, 4, false)); this.targetTasks.addTask(5, new EntityAINearestAttackableTarget(this, EntitySpider.class, 5, false)); this.targetTasks.addTask(6, new EntityAINearestAttackableTarget(this, EntityWitch.class, 6, false)); this.targetTasks.addTask(7, new EntityAINearestAttackableTarget(this, EntitySkeleton.class, 7, false)); this.targetTasks.addTask(8, new EntityAINearestAttackableTarget(this, EntityGiantZombie.class, 8, false)); it still wont attack creepers as i said before it will attack everything else but thanks so far
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.