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


Java EntityLiving.setCustomNameTag方法代碼示例

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


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

示例1: itemInteractionForEntity

import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target)
{
    if (!stack.hasDisplayName())
    {
        return false;
    }
    else if (target instanceof EntityLiving)
    {
        EntityLiving entityliving = (EntityLiving)target;
        entityliving.setCustomNameTag(stack.getDisplayName());
        entityliving.enablePersistence();
        --stack.stackSize;
        return true;
    }
    else
    {
        return super.itemInteractionForEntity(stack, playerIn, target);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:23,代碼來源:ItemNameTag.java

示例2: itemInteractionForEntity

import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
/**
 * Returns true if the item can be used on the given entity, e.g. shears on sheep.
 */
public boolean itemInteractionForEntity(ItemStack stack, EntityPlayer playerIn, EntityLivingBase target, EnumHand hand)
{
    if (!stack.hasDisplayName())
    {
        return false;
    }
    else if (target instanceof EntityLiving)
    {
        EntityLiving entityliving = (EntityLiving)target;
        entityliving.setCustomNameTag(stack.getDisplayName());
        entityliving.enablePersistence();
        --stack.stackSize;
        return true;
    }
    else
    {
        return super.itemInteractionForEntity(stack, playerIn, target, hand);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:23,代碼來源:ItemNameTag.java

示例3: decorate

import net.minecraft.entity.EntityLiving; //導入方法依賴的package包/類
/**
 * Convert the provided entity into the given nemesis
 *
 * @param entity the entity to be converted into a nemesis
 * @param nemesis the nemesis to create
 */
public static void decorate(EntityLiving entity, NemesisEntry nemesis) {
	entity.addTag(NemesisSystem.TAG_NEMESIS);
	entity.getEntityData().setUniqueId(NemesisSystem.NBT_NEMESIS_ID, nemesis.getId());
	entity.setCustomNameTag(nemesis.getNameAndTitle());

	if (entity instanceof EntityZombie) {
		((EntityZombie) entity).setChild(nemesis.isChild());
	}

	ItemStack helmet = nemesis.getArmorInventory().get(EntityEquipmentSlot.HEAD.getIndex());

	entity.setItemStackToSlot(EntityEquipmentSlot.HEAD, helmet);
	entity.setItemStackToSlot(EntityEquipmentSlot.CHEST, nemesis.getArmorInventory().get(EntityEquipmentSlot.CHEST.getIndex()));
	entity.setItemStackToSlot(EntityEquipmentSlot.LEGS, nemesis.getArmorInventory().get(EntityEquipmentSlot.LEGS.getIndex()));
	entity.setItemStackToSlot(EntityEquipmentSlot.FEET, nemesis.getArmorInventory().get(EntityEquipmentSlot.FEET.getIndex()));

	entity.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, nemesis.getHandInventory().get(EntityEquipmentSlot.MAINHAND.getIndex()));
	entity.setItemStackToSlot(EntityEquipmentSlot.OFFHAND, nemesis.getHandInventory().get(EntityEquipmentSlot.OFFHAND.getIndex()));

	for (IAttributeInstance attribute : entity.getAttributeMap().getAllAttributes()) {
		if (attribute.getAttribute() == SharedMonsterAttributes.ATTACK_DAMAGE) {
			attribute.setBaseValue(attribute.getAttributeValue() * (nemesis.getLevel() / 3));
		}

		if (attribute.getAttribute() == SharedMonsterAttributes.ATTACK_SPEED) {
			attribute.setBaseValue(attribute.getAttributeValue() * (nemesis.getLevel() / 8));
		}

		if (attribute.getAttribute() == SharedMonsterAttributes.MAX_HEALTH) {
			attribute.setBaseValue(attribute.getAttributeValue() * nemesis.getLevel());
			entity.setHealth(entity.getMaxHealth());
		}
	}
}
 
開發者ID:ToroCraft,項目名稱:NemesisSystem,代碼行數:41,代碼來源:EntityDecorator.java


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