Posted June 7, 201510 yr I want to make the mob attack other mobs but not its self. so I gave it the task to attack all mobs. problem is it's a mob so how do I make it not attack itself if there are multiple of them? package com.OlympiansMod.entity; import net.minecraft.entity.EntityCreature; import net.minecraft.entity.EntityLiving; import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.EntityAIAttackOnCollide; import net.minecraft.entity.ai.EntityAIDefendVillage; import net.minecraft.entity.ai.EntityAIHurtByTarget; import net.minecraft.entity.ai.EntityAILookAtVillager; import net.minecraft.entity.ai.EntityAILookIdle; import net.minecraft.entity.ai.EntityAIMoveThroughVillage; import net.minecraft.entity.ai.EntityAIMoveTowardsRestriction; import net.minecraft.entity.ai.EntityAIMoveTowardsTarget; import net.minecraft.entity.ai.EntityAINearestAttackableTarget; import net.minecraft.entity.ai.EntityAIWander; import net.minecraft.entity.ai.EntityAIWatchClosest; import net.minecraft.entity.monster.EntityGolem; import net.minecraft.entity.monster.EntityMob; import net.minecraft.entity.monster.IMob; import net.minecraft.entity.passive.EntityAnimal; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.world.World; public class EntityUndead extends EntityMob{ public EntityUndead(World world) { super(world); this.setSize(1.4F, 2.9F); this.getNavigator().setAvoidsWater(true); this.tasks.addTask(1, new EntityAIAttackOnCollide(this, 1.0D, true)); this.tasks.addTask(2, new EntityAIMoveTowardsTarget(this, 0.9D, 32.0F)); this.tasks.addTask(4, new EntityAIMoveTowardsRestriction(this, 1.0D)); this.tasks.addTask(6, new EntityAIWander(this, 0.6D)); this.tasks.addTask(7, new EntityAIWatchClosest(this, EntityPlayer.class, 6.0F)); this.tasks.addTask(8, new EntityAILookIdle(this)); this.targetTasks.addTask(2, new EntityAIHurtByTarget(this, false)); this.targetTasks.addTask(3, new EntityAINearestAttackableTarget(this, EntityLiving.class, 0, false, true, IMob.mobSelector)); } protected boolean isAIEnabled(){ return true; } protected void applyEntityAttributes(){ super.applyEntityAttributes(); this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue(100.0f); this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).setBaseValue(0.25D); this.getEntityAttribute(SharedMonsterAttributes.attackDamage).setBaseValue(10); } } what task to I give it? Im serious don't look at it!!
June 7, 201510 yr Author dude that method will make it so that it will kill itself in combat, meaning if I spawn multiple it will kill itself Im serious don't look at it!!
June 7, 201510 yr Author plus I want my mob to attack all mobs other than itself, im looking for a EntityAi for that or something, I already have an AI to attack all mobs, now I need something to override it and tell it to not attack its self Im serious don't look at it!!
June 7, 201510 yr Create your own EntityAIAttackWhatever class, and override shouldExecute() and write your own condition. Like public boolean shouldExecute() { EntityLivingBase entitylivingbase = this.attacker.getAttackTarget(); if (entitylivingbase == null) { return false; } else if (!entitylivingbase.isEntityAlive()) { return false; } else if (entitylivingbase instanceof YourMobNameHere) { return false; } //All the other checks, etc. } else { return true; } } }
June 7, 201510 yr Author Like This? public boolean shouldExecute() { EntityLivingBase entitylivingbase = ((EntityLiving) this.attacker).getAttackTarget(); if (entitylivingbase == null) { return false; } else if (!entitylivingbase.isEntityAlive()) { return false; } else if (entitylivingbase instanceof EntityUndead) { return false; } //All the other checks, etc. return hasAttacked; Im serious don't look at it!!
June 7, 201510 yr Author because the Entitys are still attacking eachother Im serious don't look at it!!
June 7, 201510 yr Author public boolean shouldExecute() { EntityLivingBase entitylivingbase = ((EntityLiving) this.attacker).getAttackTarget(); if (entitylivingbase == null) { return false; } else if (!entitylivingbase.isEntityAlive()) { return false; } else if (entitylivingbase instanceof EntityUndead) { return false; } else{ return true; } } } I wrote this method, the only thing different from yours is that I had to define the attacker as entity living it doesn't work. Im serious don't look at it!!
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.