當前位置: 首頁>>代碼示例>>Java>>正文


Java EntityPotion.setThrowableHeading方法代碼示例

本文整理匯總了Java中net.minecraft.entity.projectile.EntityPotion.setThrowableHeading方法的典型用法代碼示例。如果您正苦於以下問題:Java EntityPotion.setThrowableHeading方法的具體用法?Java EntityPotion.setThrowableHeading怎麽用?Java EntityPotion.setThrowableHeading使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在net.minecraft.entity.projectile.EntityPotion的用法示例。


在下文中一共展示了EntityPotion.setThrowableHeading方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: attackWithPotion

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
protected void attackWithPotion(EntityLivingBase target) {
	double targetY = target.posY + (double) target.getEyeHeight() - 1.100000023841858D;
	double targetX = target.posX + target.motionX - this.posX;
	double d2 = targetY - this.posY;
	double targetZ = target.posZ + target.motionZ - this.posZ;

	float f = MathHelper.sqrt(targetX * targetX + targetZ * targetZ);
	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(targetX, d2 + (double) (f * 0.2F), targetZ, 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.spawnEntity(entitypotion);
}
 
開發者ID:ToroCraft,項目名稱:ToroQuest,代碼行數:27,代碼來源:EntityMage.java

示例2: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
@Override
public void attackEntityWithRangedAttack(EntityLivingBase entity, float rangeRatio) {   
  //the EntityPotion class validates if this potion is throwable, and if not it logs error "ThrownPotion entity {} has no item?!
  if(attackTimer <= 0 && getHeldItem(EnumHand.MAIN_HAND).getItem() == Items.SPLASH_POTION && !isHealing) {

    attackedWithPotion = entity;

    double x = entity.posX + entity.motionX - posX;
    double y = entity.posY + entity.getEyeHeight() - 1.100000023841858D - posY;
    double z = entity.posZ + entity.motionZ - posZ;
    float groundDistance = MathHelper.sqrt(x * x + z * z);

    ItemStack potion = getHeldItem(EnumHand.MAIN_HAND);
    attackTimer = getHeldItem(EnumHand.MAIN_HAND).getMaxItemUseDuration();

    EntityPotion entitypotion = new EntityPotion(world, this, potion);
    entitypotion.rotationPitch -= -20.0F;
    entitypotion.setThrowableHeading(x, y + groundDistance * 0.2F, z, 0.75F, 8.0F);
    world.spawnEntity(entitypotion);

    setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
  }
}
 
開發者ID:SleepyTrousers,項目名稱:EnderZoo,代碼行數:24,代碼來源:EntityWitherWitch.java

示例3: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的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);
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:33,代碼來源:EntityWitch.java

示例4: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的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);
    }
}
 
開發者ID:sudofox,項目名稱:Backmemed,代碼行數:37,代碼來源:EntityWitch.java

示例5: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的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);
    }
}
 
開發者ID:F1r3w477,項目名稱:CustomWorldGen,代碼行數:37,代碼來源:EntityWitch.java

示例6: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
    if (!this.getAggressive())
    {
        EntityPotion var3 = new EntityPotion(this.worldObj, this, 32732);
        var3.rotationPitch -= -20.0F;
        double var4 = par1EntityLivingBase.posX + par1EntityLivingBase.motionX - this.posX;
        double var6 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - this.posY;
        double var8 = par1EntityLivingBase.posZ + par1EntityLivingBase.motionZ - this.posZ;
        float var10 = MathHelper.sqrt_double(var4 * var4 + var8 * var8);

        if (var10 >= 8.0F && !par1EntityLivingBase.isPotionActive(Potion.moveSlowdown))
        {
            var3.setPotionDamage(32698);
        }
        else if (par1EntityLivingBase.getHealth() >= 8.0F && !par1EntityLivingBase.isPotionActive(Potion.poison))
        {
            var3.setPotionDamage(32660);
        }
        else if (var10 <= 3.0F && !par1EntityLivingBase.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
        {
            var3.setPotionDamage(32696);
        }

        var3.setThrowableHeading(var4, var6 + (double)(var10 * 0.2F), var8, 0.75F, 8.0F);
        this.worldObj.spawnEntityInWorld(var3);
    }
}
 
開發者ID:MinecraftModdedClients,項目名稱:Resilience-Client-Source,代碼行數:32,代碼來源:EntityWitch.java

示例7: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_)
{
    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);
    }
}
 
開發者ID:BlazeAxtrius,項目名稱:ExpandedRailsMod,代碼行數:35,代碼來源:EntityWitch.java

