Java Code Examples for net.minecraft.entity.projectile.EntitySnowball

The following are top voted examples for showing how to use net.minecraft.entity.projectile.EntitySnowball. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: DecompiledMinecraft   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntitySnowball(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 2
Project: DecompiledMinecraft   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntitySnowball(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 3
Project: BaseClient   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntitySnowball(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 4
Project: BaseClient   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        worldIn.spawnEntityInWorld(new EntitySnowball(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 5
Project: Backmemed   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(World itemStackIn, EntityPlayer worldIn, EnumHand playerIn)
{
    ItemStack itemstack = worldIn.getHeldItem(playerIn);

    if (!worldIn.capabilities.isCreativeMode)
    {
        itemstack.func_190918_g(1);
    }

    itemStackIn.playSound((EntityPlayer)null, worldIn.posX, worldIn.posY, worldIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!itemStackIn.isRemote)
    {
        EntitySnowball entitysnowball = new EntitySnowball(itemStackIn, worldIn);
        entitysnowball.setHeadingFromThrower(worldIn, worldIn.rotationPitch, worldIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        itemStackIn.spawnEntityInWorld(entitysnowball);
    }

    worldIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemstack);
}
 
Example 6
Project: CustomWorldGen   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
        entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitysnowball);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 7
Project: metamorph   File: Snowball.java   Source Code and License 6 votes vote down vote up
@Override
public void execute(EntityLivingBase target, @Nullable AbstractMorph morph)
{
    if (!target.worldObj.isRemote)
    {
        EntitySnowball snowball = new EntitySnowball(target.worldObj, target);
        Vec3d vec3d = target.getLook(1.0F);

        double d1 = 4.0D;
        double d2 = vec3d.xCoord * d1;
        double d3 = vec3d.yCoord * d1;
        double d4 = vec3d.zCoord * d1;

        snowball.setPosition(target.posX, target.posY + target.height * 0.9F, target.posZ);
        snowball.motionX = d2;
        snowball.motionY = d3;
        snowball.motionZ = d4;

        target.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (target.getRNG().nextFloat() * 0.4F + 0.8F));
        target.worldObj.spawnEntityInWorld(snowball);
    }
}
 
Example 8
Project: FairyFactions   File: EntityFairy.java   Source Code and License 6 votes vote down vote up
public boolean snowballFight(DamageSource damagesource) {
	if (damagesource instanceof EntityDamageSourceIndirect) {
		EntityDamageSourceIndirect snowdamage = (EntityDamageSourceIndirect) damagesource;

		if (snowdamage.getSourceOfDamage() != null && snowdamage
				.getSourceOfDamage() instanceof EntitySnowball) {
			snowballin += 1;

			if (attackTime < 10) {
				attackTime = 10;
			}
		}
	}

	return snowballin <= 0;
}
 
Example 9
Project: FairyFactions   File: EntityFairy.java   Source Code and License 6 votes vote down vote up
private void tossSnowball(EntityLivingBase attackTarget) {
	EntitySnowball entitysnowball = new EntitySnowball(worldObj, this);
	double d = attackTarget.posX - this.posX;
	double d1 = ( attackTarget.posY + (double) attackTarget.getEyeHeight() )
			- 1.1000000238418579D - entitysnowball.posY;
	double d2 = attackTarget.posZ - this.posZ;
	float f = MathHelper.sqrt_double(d * d + d2 * d2) * 0.2F;
	entitysnowball.setThrowableHeading(d, d1 + (double) f, d2, 1.6F, 12F);
	worldObj.playSoundAtEntity(this, "random.bow", 1.0F,
			1.0F / ( this.getRNG().nextFloat() * 0.4F + 0.8F ));
	worldObj.spawnEntityInWorld(entitysnowball);
	attackTime = 30;
	armSwing(!didSwing);
	faceEntity(attackTarget, 180F, 180F);
	snowballin -= 1;

	if (snowballin < 0) {
		snowballin = 0;
	}
}
 
Example 10
Project: Resilience-Client-Source   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (!par3EntityPlayer.capabilities.isCreativeMode)
    {
        --par1ItemStack.stackSize;
    }

    par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!par2World.isClient)
    {
        par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
    }

    return par1ItemStack;
}
 
Example 11
Project: Aura-Cascade   File: AuraTilePumpProjectile.java   Source Code and License 6 votes vote down vote up
@Override
public void update() {
    super.update();
    List<Entity> entityList = worldObj.getEntitiesWithinAABB(Entity.class, new AxisAlignedBB(pos.getX() - .5, pos.getY() - .5, pos.getZ() - .5, pos.getX() + 1.5, pos.getY() + 1.5, pos.getZ() + 1.5));
    for (Entity entity : entityList) {
        if (entity instanceof EntitySnowball || entity instanceof EntityEgg) {
            //Fun fact: Eggs and snowballs use the same particle code
            for (int i = 0; i < 8; ++i) {
                this.worldObj.spawnParticle(EnumParticleTypes.SNOWBALL, entity.posX, entity.posY, entity.posZ, 0.0D, 0.0D, 0.0D);
            }
            entity.setDead();
            if (!worldObj.isRemote) {
                onEntityCollidedWithBlock(entity);
            }
        } else if (entity instanceof EntityArrow) {
            entity.setDead();
            if (!worldObj.isRemote) {
                onEntityCollidedWithBlock(entity);
            }
        }
    }
}
 
Example 12
Project: RTM   File: ItemSnowballStick.java   Source Code and License 6 votes vote down vote up
/**
     * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
     */
    public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
    {
//        if (!par3EntityPlayer.capabilities.isCreativeMode)
//        {
//            --par1ItemStack.stackSize;
//        }
        par3EntityPlayer.swingItem();//Make the item swing on right click
        par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

        if (!par2World.isRemote)
        {
            par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
        }

        return par1ItemStack;
    }
 
Example 13
Project: ExpandedRailsMod   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
public ActionResult<ItemStack> onItemRightClick(ItemStack itemStackIn, World worldIn, EntityPlayer playerIn, EnumHand hand)
{
    if (!playerIn.capabilities.isCreativeMode)
    {
        --itemStackIn.stackSize;
    }

    worldIn.playSound((EntityPlayer)null, playerIn.posX, playerIn.posY, playerIn.posZ, SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.NEUTRAL, 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!worldIn.isRemote)
    {
        EntitySnowball entitysnowball = new EntitySnowball(worldIn, playerIn);
        entitysnowball.setHeadingFromThrower(playerIn, playerIn.rotationPitch, playerIn.rotationYaw, 0.0F, 1.5F, 1.0F);
        worldIn.spawnEntityInWorld(entitysnowball);
    }

    playerIn.addStat(StatList.getObjectUseStats(this));
    return new ActionResult(EnumActionResult.SUCCESS, itemStackIn);
}
 
Example 14
Project: MineCraft   File: SharpSnowballs.java   Source Code and License 6 votes vote down vote up
@SubscribeEvent
public void replaceSnowballWithArrow(EntityJoinWorldEvent event) {
	Entity entity = event.entity;
	World world = entity.worldObj;

	if (!(entity instanceof EntitySnowball)) {
		return;
	}

	if (!world.isRemote) {
		EntityArrow arrow = new EntityArrow(world);
		arrow.setLocationAndAngles(entity.posX, entity.posY, entity.posZ,
				0, 0);
		arrow.motionX = entity.motionX;
		arrow.motionY = entity.motionY;
		arrow.motionZ = entity.motionZ;

		arrow.posX += arrow.motionX;
		arrow.posY += arrow.motionY;
		arrow.posZ += arrow.motionZ;

		world.spawnEntityInWorld(arrow);
		entity.setDead();
	}
}
 
Example 15
Project: Cauldron   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
    if (!p_77659_3_.capabilities.isCreativeMode)
    {
        --p_77659_1_.stackSize;
    }

    p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!p_77659_2_.isRemote)
    {
        p_77659_2_.spawnEntityInWorld(new EntitySnowball(p_77659_2_, p_77659_3_));
    }

    return p_77659_1_;
}
 
