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


Java IAttributeInstance類代碼示例

本文整理匯總了Java中net.minecraft.entity.ai.attributes.IAttributeInstance的典型用法代碼示例。如果您正苦於以下問題:Java IAttributeInstance類的具體用法?Java IAttributeInstance怎麽用?Java IAttributeInstance使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


IAttributeInstance類屬於net.minecraft.entity.ai.attributes包,在下文中一共展示了IAttributeInstance類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: writeAttributeInstanceToNBT

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
 */
private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance instance)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    IAttribute iattribute = instance.getAttribute();
    nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName());
    nbttagcompound.setDouble("Base", instance.getBaseValue());
    Collection<AttributeModifier> collection = instance.getModifiers();

    if (collection != null && !collection.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (AttributeModifier attributemodifier : collection)
        {
            if (attributemodifier.isSaved())
            {
                nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
            }
        }

        nbttagcompound.setTag("Modifiers", nbttaglist);
    }

    return nbttagcompound;
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:29,代碼來源:SharedMonsterAttributes.java

示例2: updateAITasks

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
protected void updateAITasks() {
	IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);

	if (this.isAngry()) {
		--this.angerLevel;
	}

	if (this.randomSoundDelay > 0 && --this.randomSoundDelay == 0) {
		this.playSound(SoundEvents.ENTITY_ZOMBIE_PIG_ANGRY, this.getSoundVolume() * 2.0F,
				((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F + 1.0F) * 1.8F);
	}

	if (this.angerLevel > 0 && this.angerTargetUUID != null && this.getAITarget() == null) {
		EntityPlayer entityplayer = this.world.getPlayerEntityByUUID(this.angerTargetUUID);
		this.setRevengeTarget(entityplayer);
		this.attackingPlayer = entityplayer;
		this.recentlyHit = this.getRevengeTimer();
	}

	super.updateAITasks();
}
 
開發者ID:the-realest-stu,項目名稱:Infernum,代碼行數:22,代碼來源:EntityPigZombieMage.java

