当前位置: 首页>>代码示例>>Java>>正文


Java EntityCreature.setAttackTarget方法代码示例

本文整理汇总了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);
				;
			}

		}
	}
}
 
开发者ID:rafradek,项目名称:Mods,代码行数:35,代码来源:TF2Util.java

示例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);
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:14,代码来源:UpdateHandler.java

示例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);
}
 
开发者ID:ToroCraft,项目名称:NemesisSystem,代码行数:37,代码来源:SpawnHandler.java

示例4: setEntityAttackTarget

import net.minecraft.entity.EntityCreature; //导入方法依赖的package包/类
protected void setEntityAttackTarget(EntityCreature creatureIn, EntityLivingBase entityLivingBaseIn)
{
    creatureIn.setAttackTarget(entityLivingBaseIn);
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:5,代码来源:EntityAIHurtByTarget.java


注:本文中的net.minecraft.entity.EntityCreature.setAttackTarget方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。