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


Java IAttributeInstance.applyModifier方法代码示例

本文整理汇总了Java中net.minecraft.entity.ai.attributes.IAttributeInstance.applyModifier方法的典型用法代码示例。如果您正苦于以下问题:Java IAttributeInstance.applyModifier方法的具体用法?Java IAttributeInstance.applyModifier怎么用?Java IAttributeInstance.applyModifier使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在net.minecraft.entity.ai.attributes.IAttributeInstance的用法示例。


在下文中一共展示了IAttributeInstance.applyModifier方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: 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:SkidJava,项目名称:BaseClient,代码行数:27,代码来源:SharedMonsterAttributes.java

示例2: 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.MOVEMENT_SPEED);

    if (iattributeinstance.getModifier(SPRINTING_SPEED_BOOST_ID) != null)
    {
        iattributeinstance.removeModifier(SPRINTING_SPEED_BOOST);
    }

    if (sprinting)
    {
        iattributeinstance.applyModifier(SPRINTING_SPEED_BOOST);
    }
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:19,代码来源:EntityLivingBase.java

示例3: 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

示例4: 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

示例5: 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:sudofox,项目名称:Backmemed,代码行数:27,代码来源:SharedMonsterAttributes.java

示例6: 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

示例7: handleEntityProperties

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
/**
 * Updates en entity's attributes and their respective modifiers, which are used
 * for speed bonusses (player sprinting, animals fleeing, baby speed),
 * weapon/tool attackDamage, hostiles followRange randomization, zombie
 * maxHealth and knockback resistance as well as reinforcement spawning chance.
 */
