本文整理汇总了Java中net.minecraft.entity.ai.EntityAITarget类的典型用法代码示例。如果您正苦于以下问题:Java EntityAITarget类的具体用法?Java EntityAITarget怎么用?Java EntityAITarget使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
EntityAITarget类属于net.minecraft.entity.ai包,在下文中一共展示了EntityAITarget类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: EntityAIFindEntityNearestSkins
import net.minecraft.entity.ai.EntityAITarget; //导入依赖的package包/类
public EntityAIFindEntityNearestSkins(EntityLiving entityLivingIn) {
this.taskOwner = entityLivingIn;
if (entityLivingIn instanceof EntityCreature) {
LOGGER.warn("Use NearestAttackableTargetGoal.class for PathfinderMob mobs!");
}
this.predicate = p_apply_1_ -> {
if (!(p_apply_1_ instanceof EntityArmyMember)) {
return false;
} else if (p_apply_1_.getIsInvulnerable()) {
return false;
} else {
double maxTargetRange = EntityAIFindEntityNearestSkins.this.maxTargetRange();
return !((double) p_apply_1_.getDistanceToEntity(EntityAIFindEntityNearestSkins.this.taskOwner) > maxTargetRange) && (EntityAITarget.isSuitableTarget(EntityAIFindEntityNearestSkins.this.taskOwner, (EntityLivingBase) p_apply_1_, false, true) && CAN_ATTACK_ARMY_MEMBER.test((EntityArmyMember) p_apply_1_));
}
};
this.sorter = new EntityAINearestAttackableTarget.Sorter(entityLivingIn);
}
示例2: isEntityValidToAttack
import net.minecraft.entity.ai.EntityAITarget; //导入依赖的package包/类
public boolean isEntityValidToAttack(EntityMinionWarrior minion, EntityLivingBase entity)
{
if(entity == minion || entity == minion.getRidingEntity() || !EntityAITarget.isSuitableTarget(minion, entity, false, false) || entity.getClass() == EntityCreeper.class) return false;
if (entity instanceof EntityMob &&
(getTargetBehavior() == EnumCombatBehaviors.TARGET_HOSTILE_MOBS ||
getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS))
{
return true;
}
else if (entity instanceof EntityAnimal &&
(getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_MOBS ||
getTargetBehavior() == EnumCombatBehaviors.TARGET_PASSIVE_OR_HOSTILE_MOBS))
{
return true;
}
else
{
return false;
}
}
示例3: EntityAIFindOtherSlimeNearest
import net.minecraft.entity.ai.EntityAITarget; //导入依赖的package包/类
public EntityAIFindOtherSlimeNearest(final EntitySlime mobIn)
{
super(mobIn, EntitySlime.class);
this.slime = mobIn;
Predicate<EntityLivingBase> predicate = entity -> {
double range = EntityAIFindOtherSlimeNearest.this.getFollowRange();
return entity != null
&& entity != mobIn
&& entity.getClass() == mobIn.getClass()
&& entity.ticksExisted > AGE_LIMIT
&& !entity.isInvisible()
&& entity.getDistance(mobIn) <= range
&& ((EntitySlime) entity).getSlimeSize() == mobIn.getSlimeSize()
&& EntityAITarget.isSuitableTarget(mobIn, entity, false, true);
};
try
{
predicateField.set(this, predicate);
}
catch (IllegalAccessException e)
{
throw new ReportedException(new CrashReport("Could not set private field '" + predicateField.getName() + "'", e));
}
}
示例4: updateTask
import net.minecraft.entity.ai.EntityAITarget; //导入依赖的package包/类
@Override
public void updateTask() {
EntityLivingBase target=this.host.getAttackTarget();
World world=this.host.world;
this.host.getLookHelper().setLookPositionWithEntity(target, 30F, 90F);
if(attackDuration<20){
this.host.getNavigator().tryMoveToEntityLiving(target, 1f);
}
if(--this.attackDuration<=0){
this.host.swingArm(EnumHand.MAIN_HAND);
if(this.attacksMade>0&&this.attacksMade%13==0){
this.host.setBombSpell(true);
this.host.bombDuration=200;
BlockPos pos = this.host.world.getTopSolidOrLiquidBlock(this.host.getPosition());
this.host.topBlock=pos.getY()+7+this.host.rand.nextInt(3);
this.attackDuration=200;
}
else if(this.attacksMade%2==0){
this.attackDuration=20-this.host.level/4;
if(this.host.getDistanceSqToEntity(target)<6){
if(this.host.attackEntityAsMob(target)){
target.knockBack(this.host, (float)1.5f, (double)MathHelper.sin(this.host.rotationYaw * 0.017453292F), (double)(-MathHelper.cos(this.host.rotationYaw * 0.017453292F)));
}
}
else{
((ItemProjectileWeapon) this.host.getHeldItemMainhand().getItem()).shoot(
this.host.getHeldItemMainhand(), this.host, world, 0, EnumHand.MAIN_HAND);
}
}
else{
this.attackDuration=(int) (55/(0.92+this.host.level*0.08f));
this.host.getNavigator().clearPathEntity();
this.host.playSound(TF2Sounds.MOB_MERASMUS_SPELL, 2F, 1F);
boolean attacked=false;
for(EntityLivingBase living:world.getEntitiesWithinAABB(EntityLivingBase.class, this.host.getEntityBoundingBox().grow(12, 5, 12), new Predicate<EntityLivingBase>(){
@Override
public boolean apply(EntityLivingBase input) {
// TODO Auto-generated method stub
return input.getDistanceSqToEntity(host)<144&&!TF2Util.isOnSameTeam(host, input)&&EntityAITarget.isSuitableTarget(host, input, false, false);
}
})){
living.attackEntityFrom(new EntityDamageSource("magicm",this.host).setMagicDamage().setDifficultyScaled(), 6);
living.addVelocity(0, 1.25, 0);
living.fallDistance=-10;
attacked=true;
}
if(!attacked)
this.host.teleportCooldown-=20;
}
this.attacksMade++;
}
}
示例5: isEntityValidToAttack
import net.minecraft.entity.ai.EntityAITarget; //导入依赖的package包/类
public boolean isEntityValidToAttack(EntityBombomb bombomb, EntityLivingBase entity)
{
if(entity == bombomb || entity == bombomb.getRidingEntity() || !EntityAITarget.isSuitableTarget(bombomb, entity, false, false) || entity.getClass() == EntityCreeper.class) return false;
return true;
}