示例3: applyModifiersToAttributeInstance

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
private static void applyModifiersToAttributeInstance(IAttributeInstance instance, NBTTagCompound compound)
{
    instance.setBaseValue(compound.getDouble("Base"));

    if (compound.hasKey("Modifiers", 9))
    {
        NBTTagList nbttaglist = compound.getTagList("Modifiers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i));

            if (attributemodifier != null)
            {
                AttributeModifier attributemodifier1 = instance.getModifier(attributemodifier.getID());

                if (attributemodifier1 != null)
                {
                    instance.removeModifier(attributemodifier1);
                }

                instance.applyModifier(attributemodifier);
            }
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:27,代碼來源:SharedMonsterAttributes.java

示例4: sendMetadataToAllAssociatedPlayers

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Sends the entity metadata (DataWatcher) and attributes to all players tracking this entity, including the entity
 * itself if a player.
 */
private void sendMetadataToAllAssociatedPlayers()
{
    EntityDataManager entitydatamanager = this.trackedEntity.getDataManager();

    if (entitydatamanager.isDirty())
    {
        this.sendToTrackingAndSelf(new SPacketEntityMetadata(this.trackedEntity.getEntityId(), entitydatamanager, false));
    }

    if (this.trackedEntity instanceof EntityLivingBase)
    {
        AttributeMap attributemap = (AttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();
        Set<IAttributeInstance> set = attributemap.getAttributeInstanceSet();

        if (!set.isEmpty())
        {
            this.sendToTrackingAndSelf(new SPacketEntityProperties(this.trackedEntity.getEntityId(), set));
        }

        set.clear();
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:27,代碼來源:EntityTrackerEntry.java

示例5: setChild

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Set whether this zombie is a child.
 */
public void setChild(boolean childZombie)
{
    this.getDataWatcher().updateObject(12, Byte.valueOf((byte)(childZombie ? 1 : 0)));

    if (this.worldObj != null && !this.worldObj.isRemote)
    {
        IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
        iattributeinstance.removeModifier(babySpeedBoostModifier);

        if (childZombie)
        {
            iattributeinstance.applyModifier(babySpeedBoostModifier);
        }
    }

    this.setChildSize(childZombie);
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:21,代碼來源:EntityZombie.java

示例6: writeAttributeInstanceToNBT

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Creates an NBTTagCompound from an AttributeInstance, including its AttributeModifiers
 */
private static NBTTagCompound writeAttributeInstanceToNBT(IAttributeInstance p_111261_0_)
{
    NBTTagCompound nbttagcompound = new NBTTagCompound();
    IAttribute iattribute = p_111261_0_.getAttribute();
    nbttagcompound.setString("Name", iattribute.getAttributeUnlocalizedName());
    nbttagcompound.setDouble("Base", p_111261_0_.getBaseValue());
    Collection<AttributeModifier> collection = p_111261_0_.func_111122_c();

    if (collection != null && !collection.isEmpty())
    {
        NBTTagList nbttaglist = new NBTTagList();

        for (AttributeModifier attributemodifier : collection)
        {
            if (attributemodifier.isSaved())
            {
                nbttaglist.appendTag(writeAttributeModifierToNBT(attributemodifier));
            }
        }

        nbttagcompound.setTag("Modifiers", nbttaglist);
    }

    return nbttagcompound;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:29,代碼來源:SharedMonsterAttributes.java

示例7: func_151475_a

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
public static void func_151475_a(BaseAttributeMap p_151475_0_, NBTTagList p_151475_1_)
{
    for (int i = 0; i < p_151475_1_.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = p_151475_1_.getCompoundTagAt(i);
        IAttributeInstance iattributeinstance = p_151475_0_.getAttributeInstanceByName(nbttagcompound.getString("Name"));

        if (iattributeinstance != null)
        {
            applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
        }
        else
        {
            logger.warn("Ignoring unknown attribute \'" + nbttagcompound.getString("Name") + "\'");
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:18,代碼來源:SharedMonsterAttributes.java

示例8: applyModifiersToAttributeInstance

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
private static void applyModifiersToAttributeInstance(IAttributeInstance p_111258_0_, NBTTagCompound p_111258_1_)
{
    p_111258_0_.setBaseValue(p_111258_1_.getDouble("Base"));

    if (p_111258_1_.hasKey("Modifiers", 9))
    {
        NBTTagList nbttaglist = p_111258_1_.getTagList("Modifiers", 10);

        for (int i = 0; i < nbttaglist.tagCount(); ++i)
        {
            AttributeModifier attributemodifier = readAttributeModifierFromNBT(nbttaglist.getCompoundTagAt(i));

            if (attributemodifier != null)
            {
                AttributeModifier attributemodifier1 = p_111258_0_.getModifier(attributemodifier.getID());

                if (attributemodifier1 != null)
                {
                    p_111258_0_.removeModifier(attributemodifier1);
                }

                p_111258_0_.applyModifier(attributemodifier);
            }
        }
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:27,代碼來源:SharedMonsterAttributes.java

示例9: sendMetadataToAllAssociatedPlayers

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Sends the entity metadata (DataWatcher) and attributes to all players tracking this entity, including the entity
 * itself if a player.
 */
private void sendMetadataToAllAssociatedPlayers()
{
    DataWatcher datawatcher = this.trackedEntity.getDataWatcher();

    if (datawatcher.hasObjectChanged())
    {
        this.func_151261_b(new S1CPacketEntityMetadata(this.trackedEntity.getEntityId(), datawatcher, false));
    }

    if (this.trackedEntity instanceof EntityLivingBase)
    {
        ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.trackedEntity).getAttributeMap();
        Set<IAttributeInstance> set = serversideattributemap.getAttributeInstanceSet();

        if (!set.isEmpty())
        {
            this.func_151261_b(new S20PacketEntityProperties(this.trackedEntity.getEntityId(), set));
        }

        set.clear();
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:27,代碼來源:EntityTrackerEntry.java

示例10: setAttributeModifiers

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
public static void setAttributeModifiers(AbstractAttributeMap map, NBTTagList list)
{
    for (int i = 0; i < list.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
        IAttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name"));

        if (iattributeinstance != null)
        {
            applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
        }
        else
        {
            LOGGER.warn("Ignoring unknown attribute \'{}\'", new Object[] {nbttagcompound.getString("Name")});
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:18,代碼來源:SharedMonsterAttributes.java

示例11: setAttributeModifiers

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
public static void setAttributeModifiers(AbstractAttributeMap map, NBTTagList list)
{
    for (int i = 0; i < list.tagCount(); ++i)
    {
        NBTTagCompound nbttagcompound = list.getCompoundTagAt(i);
        IAttributeInstance iattributeinstance = map.getAttributeInstanceByName(nbttagcompound.getString("Name"));

        if (iattributeinstance == null)
        {
            LOGGER.warn("Ignoring unknown attribute \'{}\'", new Object[] {nbttagcompound.getString("Name")});
        }
        else
        {
            applyModifiersToAttributeInstance(iattributeinstance, nbttagcompound);
        }
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:18,代碼來源:SharedMonsterAttributes.java

示例12: setAttackTarget

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Sets the active target the Task system uses for tracking
 */
public void setAttackTarget(@Nullable EntityLivingBase entitylivingbaseIn)
{
    super.setAttackTarget(entitylivingbaseIn);
    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);

    if (entitylivingbaseIn == null)
    {
        this.targetChangeTime = 0;
        this.dataManager.set(SCREAMING, Boolean.valueOf(false));
        iattributeinstance.removeModifier(ATTACKING_SPEED_BOOST);
    }
    else
    {
        this.targetChangeTime = this.ticksExisted;
        this.dataManager.set(SCREAMING, Boolean.valueOf(true));

        if (!iattributeinstance.hasModifier(ATTACKING_SPEED_BOOST))
        {
            iattributeinstance.applyModifier(ATTACKING_SPEED_BOOST);
        }
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:26,代碼來源:EntityEnderman.java

示例13: setChild

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Set whether this zombie is a child.
 */
public void setChild(boolean childZombie)
{
    this.getDataManager().set(IS_CHILD, Boolean.valueOf(childZombie));

    if (this.world != null && !this.world.isRemote)
    {
        IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
        iattributeinstance.removeModifier(BABY_SPEED_BOOST);

        if (childZombie)
        {
            iattributeinstance.applyModifier(BABY_SPEED_BOOST);
        }
    }

    this.setChildSize(childZombie);
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:21,代碼來源:EntityZombie.java

示例14: setSprintingGay

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
public void setSprintingGay(boolean sprinting)
{
	SprintEvent event = new SprintEvent(sprinting);
	event.call();

	sprinting = event.sprint;

	super.setSprinting(sprinting);
	IAttributeInstance var2 = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);

	if (var2.getModifier(sprintingSpeedBoostModifierUUID) != null)
	{
		var2.removeModifier(sprintingSpeedBoostModifier);
	}

	if (sprinting)
	{
		var2.applyModifier(sprintingSpeedBoostModifier);
	}
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:AbstractClientPlayer.java

示例15: setSprinting

import net.minecraft.entity.ai.attributes.IAttributeInstance; //導入依賴的package包/類
/**
 * Set sprinting switch for Entity.
 */
public void setSprinting(boolean sprinting)
{
    super.setSprinting(sprinting);
    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);

    if (iattributeinstance.getModifier(sprintingSpeedBoostModifierUUID) != null)
    {
        iattributeinstance.removeModifier(sprintingSpeedBoostModifier);
    }

    if (sprinting)
    {
        iattributeinstance.applyModifier(sprintingSpeedBoostModifier);
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:19,代碼來源:EntityLivingBase.java


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