public void handleEntityProperties(S20PacketEntityProperties packetIn) {
	PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
	Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

	if (entity != null) {
		if (!(entity instanceof EntityLivingBase)) {
			throw new IllegalStateException(
					"Server tried to update attributes of a non-living entity (actually: " + entity + ")");
		} else {
			BaseAttributeMap baseattributemap = ((EntityLivingBase) entity).getAttributeMap();

			for (S20PacketEntityProperties.Snapshot s20packetentityproperties$snapshot : packetIn.func_149441_d()) {
				IAttributeInstance iattributeinstance = baseattributemap
						.getAttributeInstanceByName(s20packetentityproperties$snapshot.func_151409_a());

				if (iattributeinstance == null) {
					iattributeinstance = baseattributemap.registerAttribute(new RangedAttribute((IAttribute) null,
							s20packetentityproperties$snapshot.func_151409_a(), 0.0D, 2.2250738585072014E-308D,
							Double.MAX_VALUE));
				}

				iattributeinstance.setBaseValue(s20packetentityproperties$snapshot.func_151410_b());
				iattributeinstance.removeAllModifiers();

				for (AttributeModifier attributemodifier : s20packetentityproperties$snapshot.func_151408_c()) {
					iattributeinstance.applyModifier(attributemodifier);
				}
			}
		}
	}
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:38,代码来源:NetHandlerPlayClient.java

示例8: applyAttributesModifiersToEntity

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
public void applyAttributesModifiersToEntity(EntityLivingBase entityLivingBaseIn, BaseAttributeMap p_111185_2_, int amplifier)
{
    for (Entry<IAttribute, AttributeModifier> entry : this.attributeModifierMap.entrySet())
    {
        IAttributeInstance iattributeinstance = p_111185_2_.getAttributeInstance((IAttribute)entry.getKey());

        if (iattributeinstance != null)
        {
            AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
            iattributeinstance.removeModifier(attributemodifier);
            iattributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + amplifier, this.getAttributeModifierAmount(amplifier, attributemodifier), attributemodifier.getOperation()));
        }
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:15,代码来源:Potion.java

示例9: updateAITasks

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
protected void updateAITasks()
{
    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);

    if (this.isAngry())
    {
        if (!this.isChild() && !iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER))
        {
            iattributeinstance.applyModifier(ATTACK_SPEED_BOOST_MODIFIER);
        }

        --this.angerLevel;
    }
    else if (iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER))
    {
        iattributeinstance.removeModifier(ATTACK_SPEED_BOOST_MODIFIER);
    }

    if (this.randomSoundDelay > 0 && --this.randomSoundDelay == 0)
    {
        this.playSound("mob.zombiepig.zpigangry", 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.worldObj.getPlayerEntityByUUID(this.angerTargetUUID);
        this.setRevengeTarget(entityplayer);
        this.attackingPlayer = entityplayer;
        this.recentlyHit = this.getRevengeTimer();
    }

    super.updateAITasks();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:34,代码来源:EntityPigZombie.java

示例10: handleEntityProperties

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
/**
 * Updates en entity's attributes and their respective modifiers, which are used for speed bonusses (player
 * sprinting, animals fleeing, baby speed), weapon/tool attackDamage, hostiles followRange randomization, zombie
 * maxHealth and knockback resistance as well as reinforcement spawning chance.
 */
public void handleEntityProperties(SPacketEntityProperties packetIn)
{
    PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController);
    Entity entity = this.clientWorldController.getEntityByID(packetIn.getEntityId());

    if (entity != null)
    {
        if (!(entity instanceof EntityLivingBase))
        {
            throw new IllegalStateException("Server tried to update attributes of a non-living entity (actually: " + entity + ")");
        }
        else
        {
            AbstractAttributeMap abstractattributemap = ((EntityLivingBase)entity).getAttributeMap();

            for (SPacketEntityProperties.Snapshot spacketentityproperties$snapshot : packetIn.getSnapshots())
            {
                IAttributeInstance iattributeinstance = abstractattributemap.getAttributeInstanceByName(spacketentityproperties$snapshot.getName());

                if (iattributeinstance == null)
                {
                    iattributeinstance = abstractattributemap.registerAttribute(new RangedAttribute((IAttribute)null, spacketentityproperties$snapshot.getName(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));
                }

                iattributeinstance.setBaseValue(spacketentityproperties$snapshot.getBaseValue());
                iattributeinstance.removeAllModifiers();

                for (AttributeModifier attributemodifier : spacketentityproperties$snapshot.getModifiers())
                {
                    iattributeinstance.applyModifier(attributemodifier);
                }
            }
        }
    }
}
 
开发者ID:NSExceptional,项目名称:Zombe-Modpack,代码行数:41,代码来源:NetHandlerPlayClient.java

示例11: updateTask

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
public void updateTask()
{
    if (this.player != null)
    {
        if (--this.field_179450_h <= 0)
        {
            this.targetEntity = this.player;
            this.player = null;
            super.startExecuting();
            this.enderman.playSound("mob.endermen.stare", 1.0F, 1.0F);
            this.enderman.setScreaming(true);
            IAttributeInstance iattributeinstance = this.enderman.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
            iattributeinstance.applyModifier(EntityEnderman.attackingSpeedBoostModifier);
        }
    }
    else
    {
        if (this.targetEntity != null)
        {
            if (this.targetEntity instanceof EntityPlayer && this.enderman.shouldAttackPlayer((EntityPlayer)this.targetEntity))
            {
                if (this.targetEntity.getDistanceSqToEntity(this.enderman) < 16.0D)
                {
                    this.enderman.teleportRandomly();
                }

                this.field_179451_i = 0;
            }
            else if (this.targetEntity.getDistanceSqToEntity(this.enderman) > 256.0D && this.field_179451_i++ >= 30 && this.enderman.teleportToEntity(this.targetEntity))
            {
                this.field_179451_i = 0;
            }
        }

        super.updateTask();
    }
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:38,代码来源:EntityEnderman.java

示例12: updateAITasks

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
protected void updateAITasks()
{
    IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);

    if (this.isAngry())
    {
        if (!this.isChild() && !iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER))
        {
            iattributeinstance.applyModifier(ATTACK_SPEED_BOOST_MODIFIER);
        }

        --this.angerLevel;
    }
    else if (iattributeinstance.hasModifier(ATTACK_SPEED_BOOST_MODIFIER))
    {
        iattributeinstance.removeModifier(ATTACK_SPEED_BOOST_MODIFIER);
    }

    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:sudofox,项目名称:Backmemed,代码行数:34,代码来源:EntityPigZombie.java

示例13: onLivingUpdate

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    if (!this.worldObj.isRemote)
    {
        if (this.isDrinkingPotion())
        {
            if (this.witchAttackTimer-- <= 0)
            {
                this.setAggressive(false);
                ItemStack itemstack = this.getHeldItemMainhand();
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, (ItemStack)null);

                if (itemstack != null && itemstack.getItem() == Items.POTIONITEM)
                {
                    List<PotionEffect> list = PotionUtils.getEffectsFromStack(itemstack);

                    if (list != null)
                    {
                        for (PotionEffect potioneffect : list)
                        {
                            this.addPotionEffect(new PotionEffect(potioneffect));
                        }
                    }
                }

                this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED).removeModifier(MODIFIER);
            }
        }
        else
        {
            PotionType potiontype = null;

            if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.WATER) && !this.isPotionActive(MobEffects.WATER_BREATHING))
            {
                potiontype = PotionTypes.WATER_BREATHING;
            }
            else if (this.rand.nextFloat() < 0.15F && (this.isBurning() || this.getLastDamageSource() != null && this.getLastDamageSource().isFireDamage()) && !this.isPotionActive(MobEffects.FIRE_RESISTANCE))
            {
                potiontype = PotionTypes.FIRE_RESISTANCE;
            }
            else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth())
            {
                potiontype = PotionTypes.HEALING;
            }
            else if (this.rand.nextFloat() < 0.5F && this.getAttackTarget() != null && !this.isPotionActive(MobEffects.SPEED) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                potiontype = PotionTypes.SWIFTNESS;
            }

            if (potiontype != null)
            {
                this.setItemStackToSlot(EntityEquipmentSlot.MAINHAND, PotionUtils.addPotionToItemStack(new ItemStack(Items.POTIONITEM), potiontype));
                this.witchAttackTimer = this.getHeldItemMainhand().getMaxItemUseDuration();
                this.setAggressive(true);
                this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_DRINK, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
                IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.MOVEMENT_SPEED);
                iattributeinstance.removeModifier(MODIFIER);
                iattributeinstance.applyModifier(MODIFIER);
            }
        }

        if (this.rand.nextFloat() < 7.5E-4F)
        {
            this.worldObj.setEntityState(this, (byte)15);
        }
    }

    super.onLivingUpdate();
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:74,代码来源:EntityWitch.java

