本文整理匯總了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);
}
}
}
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
}
}
}
示例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);
}
}
示例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);
}
}
}
}
}
示例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()));
}
}
}
示例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();
}
示例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);
}
}
}
}
}
示例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();
}
}
示例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();
}
示例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();
}
示例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();
}