Example 16
Project: Cauldron   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
public ItemStack onItemRightClick(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_)
{
    if (!p_77659_3_.capabilities.isCreativeMode)
    {
        --p_77659_1_.stackSize;
    }

    p_77659_2_.playSoundAtEntity(p_77659_3_, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!p_77659_2_.isRemote)
    {
        p_77659_2_.spawnEntityInWorld(new EntitySnowball(p_77659_2_, p_77659_3_));
    }

    return p_77659_1_;
}
 
Example 17
Project: RuneCraftery   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (!par3EntityPlayer.capabilities.isCreativeMode)
    {
        --par1ItemStack.stackSize;
    }

    par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!par2World.isRemote)
    {
        par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
    }

    return par1ItemStack;
}
 
Example 18
Project: BetterNutritionMod   File: ItemSnowball.java   Source Code and License 6 votes vote down vote up
/**
 * Called whenever this item is equipped and the right mouse button is pressed. Args: itemStack, world, entityPlayer
 */
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (!par3EntityPlayer.capabilities.isCreativeMode)
    {
        --par1ItemStack.stackSize;
    }

    par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

    if (!par2World.isRemote)
    {
        par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
    }

    return par1ItemStack;
}
 
Example 19
Project: WuppyMods   File: ItemElsaGlove.java   Source Code and License 6 votes vote down vote up
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
	/*
	 * if(lastUse == 0) par2World.getWorldTime();
	 */

	par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

	if (!par2World.isRemote/* && lastUse + 4 < par2World.getWorldTime() */)
	{
		par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
		// lastUse = par2World.getWorldTime();
	}

	par1ItemStack.damageItem(1, par3EntityPlayer);

	return par1ItemStack;
}
 