示例14: onLivingUpdate

import net.minecraft.entity.ai.attributes.IAttributeInstance; //导入方法依赖的package包/类
/**
 * Called frequently so the entity can update its state every tick as required. For example, zombies and skeletons
 * use this to react to sunlight and start to burn.
 */
public void onLivingUpdate()
{
    if (!this.worldObj.isRemote)
    {
        if (this.getAggressive())
        {
            if (this.witchAttackTimer-- <= 0)
            {
                this.setAggressive(false);
                ItemStack itemstack = this.getHeldItem();
                this.setCurrentItemOrArmor(0, (ItemStack)null);

                if (itemstack != null && itemstack.getItem() == Items.potionitem)
                {
                    List<PotionEffect> list = Items.potionitem.getEffects(itemstack);

                    if (list != null)
                    {
                        for (PotionEffect potioneffect : list)
                        {
                            this.addPotionEffect(new PotionEffect(potioneffect));
                        }
                    }
                }

                this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).removeModifier(MODIFIER);
            }
        }
        else
        {
            int i = -1;

            if (this.rand.nextFloat() < 0.15F && this.isInsideOfMaterial(Material.water) && !this.isPotionActive(Potion.waterBreathing))
            {
                i = 8237;
            }
            else if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(Potion.fireResistance))
            {
                i = 16307;
            }
            else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth())
            {
                i = 16341;
            }
            else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                i = 16274;
            }
            else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
            {
                i = 16274;
            }

            if (i > -1)
            {
                this.setCurrentItemOrArmor(0, new ItemStack(Items.potionitem, 1, i));
                this.witchAttackTimer = this.getHeldItem().getMaxItemUseDuration();
                this.setAggressive(true);
                IAttributeInstance iattributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
                iattributeinstance.removeModifier(MODIFIER);
                iattributeinstance.applyModifier(MODIFIER);
            }
        }

        if (this.rand.nextFloat() < 7.5E-4F)
        {
            this.worldObj.setEntityState(this, (byte)15);
        }
    }

    super.onLivingUpdate();
}
 
开发者ID:Notoh,项目名称:DecompiledMinecraft,代码行数:77,代码来源:EntityWitch.java


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