本文整理匯總了Java中net.minecraft.entity.EntityLivingBase.isPotionActive方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityLivingBase.isPotionActive方法的具體用法?Java EntityLivingBase.isPotionActive怎麽用?Java EntityLivingBase.isPotionActive使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類net.minecraft.entity.EntityLivingBase
的用法示例。
在下文中一共展示了EntityLivingBase.isPotionActive方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: applyEntityCollision
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@Override
public void applyEntityCollision(Entity e) {
if (!(e instanceof EntityLivingBase))
return;
EntityLivingBase entity = (EntityLivingBase) e;
List<PotionEffect> effects = ((LingeringPotion) ModItems.lingering_potion).getEffects(stack);
boolean addedEffect = false;
for (PotionEffect effect : effects) {
int effectID = effect.getPotionID();
if (Potion.potionTypes[effectID].isInstant()) {
Potion.potionTypes[effectID].affectEntity(thrower, entity, effect.getAmplifier(), 0.25);
addedEffect = true;
} else if (!entity.isPotionActive(effectID)) {
entity.addPotionEffect(effect);
addedEffect = true;
}
}
if (addedEffect) {
int ticks = dataWatcher.getWatchableObjectInt(TICKS_DATA_WATCHER);
if (setTickCount(ticks + 5 * 20)) // Add 5 seconds to the expiration time (decreasing radius by 0.5 blocks)
return;
}
}
示例2: attackEntityWithRangedAttack
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
* Attack the specified entity using a ranged attack.
*/
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
if (!this.getAggressive())
{
EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
entitypotion.rotationPitch -= -20.0F;
double d1 = p_82196_1_.posX + p_82196_1_.motionX - this.posX;
double d2 = d0 - this.posY;
double d3 = p_82196_1_.posZ + p_82196_1_.motionZ - this.posZ;
float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);
if (f >= 8.0F && !p_82196_1_.isPotionActive(Potion.moveSlowdown))
{
entitypotion.setPotionDamage(32698);
}
else if (p_82196_1_.getHealth() >= 8.0F && !p_82196_1_.isPotionActive(Potion.poison))
{
entitypotion.setPotionDamage(32660);
}
else if (f <= 3.0F && !p_82196_1_.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
{
entitypotion.setPotionDamage(32696);
}
entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
this.worldObj.spawnEntityInWorld(entitypotion);
}
}
示例3: onImpact
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
@Override
protected void onImpact(MovingObjectPosition pos) {
if (pos.entityHit != null) {
pos.entityHit.attackEntityFrom(DamageSource.causePlayerDamage(this.getOwner()).setProjectile(), getDamage(exp));
if (pos.entityHit instanceof EntityLivingBase) {
EntityLivingBase elb = (EntityLivingBase) pos.entityHit;
if (!elb.isPotionActive(Potion.blindness)) {
elb.addPotionEffect(new PotionEffect(Potion.blindness.id, (int)MathUtils.lerp(40, 80, exp)));
}
}
}
this.setDead();
}
示例4: attackEntityWithRangedAttack
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
* Attack the specified entity using a ranged attack.
*
* @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
*/
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
if (!this.isDrinkingPotion())
{
double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
double d1 = target.posX + target.motionX - this.posX;
double d2 = d0 - this.posY;
double d3 = target.posZ + target.motionZ - this.posZ;
float f = MathHelper.sqrt(d1 * d1 + d3 * d3);
PotionType potiontype = PotionTypes.HARMING;
if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
{
potiontype = PotionTypes.SLOWNESS;
}
else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
{
potiontype = PotionTypes.POISON;
}
else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
{
potiontype = PotionTypes.WEAKNESS;
}
EntityPotion entitypotion = new EntityPotion(this.world, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -20.0F;
entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
this.world.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
this.world.spawnEntityInWorld(entitypotion);
}
}
示例5: attackEntityWithRangedAttack
import net.minecraft.entity.EntityLivingBase; //導入方法依賴的package包/類
/**
* Attack the specified entity using a ranged attack.
*
* @param distanceFactor How far the target is, normalized and clamped between 0.1 and 1.0
*/
public void attackEntityWithRangedAttack(EntityLivingBase target, float distanceFactor)
{
if (!this.isDrinkingPotion())
{
double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
double d1 = target.posX + target.motionX - this.posX;
double d2 = d0 - this.posY;
double d3 = target.posZ + target.motionZ - this.posZ;
float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3);
PotionType potiontype = PotionTypes.HARMING;
if (f >= 8.0F && !target.isPotionActive(MobEffects.SLOWNESS))
{
potiontype = PotionTypes.SLOWNESS;
}
else if (target.getHealth() >= 8.0F && !target.isPotionActive(MobEffects.POISON))
{
potiontype = PotionTypes.POISON;
}
else if (f <= 3.0F && !target.isPotionActive(MobEffects.WEAKNESS) && this.rand.nextFloat() < 0.25F)
{
potiontype = PotionTypes.WEAKNESS;
}
EntityPotion entitypotion = new EntityPotion(this.worldObj, this, PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), potiontype));
entitypotion.rotationPitch -= -20.0F;
entitypotion.setThrowableHeading(d1, d2 + (double)(f * 0.2F), d3, 0.75F, 8.0F);
this.worldObj.playSound((EntityPlayer)null, this.posX, this.posY, this.posZ, SoundEvents.ENTITY_WITCH_THROW, this.getSoundCategory(), 1.0F, 0.8F + this.rand.nextFloat() * 0.4F);
this.worldObj.spawnEntityInWorld(entitypotion);
}
}