Example 20
Project: DecompiledMinecraft   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 21
Project: DecompiledMinecraft   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 22
Project: BaseClient   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 23
Project: BaseClient   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D;
    double d1 = p_82196_1_.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = p_82196_1_.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 24
Project: Backmemed   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * 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)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.world, this);
    double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
    double d1 = target.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = target.posZ - this.posZ;
    float f = MathHelper.sqrt(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.world.spawnEntityInWorld(entitysnowball);
}
 
Example 25
Project: CustomWorldGen   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * 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)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
    double d1 = target.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = target.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 26
Project: MidgarCrusade   File: EntitySnowCube.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase entity, float damage)
{
	if (System.currentTimeMillis() % 5000 < 2000)
	{
     EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
     double d0 = entity.posX - this.posX;
     double d1 = entity.posY + (double)entity.getEyeHeight() - 1.100000023841858D - entitysnowball.posY;
     double d2 = entity.posZ - this.posZ;
     float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;
     entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
     this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
     this.worldObj.spawnEntityInWorld(entitysnowball);
	}
}
 
Example 27
Project: Resilience-Client-Source   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
    EntitySnowball var3 = new EntitySnowball(this.worldObj, this);
    double var4 = par1EntityLivingBase.posX - this.posX;
    double var6 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - var3.posY;
    double var8 = par1EntityLivingBase.posZ - this.posZ;
    float var10 = MathHelper.sqrt_double(var4 * var4 + var8 * var8) * 0.2F;
    var3.setThrowableHeading(var4, var6 + (double)var10, var8, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(var3);
}
 
