當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityLiving.hasCustomNameTag方法代碼示例

本文整理匯總了Java中net.minecraft.entity.EntityLiving.hasCustomNameTag方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLiving.hasCustomNameTag方法的具體用法?Java EntityLiving.hasCustomNameTag怎麽用?Java EntityLiving.hasCustomNameTag使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.EntityLiving的用法示例。


在下文中一共展示了EntityLiving.hasCustomNameTag方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: isEntityListed

import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
private static boolean isEntityListed(Entity_AA turret, Entity entity)
{
	if (entity instanceof EntityPlayer)
	{
		EntityPlayer player = (EntityPlayer) entity;
		
		if (isNameOnWhitelist(turret, player.getDisplayName())) { return true; }	// Not shooting at their friends either
		else if (isNameOnWhitelist(turret, "player")) { return true; }				// Not shooting at players in general
	}
	
	// Creature specific whitelists
	else if (entity instanceof EntityVillager && isNameOnWhitelist(turret, "villager")) { return true; }
	else if (entity instanceof EntityChicken && isNameOnWhitelist(turret, "chicken")) { return true; }
	else if (entity instanceof EntityCow && isNameOnWhitelist(turret, "cow")) { return true; }
	else if (entity instanceof EntityHorse && isNameOnWhitelist(turret, "horse")) { return true; }
	else if (entity instanceof EntityMooshroom && isNameOnWhitelist(turret, "mooshroom")) { return true; }
	else if (entity instanceof EntityOcelot && isNameOnWhitelist(turret, "ocelot")) { return true; }
	else if (entity instanceof EntityPig && isNameOnWhitelist(turret, "pig")) { return true; }
	else if (entity instanceof EntitySheep && isNameOnWhitelist(turret, "sheep")) { return true; }
	else if (entity instanceof EntitySquid && isNameOnWhitelist(turret, "squid")) { return true; }
	else if (entity instanceof EntityWolf && isNameOnWhitelist(turret, "wolf")) { return true; }
	
	// Bosses
	else if (entity instanceof EntityDragon && isNameOnWhitelist(turret, "ender dragon")) { return true; }
	else if (entity instanceof EntityDragonPart && isNameOnWhitelist(turret, "ender dragon")) { return true; }
	else if (entity instanceof EntityWither && isNameOnWhitelist(turret, "wither")) { return true; }
	
	// Hostiles
	else if (entity instanceof EntityBlaze && isNameOnWhitelist(turret, "blaze")) { return true; }
	else if (entity instanceof EntityCaveSpider && isNameOnWhitelist(turret, "cave spider")) { return true; }
	else if (entity instanceof EntityCreeper && isNameOnWhitelist(turret, "creeper")) { return true; }
	else if (entity instanceof EntityEnderman && isNameOnWhitelist(turret, "enderman")) { return true; }
	else if (entity instanceof EntityGhast && isNameOnWhitelist(turret, "ghast")) { return true; }
	else if (entity instanceof EntityGiantZombie && isNameOnWhitelist(turret, "zombie")) { return true; }
	else if (entity instanceof EntityGolem && isNameOnWhitelist(turret, "golem")) { return true; }
	else if (entity instanceof EntityIronGolem && isNameOnWhitelist(turret, "iron golem")) { return true; }
	else if (entity instanceof EntityMagmaCube && isNameOnWhitelist(turret, "magma cube")) { return true; }
	else if (entity instanceof EntityPigZombie && isNameOnWhitelist(turret, "pig zombie")) { return true; }
	else if (entity instanceof EntitySilverfish && isNameOnWhitelist(turret, "silverfish")) { return true; }
	else if (entity instanceof EntitySkeleton && isNameOnWhitelist(turret, "skeleton")) { return true; }
	else if (entity instanceof EntitySlime && isNameOnWhitelist(turret, "slime")) { return true; }
	else if (entity instanceof EntitySnowman && isNameOnWhitelist(turret, "snow golem")) { return true; }
	else if (entity instanceof EntitySpider && isNameOnWhitelist(turret, "spider")) { return true; }
	else if (entity instanceof EntityWitch && isNameOnWhitelist(turret, "witch")) { return true; }
	else if (entity instanceof EntityZombie && isNameOnWhitelist(turret, "zombie")) { return true; }
	
	if (entity instanceof EntityLiving)	// For things with custom names
	{
		EntityLiving living = (EntityLiving) entity;
		
		if (living.hasCustomNameTag())
		{
			if (isNameOnWhitelist(turret, living.getCustomNameTag())) { return true; }
		}
	}
	
	return false;	// Nope. Fire away!
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:59,代碼來源:AI_Targeting.java


注:本文中的net.minecraft.entity.EntityLiving.hasCustomNameTag方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。