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