Example 28
Project: Fake-Ores-2   File: EntityOresBoss.java   Source Code and License 5 votes vote down vote up
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.world, this);
    EntityArrow entityarrow = new EntityTippedArrow(this.world, this);
    double d0 = par1EntityLivingBase.posX - this.posX;
    double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - entitysnowball.posY;
    double d2 = par1EntityLivingBase.posZ - this.posZ;
    float f1 = MathHelper.sqrt(d0 * d0 + d2 * d2) * 0.2F;
    entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
    entityarrow.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
    this.playSound(SoundEvents.ENTITY_SKELETON_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.world.spawnEntity(entityarrow);
    this.world.spawnEntity(entitysnowball);
}
 
Example 29
Project: Aura-Cascade   File: AuraTilePumpProjectile.java   Source Code and License 5 votes vote down vote up
public void onEntityCollidedWithBlock(Entity entity) {
    if (entity instanceof EntityArrow) {
        addFuel(Config.pumpArrowDuration, Config.pumpArrowSpeed);
    }

    if (entity instanceof EntityEgg) {
        addFuel(Config.pumpEggDuration, Config.pumpEggSpeed);
    }

    if (entity instanceof EntitySnowball) {
        addFuel(Config.pumpSnowballDuration, Config.pumpSnowballSpeed);
    }
}
 
Example 30
Project: ExpandedRailsMod   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase target, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = target.posY + (double)target.getEyeHeight() - 1.100000023841858D;
    double d1 = target.posX - this.posX;
    double d2 = d0 - entitysnowball.posY;
    double d3 = target.posZ - this.posZ;
    float f = MathHelper.sqrt_double(d1 * d1 + d3 * d3) * 0.2F;
    entitysnowball.setThrowableHeading(d1, d2 + (double)f, d3, 1.6F, 12.0F);
    this.playSound(SoundEvents.ENTITY_SNOWMAN_SHOOT, 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 31
Project: MineCraft   File: SharpSnowballs.java   Source Code and License 5 votes vote down vote up
@SubscribeEvent
public void replaceSnowballWithArrow(EntityJoinWorldEvent event) {
	Entity snowball = event.getEntity();
	World world = snowball.worldObj;

	if (!(snowball instanceof EntitySnowball)) {
		return;
	}

	if (!world.isRemote) {
		EntityTippedArrow arrow = new EntityTippedArrow(world);
		arrow.setLocationAndAngles(snowball.posX, snowball.posY, snowball.posZ,
				0, 0);
		arrow.motionX = snowball.motionX;
		arrow.motionY = snowball.motionY;
		arrow.motionZ = snowball.motionZ;

		// gets arrow out of player's head
		// gets the angle of arrow right, in the direction of motion
		arrow.posX += arrow.motionX;
		arrow.posY += arrow.motionY;
		arrow.posZ += arrow.motionZ;

		world.spawnEntityInWorld(arrow);
		snowball.setDead();
	}
}
 
Example 32
Project: Cauldron   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posX - this.posX;
    double d1 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D - entitysnowball.posY;
    double d2 = p_82196_1_.posZ - this.posZ;
    float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;
    entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 33
Project: Cauldron   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
public void attackEntityWithRangedAttack(EntityLivingBase p_82196_1_, float p_82196_2_)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = p_82196_1_.posX - this.posX;
    double d1 = p_82196_1_.posY + (double)p_82196_1_.getEyeHeight() - 1.100000023841858D - entitysnowball.posY;
    double d2 = p_82196_1_.posZ - this.posZ;
    float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;
    entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 34
Project: modpack   File: SnowballLauncher.java   Source Code and License 5 votes vote down vote up
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
 if(par3EntityPlayer.capabilities.isCreativeMode || par3EntityPlayer.inventory.consumeInventoryItem(Items.snowball)) {
  par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 1F, 0.9F / (itemRand.nextFloat() * 0.4F + 0.8F));
  if (!par2World.isRemote)
     {
         par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
     }
 }
 
          
    return par1ItemStack;
}
 
