當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。