本文整理汇总了Java中net.minecraft.entity.EntityLivingBase.getEntityAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java EntityLivingBase.getEntityAttribute方法的具体用法?Java EntityLivingBase.getEntityAttribute怎么用?Java EntityLivingBase.getEntityAttribute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.getEntityAttribute方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onHurtEvent
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@SubscribeEvent
public static void onHurtEvent(LivingHurtEvent event)
{
EntityLivingBase entity = event.getEntityLiving();
DamageSource damageSource = event.getSource();
float damage = event.getAmount();
if(entity != null)
{
IAttributeInstance damageRate = null;
if(isPhysicalDamage(damageSource))
damageRate = entity.getEntityAttribute(PHYSICAL_DAMAGE_RATE);
if(damageSource.isFireDamage())
damageRate = entity.getEntityAttribute(FIRE_DAMAGE_RATE);
if(damageRate != null)
damage *= damageRate.getAttributeValue();
}
event.setAmount(damage);
}
示例2: getWeaponDamage
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
@Override
public float getWeaponDamage(ItemStack stack, EntityLivingBase living, Entity target) {
float damage = ItemFromData.getData(stack).getFloat(PropertyType.DAMAGE);
if(living == null || living!=target){
damage=TF2Attribute.getModifier("Damage", stack,damage, living);
if (living != null && (this.isDoubleWielding(living) || living.isHandActive()))
damage *= 0.85f;
if (target != null && !target.isBurning())
damage = TF2Attribute.getModifier("Damage Non Burn", stack, damage, living);
if (target != null && target.isBurning())
damage = TF2Attribute.getModifier("Damage Burning", stack, damage, living);
if (living != null && living.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE) != null){
//System.out.println("Pre "+damage);
damage=(float) calculateModifiers(living.getEntityAttribute(SharedMonsterAttributes.ATTACK_DAMAGE),ATTACK_DAMAGE_MODIFIER,damage,1D/9D);
//System.out.println("Post "+damage);
}
}
return damage;
}
示例3: getFiringSpeed
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
public int getFiringSpeed(ItemStack stack, EntityLivingBase living) {
int speed=(int) (TF2Attribute.getModifier("Fire Rate", stack,
ItemFromData.getData(stack).getInt(PropertyType.FIRE_SPEED), living));
if(living != null && this.isDoubleWielding(living))
speed *= this.getDoubleWieldBonus(stack, living);
if(TF2Attribute.getModifier("Fire Rate Health", stack, 1f, living) != 1f)
speed *= this.getHealthBasedBonus(stack, living, TF2Attribute.getModifier("Fire Rate Health", stack, 1f, living));
if(living != null && (WeaponsCapability.get(living).isExpJump() || living.isElytraFlying()) && TF2Attribute.getModifier("Airborne Bonus", stack, 0, living) != 0)
speed *= 0.35f;
if(living != null && living.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED)!=null){
//System.out.println("Pre speed "+speed+" "+living.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue());
double modifiers=calculateModifiers(living.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED),ATTACK_SPEED_MODIFIER,living.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue(),1.4);
speed *= (living instanceof EntityPlayer? 4:living.getEntityAttribute(SharedMonsterAttributes.ATTACK_SPEED).getBaseValue())/modifiers;
//System.out.println("Post speed "+speed);
}
return speed;
}
示例4: netherFortressArmor
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/** Handle wearing nether fortress armor */
private boolean netherFortressArmor(LivingHurtEvent e) {
EntityLivingBase hurt = e.getEntityLiving();
// do things based on the armor status
int armorCount = getWearingSetCount(hurt, ItemArmorNether.class);
if(armorCount > 0) {
// knockback resistance
IAttributeInstance inst = hurt.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE);
AttributeModifier mod = new AttributeModifier(knockbackID, "nfakb", armorCount / 4D, 0).setSaved(false);
if(inst.getModifier(knockbackID) == null) inst.applyModifier(mod);
// wither thorns
if(e.getSource().getTrueSource() != null && e.getSource().getTrueSource() instanceof EntityLivingBase) {
EntityLivingBase attacker = (EntityLivingBase)e.getSource().getTrueSource();
attacker.addPotionEffect(new PotionEffect(MobEffects.WITHER, armorCount * 20, armorCount > 2 ? 1 : 0));
}
// blast resistance I
if(e.getSource().isExplosion()) {
e.setAmount(e.getAmount() * (1 - armorCount / 8F));
}
return true;
}
return false;
}
示例5: resetStatus
import net.minecraft.entity.EntityLivingBase; //导入方法依赖的package包/类
/** Reset some stuff every tick */
@SubscribeEvent
public void resetStatus(LivingUpdateEvent e) {
EntityLivingBase guy = e.getEntityLiving();
if(!guy.world.isRemote) {
// nether fortress stuff
IAttributeInstance inst = guy.getEntityAttribute(SharedMonsterAttributes.KNOCKBACK_RESISTANCE);
if(inst.getModifier(knockbackID) != null) inst.removeModifier(knockbackID);
}
}