本文整理汇总了Java中net.minecraft.entity.EntityCreature.setAttackTarget方法的典型用法代码示例。如果您正苦于以下问题:Java EntityCreature.setAttackTarget方法的具体用法?Java EntityCreature.setAttackTarget怎么用?Java EntityCreature.setAttackTarget使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityCreature
的用法示例。
在下文中一共展示了EntityCreature.setAttackTarget方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: attractMobs
import net.minecraft.entity.EntityCreature; //导入方法依赖的package包/类
public static void attractMobs(EntityLivingBase living, World world) {
if (!world.isRemote && TF2ConfigVars.shootAttract && world.getDifficulty().getDifficultyId()>1) {
int range=world.getDifficulty()==EnumDifficulty.HARD?60:38;
for (EntityCreature mob : world.getEntitiesWithinAABB(EntityCreature.class,
living.getEntityBoundingBox().grow(range, range, range), new Predicate<EntityCreature>() {
@Override
public boolean apply(EntityCreature input) {
// TODO Auto-generated method stub
return input.getAttackTarget() == null && (input instanceof IMob) && input.isNonBoss();
}
})) {
mob.getLookHelper().setLookPositionWithEntity(mob, 60, 30);
if (!TF2Util.isOnSameTeam(living, mob)) {
if (mob.getEntitySenses().canSee(living) || mob.getDistanceSqToEntity(living)<150){
mob.setAttackTarget(living);
if(mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getModifier(FOLLOW_MODIFIER)==null)
mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE)
.applyModifier(new AttributeModifier(FOLLOW_MODIFIER, "Follow Check", 65-mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).getAttributeValue(), 0));
//mob.getNavigator().tryMoveToEntityLiving(living, 1.1f);
mob.getEntityAttribute(SharedMonsterAttributes.FOLLOW_RANGE).removeModifier(FOLLOW_MODIFIER);
}
// CoroUtilPath.tryMoveToEntityLivingLongDist((EntityCreature)mob,
// living, 1.1D);
;
}
}
}
}
示例2: flee
import net.minecraft.entity.EntityCreature; //导入方法依赖的package包/类
private void flee(EntityCreature bodyGuard) {
bodyGuard.removeTag(NemesisSystem.TAG_BODY_GUARD);
bodyGuard.setAttackTarget(null);
dropItemsInHands(bodyGuard);
BehaviorApi.setFollowSpeed(bodyGuard, 2);
int distance = 1000;
int degrees = bodyGuard.getRNG().nextInt(360);
int x = distance * (int) Math.round(Math.cos(Math.toRadians(degrees)));
int z = distance * (int) Math.round(Math.sin(Math.toRadians(degrees)));
BlockPos from = bodyGuard.getPosition();
BlockPos to = new BlockPos(from.getX() + x, from.getY(), from.getZ() + z);
bodyGuard.setHomePosAndDistance(to, 50);
}
示例3: spawnNemesis
import net.minecraft.entity.EntityCreature; //导入方法依赖的package包/类
public static void spawnNemesis(World world, BlockPos pos, NemesisEntry nemesis) {
if (nemesis.isDead()) {
return;
}
if (nemesis.isSpawned()) {
return;
}
String mobType = overrideMobType(nemesis.getMob());
EntityCreature nemesisEntity = SpawnApi.getEntityFromString(world, mobType);
if (nemesisEntity == null) {
return;
}
nemesisEntity.setAttackTarget(nemesis.getTargetPlayer());
nemesisEntity.addTag(NemesisSystem.TAG_SPAWNING);
if (nemesisEntity instanceof INemesisEntity) {
((INemesisEntity) nemesisEntity).setNemesis(nemesis);
}
EntityDecorator.decorate(nemesisEntity, nemesis);
SpawnApi.spawnEntityCreature(world, nemesisEntity, pos, 1);
spawnBodyGuard(nemesisEntity, nemesis);
nemesisAnnounceEffects(nemesisEntity);
nemesis.setSpawned(nemesisEntity.getEntityId());
nemesis.setLastSpawned(world.getTotalWorldTime());
nemesis.setEntityUuid(nemesisEntity.getPersistentID());
nemesis.setUnloaded(null);
NemesisRegistryProvider.get(world).update(nemesis);
sendNemesisDataToClient(nemesis);
}
示例4: setEntityAttackTarget
import net.minecraft.entity.EntityCreature; //导入方法依赖的package包/类
protected void setEntityAttackTarget(EntityCreature creatureIn, EntityLivingBase entityLivingBaseIn)
{
creatureIn.setAttackTarget(entityLivingBaseIn);
}