本文整理汇总了Java中net.minecraft.entity.ai.attributes.AttributeInstance.applyModifier方法的典型用法代码示例。如果您正苦于以下问题:Java AttributeInstance.applyModifier方法的具体用法?Java AttributeInstance.applyModifier怎么用?Java AttributeInstance.applyModifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.ai.attributes.AttributeInstance
的用法示例。
在下文中一共展示了AttributeInstance.applyModifier方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setSprinting
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
/**
* Set sprinting switch for Entity.
*/
public void setSprinting(boolean par1)
{
super.setSprinting(par1);
AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
if (attributeinstance.getModifier(sprintingSpeedBoostModifierUUID) != null)
{
attributeinstance.removeModifier(sprintingSpeedBoostModifier);
}
if (par1)
{
attributeinstance.applyModifier(sprintingSpeedBoostModifier);
}
}
示例2: attackEntityFrom
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
/**
* Called when the entity is attacked.
*/
public boolean attackEntityFrom(DamageSource par1DamageSource, float par2)
{
if (this.isEntityInvulnerable())
{
return false;
}
else
{
this.fleeingTick = 60;
if (!this.isAIEnabled())
{
AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
if (attributeinstance.getModifier(field_110179_h) == null)
{
attributeinstance.applyModifier(field_110181_i);
}
}
this.entityToAttack = null;
this.inLove = 0;
return super.attackEntityFrom(par1DamageSource, par2);
}
}
示例3: onUpdate
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
/**
* Called to update the entity's position/logic.
*/
public void onUpdate()
{
if (this.field_110191_bu != this.entityToAttack && !this.worldObj.isRemote)
{
AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
attributeinstance.removeModifier(field_110190_br);
if (this.entityToAttack != null)
{
attributeinstance.applyModifier(field_110190_br);
}
}
this.field_110191_bu = this.entityToAttack;
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);
}
super.onUpdate();
}
示例4: setChild
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
/**
* Set whether this zombie is a child.
*/
public void setChild(boolean par1)
{
this.getDataWatcher().updateObject(12, Byte.valueOf((byte)(par1 ? 1 : 0)));
if (this.worldObj != null && !this.worldObj.isRemote)
{
AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
attributeinstance.removeModifier(babySpeedBoostModifier);
if (par1)
{
attributeinstance.applyModifier(babySpeedBoostModifier);
}
}
}
示例5: func_111258_a
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
private static void func_111258_a(AttributeInstance par0AttributeInstance, NBTTagCompound par1NBTTagCompound)
{
par0AttributeInstance.setAttribute(par1NBTTagCompound.getDouble("Base"));
if (par1NBTTagCompound.hasKey("Modifiers"))
{
NBTTagList nbttaglist = par1NBTTagCompound.getTagList("Modifiers");
for (int i = 0; i < nbttaglist.tagCount(); ++i)
{
AttributeModifier attributemodifier = func_111259_a((NBTTagCompound)nbttaglist.tagAt(i));
AttributeModifier attributemodifier1 = par0AttributeInstance.getModifier(attributemodifier.getID());
if (attributemodifier1 != null)
{
par0AttributeInstance.removeModifier(attributemodifier1);
}
par0AttributeInstance.applyModifier(attributemodifier);
}
}
}
示例6: applyAttributesModifiersToEntity
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
public void applyAttributesModifiersToEntity(EntityLivingBase par1EntityLivingBase, BaseAttributeMap par2BaseAttributeMap, int par3)
{
Iterator iterator = this.field_111188_I.entrySet().iterator();
while (iterator.hasNext())
{
Entry entry = (Entry)iterator.next();
AttributeInstance attributeinstance = par2BaseAttributeMap.getAttributeInstance((Attribute)entry.getKey());
if (attributeinstance != null)
{
AttributeModifier attributemodifier = (AttributeModifier)entry.getValue();
attributeinstance.removeModifier(attributemodifier);
attributeinstance.applyModifier(new AttributeModifier(attributemodifier.getID(), this.getName() + " " + par3, this.func_111183_a(par3, attributemodifier), attributemodifier.getOperation()));
}
}
}
示例7: updateMoveSpeed
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
private void updateMoveSpeed(EntityLivingBase entity, EntityStats stats) {
AttributeInstance moveSpeedAttribute = entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
double newMoveSpeed = stats.getMovementSpeed();
double oldMoveSpeed = moveSpeedAttribute.getAttributeValue();
if (newMoveSpeed != oldMoveSpeed) {
double baseMoveSpeed = moveSpeedAttribute.getBaseValue();
// Get the modifier:
AttributeModifier speedModifier = moveSpeedAttribute.getModifier(uuid);
if (speedModifier != null) {
// Remove the old modifier
moveSpeedAttribute.removeModifier(speedModifier);
}
// I think the argument "2" stands for operation "add percentage":
speedModifier = new AttributeModifier(uuid, "Speed bonus from Dota 2 Items", newMoveSpeed / baseMoveSpeed - 1.0, 2)
.setSaved(false); // I think this makes it non-persistent
moveSpeedAttribute.applyModifier(speedModifier);
}
}
示例8: setChild
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
/**
* Set whether this zombie is a child.
*/
public void setChild(boolean par1)
{
this.getDataWatcher().updateObject(12, Byte.valueOf((byte) (par1 ? 1 : 0)));
if (this.worldObj != null && !this.worldObj.isRemote)
{
AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
attributeinstance.removeModifier(babySpeedBoostModifier);
if (par1)
{
attributeinstance.applyModifier(babySpeedBoostModifier);
}
}
}
示例9: func_110773_a
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
public void func_110773_a(Packet44UpdateAttributes par1Packet44UpdateAttributes)
{
Entity entity = this.getEntityByID(par1Packet44UpdateAttributes.func_111002_d());
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();
Iterator iterator = par1Packet44UpdateAttributes.func_111003_f().iterator();
while (iterator.hasNext())
{
Packet44UpdateAttributesSnapshot packet44updateattributessnapshot = (Packet44UpdateAttributesSnapshot)iterator.next();
AttributeInstance attributeinstance = baseattributemap.getAttributeInstanceByName(packet44updateattributessnapshot.func_142040_a());
if (attributeinstance == null)
{
attributeinstance = baseattributemap.func_111150_b(new RangedAttribute(packet44updateattributessnapshot.func_142040_a(), 0.0D, 2.2250738585072014E-308D, Double.MAX_VALUE));
}
attributeinstance.setAttribute(packet44updateattributessnapshot.func_142041_b());
attributeinstance.func_142049_d();
Iterator iterator1 = packet44updateattributessnapshot.func_142039_c().iterator();
while (iterator1.hasNext())
{
AttributeModifier attributemodifier = (AttributeModifier)iterator1.next();
attributeinstance.applyModifier(attributemodifier);
}
}
}
}
}
示例10: addKnockbackResistance
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
public static void addKnockbackResistance(EntityLivingBase entity) {
AttributeInstance attr = entity.getEntityAttribute(SharedMonsterAttributes.knockbackResistance);
// Get the modifier:
AttributeModifier modifier = attr.getModifier(uuid);
if (modifier != null) {
return;
}
// I think the argument "0" stands for operation "add amount":
modifier = new AttributeModifier(uuid, "Speed bonus from Dota 2 Items", 1, 0)
.setSaved(false); // I think this makes it non-persistent
attr.applyModifier(modifier);
}
示例11: AddPegasus
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的package包/类
private void AddPegasus(EntityLivingBase fEntity)
{
AttributeInstance speedAttr = fEntity.getAttributeMap().getAttributeInstance(SharedMonsterAttributes.movementSpeed);
if(speedAttr.getModifier(pegasusUUID) != null)
return;
AttributeModifier modSpeed = new AttributeModifier(pegasusUUID, "PegasusBoots", 0.2D, 1);
speedAttr.removeModifier(modSpeed);
speedAttr.applyModifier(modSpeed);
}
示例12: onLivingUpdate
import net.minecraft.entity.ai.attributes.AttributeInstance; //导入方法依赖的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.itemID == Item.potion.itemID)
{
List list = Item.potion.getEffects(itemstack);
if (list != null)
{
Iterator iterator = list.iterator();
while (iterator.hasNext())
{
PotionEffect potioneffect = (PotionEffect)iterator.next();
this.addPotionEffect(new PotionEffect(potioneffect));
}
}
}
this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).removeModifier(field_110185_bq);
}
}
else
{
short short1 = -1;
if (this.rand.nextFloat() < 0.15F && this.isBurning() && !this.isPotionActive(Potion.fireResistance))
{
short1 = 16307;
}
else if (this.rand.nextFloat() < 0.05F && this.getHealth() < this.getMaxHealth())
{
short1 = 16341;
}
else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
{
short1 = 16274;
}
else if (this.rand.nextFloat() < 0.25F && this.getAttackTarget() != null && !this.isPotionActive(Potion.moveSpeed) && this.getAttackTarget().getDistanceSqToEntity(this) > 121.0D)
{
short1 = 16274;
}
if (short1 > -1)
{
this.setCurrentItemOrArmor(0, new ItemStack(Item.potion, 1, short1));
this.witchAttackTimer = this.getHeldItem().getMaxItemUseDuration();
this.setAggressive(true);
AttributeInstance attributeinstance = this.getEntityAttribute(SharedMonsterAttributes.movementSpeed);
attributeinstance.removeModifier(field_110185_bq);
attributeinstance.applyModifier(field_110185_bq);
}
}
if (this.rand.nextFloat() < 7.5E-4F)
{
this.worldObj.setEntityState(this, (byte)15);
}
}
super.onLivingUpdate();
}