示例8: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    if (!this.getAggressive())
    {
        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
        entitypotion.rotationPitch -= -20.0F;
        double d0 = p_82196_1_.posX + p_82196_1_.motionX - this.posX;
        double d1 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D - this.posY;
        double d2 = p_82196_1_.posZ + p_82196_1_.motionZ - this.posZ;
        float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2);

        if (f1 >= 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 (f1 <= 3.0F && !p_82196_1_.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
        {
            entitypotion.setPotionDamage(32696);
        }

        entitypotion.setThrowableHeading(d0, d1 + (double)(f1 * 0.2F), d2, 0.75F, 8.0F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
 
開發者ID:xtrafrancyz,項目名稱:Cauldron,代碼行數:29,代碼來源:EntityWitch.java

示例9: attackEntityWithRangedAttack

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
    if (!this.getAggressive())
    {
        EntityPotion entitypotion = new EntityPotion(this.worldObj, this, 32732);
        entitypotion.rotationPitch -= -20.0F;
        double d0 = par1EntityLivingBase.posX + par1EntityLivingBase.motionX - this.posX;
        double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - this.posY;
        double d2 = par1EntityLivingBase.posZ + par1EntityLivingBase.motionZ - this.posZ;
        float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2);

        if (f1 >= 8.0F && !par1EntityLivingBase.isPotionActive(Potion.moveSlowdown))
        {
            entitypotion.setPotionDamage(32698);
        }
        else if (par1EntityLivingBase.getHealth() >= 8.0F && !par1EntityLivingBase.isPotionActive(Potion.poison))
        {
            entitypotion.setPotionDamage(32660);
        }
        else if (f1 <= 3.0F && !par1EntityLivingBase.isPotionActive(Potion.weakness) && this.rand.nextFloat() < 0.25F)
        {
            entitypotion.setPotionDamage(32696);
        }

        entitypotion.setThrowableHeading(d0, d1 + (double)(f1 * 0.2F), d2, 0.75F, 8.0F);
        this.worldObj.spawnEntityInWorld(entitypotion);
    }
}
 
開發者ID:HATB0T,項目名稱:RuneCraftery,代碼行數:32,代碼來源:EntityWitch.java

示例10: throwHealthPotion

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
protected void throwHealthPotion() {
  ItemStack potion = getHeldItem(EnumHand.MAIN_HAND);
  //if its not a splash or lingering potion it will be an error
  EntityPotion entitypotion = new EntityPotion(world, this, potion);
  Vec3d lookVec = getLookVec();

  entitypotion.setThrowableHeading(lookVec.x * 0.5, -1, lookVec.z * 0.5, 0.75F, 1.0F);
  world.spawnEntity(entitypotion);
  setItemStackToSlot(EntityEquipmentSlot.MAINHAND, ItemStack.EMPTY);
  healTimer = 80;
}
 
開發者ID:SleepyTrousers,項目名稱:EnderZoo,代碼行數:12,代碼來源:EntityWitherWitch.java

示例11: execute

import net.minecraft.entity.projectile.EntityPotion; //導入方法依賴的package包/類
@Override
public void execute(EntityLivingBase target, @Nullable AbstractMorph morph)
{
    World world = target.worldObj;

    if (world.isRemote)
    {
        return;
    }

    if (target instanceof EntityPlayer && ((EntityPlayer) target).getCooledAttackStrength(0.0F) < 1)
    {
        return;
    }

    Vec3d look = target.getLook(1.0F);
    PotionType effect = PotionTypes.HARMING;

    if (target.getRNG().nextFloat() < 0.2)
    {
        effect = PotionTypes.SLOWNESS;
    }
    else if (target.getRNG().nextFloat() < 0.1)
    {
        effect = PotionTypes.WEAKNESS;
    }
    else if (target.getRNG().nextFloat() < 0.05)
    {
        effect = PotionTypes.POISON;
    }

    ItemStack stack = PotionUtils.addPotionToItemStack(new ItemStack(Items.SPLASH_POTION), effect);
    EntityPotion potion = new EntityPotion(world, target, stack);

    potion.rotationPitch += 20.0F;
    potion.setThrowableHeading(look.xCoord, look.yCoord, look.zCoord, 0.85F, 2.0F);

    world.spawnEntityInWorld(potion);

    if (target instanceof EntityPlayer)
    {
        ((EntityPlayer) target).resetCooldown();
    }
}
 
開發者ID:mchorse,項目名稱:metamorph,代碼行數:45,代碼來源:Potions.java


注:本文中的net.minecraft.entity.projectile.EntityPotion.setThrowableHeading方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。