Example 35
Project: MinecraftStargate   File: ItemZatNikTel.java   Source Code and License 5 votes vote down vote up
public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer)
{
    if (!par3EntityPlayer.capabilities.isCreativeMode)
    {
        --par1ItemStack.stackSize;
    }
    par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));
    if (!par2World.isRemote)
    {
        par2World.spawnEntityInWorld(new EntitySnowball(par2World, par3EntityPlayer));
    }
    return par1ItemStack;
}
 
Example 36
Project: RuneCraftery   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
public void func_82196_d(EntityLivingBase p_82196_1_, float p_82196_2_) {
   EntitySnowball var3 = new EntitySnowball(this.field_70170_p, this);
   double var4 = p_82196_1_.field_70165_t - this.field_70165_t;
   double var6 = p_82196_1_.field_70163_u + (double)p_82196_1_.func_70047_e() - 1.100000023841858D - var3.field_70163_u;
   double var8 = p_82196_1_.field_70161_v - this.field_70161_v;
   float var10 = MathHelper.func_76133_a(var4 * var4 + var8 * var8) * 0.2F;
   var3.func_70186_c(var4, var6 + (double)var10, var8, 1.6F, 12.0F);
   this.func_85030_a("random.bow", 1.0F, 1.0F / (this.func_70681_au().nextFloat() * 0.4F + 0.8F));
   this.field_70170_p.func_72838_d(var3);
}
 
Example 37
Project: RuneCraftery   File: ItemSnowball.java   Source Code and License 5 votes vote down vote up
public ItemStack func_77659_a(ItemStack p_77659_1_, World p_77659_2_, EntityPlayer p_77659_3_) {
   if(!p_77659_3_.field_71075_bZ.field_75098_d) {
      --p_77659_1_.field_77994_a;
   }

   p_77659_2_.func_72956_a(p_77659_3_, "random.bow", 0.5F, 0.4F / (field_77697_d.nextFloat() * 0.4F + 0.8F));
   if(!p_77659_2_.field_72995_K) {
      p_77659_2_.func_72838_d(new EntitySnowball(p_77659_2_, p_77659_3_));
   }

   return p_77659_1_;
}
 
Example 38
Project: RuneCraftery   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = par1EntityLivingBase.posX - this.posX;
    double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - entitysnowball.posY;
    double d2 = par1EntityLivingBase.posZ - this.posZ;
    float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;
    entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 39
Project: BetterNutritionMod   File: EntitySnowman.java   Source Code and License 5 votes vote down vote up
/**
 * Attack the specified entity using a ranged attack.
 */
public void attackEntityWithRangedAttack(EntityLivingBase par1EntityLivingBase, float par2)
{
    EntitySnowball entitysnowball = new EntitySnowball(this.worldObj, this);
    double d0 = par1EntityLivingBase.posX - this.posX;
    double d1 = par1EntityLivingBase.posY + (double)par1EntityLivingBase.getEyeHeight() - 1.100000023841858D - entitysnowball.posY;
    double d2 = par1EntityLivingBase.posZ - this.posZ;
    float f1 = MathHelper.sqrt_double(d0 * d0 + d2 * d2) * 0.2F;
    entitysnowball.setThrowableHeading(d0, d1 + (double)f1, d2, 1.6F, 12.0F);
    this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
    this.worldObj.spawnEntityInWorld(entitysnowball);
}
 
Example 40
Project: OpenBlocks   File: SnowballsFlimFlam.java   Source Code and License 5 votes vote down vote up
@Override
public boolean execute(EntityPlayerMP target) {
	final World world = target.world;
	for (int i = 0; i < 200; i++) {
		EntitySnowball snowball = new EntitySnowball(world, target.posX, target.posY + 4, target.posZ);
		snowball.motionX = RANDOM.nextGaussian() * 0.05;
		snowball.motionY = 1;
		snowball.motionZ = RANDOM.nextGaussian() * 0.05;

		world.spawnEntity(snowball);
	}

	return true;
}