Java Code Examples for net.minecraft.world.World.playSoundAtEntity()

The following are Jave code examples for showing how to use playSoundAtEntity() of the net.minecraft.world.World class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: DecompiledMinecraft   File: ItemEgg.java   View Source Code Vote up 6 votes
/**
 * 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 EntityEgg(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 2
Project: DecompiledMinecraft   File: ItemFishingRod.java   View Source Code Vote up 6 votes
/**
 * 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.fishEntity != null)
    {
        int i = playerIn.fishEntity.handleHookRetraction();
        itemStackIn.damageItem(i, playerIn);
        playerIn.swingItem();
    }
    else
    {
        worldIn.playSoundAtEntity(playerIn, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F));

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

        playerIn.swingItem();
        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    }

    return itemStackIn;
}
 
Example 3
Project: minecraft-quiverbow   File: Potatosser.java   View Source Code Vote up 6 votes
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	if (this.getCooldown(stack) > 0) { return; }	// Hasn't cooled down yet

	// SFX
	world.playSoundAtEntity(entity, "random.break", 0.7F, 0.4F);

	// Random Damage
	int dmg_range = this.DmgMax - this.DmgMin; 						// If max dmg is 20 and min is 10, then the range will be 10
	int dmg = world.rand.nextInt(dmg_range + 1);	// Range will be between 0 and 10
	dmg += this.DmgMin;											// Adding the min dmg of 10 back on top, giving us the proper damage range (10-20)

	// Firing
	PotatoShot shot = new PotatoShot(world, entity, (float) this.Speed);
	shot.damage = dmg;
	shot.setDrop(this.shouldDrop);

	world.spawnEntityInWorld(shot);

	this.consumeAmmo(stack, entity, 1);
	this.setCooldown(stack, this.Cooldown);
}
 
Example 4
Project: minecraft-quiverbow   File: LightningRed.java   View Source Code Vote up 6 votes
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 60);
		return;
	}

	ItemStack clipStack = Helper.getAmmoStack(RedstoneMagazine.class, stack.getItemDamage());	// Unloading all ammo into that clip

	stack.setItemDamage(this.getMaxDamage());	// Emptying out

	// Creating the clip
	EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
	entityitem.delayBeforeCanPickup = 10;

	// And dropping it
	if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
	else { world.spawnEntityInWorld(entityitem); }

	// SFX
	world.playSoundAtEntity(entity, "random.break", 1.0F, 0.5F);
}
 
Example 5
Project: minecraft-quiverbow   File: LapisCoil.java   View Source Code Vote up 6 votes
private void dropMagazine(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 60);
		return;
	}

	ItemStack clipStack = Helper.getAmmoStack(LapisMagazine.class, stack.getItemDamage());	// Unloading all ammo into that clip

	stack.setItemDamage(this.getMaxDamage());	// Emptying out

	// Creating the clip
	EntityItem entityitem = new EntityItem(world, entity.posX, entity.posY + 1.0d, entity.posZ, clipStack);
	entityitem.delayBeforeCanPickup = 10;

	// And dropping it
	if (entity.captureDrops) { entity.capturedDrops.add(entityitem); }
	else { world.spawnEntityInWorld(entityitem); }

	// SFX
	world.playSoundAtEntity(entity, "random.break", 1.0F, 0.5F);
}
 
Example 6
Project: BaseClient   File: ItemExpBottle.java   View Source Code Vote up 6 votes
/**
 * 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 EntityExpBottle(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 7
Project: minecraft-quiverbow   File: Seedling.java   View Source Code Vote up 6 votes
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	// Good to go (already verified)
	
	world.playSoundAtEntity(entity, "random.click", 0.6F, 0.7F);
	
	float spreadHor = world.rand.nextFloat() * 10 - 5;	// Spread
	float spreadVert = world.rand.nextFloat() * 10 - 5;
	
	Seed shot = new Seed(world, entity, (float) this.Speed, spreadHor, spreadVert);
	shot.damage = this.Dmg;
	
	world.spawnEntityInWorld(shot); 	// Firing
	
	if (this.consumeAmmo(stack, entity, 1)) { this.breakWeapon(world, stack, entity); }
}
 
Example 8
Project: DecompiledMinecraft   File: ItemPotion.java   View Source Code Vote up 6 votes
/**
 * 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 (isSplash(itemStackIn.getMetadata()))
    {
        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 EntityPotion(worldIn, playerIn, itemStackIn));
        }

        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
        return itemStackIn;
    }
    else
    {
        playerIn.setItemInUse(itemStackIn, this.getMaxItemUseDuration(itemStackIn));
        return itemStackIn;
    }
}
 
Example 9
Project: minecraft-quiverbow   File: RPG_Imp.java   View Source Code Vote up 6 votes
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	if (this.getCooldown(stack) > 0) { return; }	// Hasn't cooled down yet

	Helper.knockUserBack(entity, this.Kickback);			// Kickback

	// Firing
	BigRocket rocket = new BigRocket(world, entity, (float) this.Speed);	// Projectile Speed. Inaccuracy Hor/Vert
	rocket.explosionSize = this.ExplosionSize;
	rocket.dmgTerrain = this.dmgTerrain;

	world.spawnEntityInWorld(rocket); 		// shoom.

	// SFX
	world.playSoundAtEntity(entity, "fireworks.launch", 2.0F, 0.6F);

	this.consumeAmmo(stack, entity, 1);
	this.setCooldown(stack, 60);
}
 
Example 10
Project: DecompiledMinecraft   File: ItemExpBottle.java   View Source Code Vote up 6 votes
/**
 * 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 EntityExpBottle(worldIn, playerIn));
    }

    playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);
    return itemStackIn;
}
 
Example 11
Project: minecraft-quiverbow   File: SugarEngine.java   View Source Code Vote up 5 votes
private void doSpinSFX(ItemStack stack, World world, Entity player)
{
	// SFX
	int spin = stack.stackTagCompound.getInteger("spinning");

	float volume = 0.8F;
	float pitch = 1.8F;

	// Increasing in frequency as we spin up
	if (spin == 1) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }			// +4
	else if (spin == 5) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +4
	else if (spin == 9) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +4

	else if (spin == 13) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +3
	else if (spin == 16) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +3
	else if (spin == 19) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +3

	else if (spin == 21) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +2
	else if (spin == 23) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +2
	else if (spin == 25) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +2

	else if (spin == 27) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +1
	else if (spin == 28) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +1
	else if (spin == 29) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +1

	else if (spin >= 30) { world.playSoundAtEntity(player, "random.wood_click", volume, pitch); }	// +++
}
 
Example 12
Project: minecraft-quiverbow   File: SeedSweeper.java   View Source Code Vote up 5 votes
@Override
public void doSingleFire(ItemStack stack, World world, Entity entity)		// Server side
{
	if (this.getCooldown(stack) != 0) { return; }	// Hasn't cooled down yet

	// SFX
	world.playSoundAtEntity(entity, "random.break", 1.6F, 0.9F);

	this.setCooldown(stack, this.Cooldown);	// Cooling down now, no matter what

	int counter = 8;

	while (counter > 0 && this.getDamage(stack) < this.getMaxDamage())	// Keep firing until you have done so 8 times or run out of seeds
	{
		this.fireShot(world, entity);

		if (this.consumeAmmo(stack, entity, 1)) 	// We're done here
		{
			this.dropMagazine(world, stack, entity);
			return;
		}
		// else, still has ammo left. Continue.

		counter -= 1;
	}

	if (this.getDamage(stack) >= this.getMaxDamage()) { this.dropMagazine(world, stack, entity); }
}
 
Example 13
Project: connor41-etfuturum2   File: LingeringPotion.java   View Source Code Vote up 5 votes
@Override
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
	if (!player.capabilities.isCreativeMode)
		stack.stackSize--;

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

	if (!world.isRemote)
		world.spawnEntityInWorld(new EntityLingeringPotion(world, player, stack));

	return stack;
}
 
Example 14
Project: BaseClient   File: BlockTNT.java   View Source Code Vote up 5 votes
public void explode(World worldIn, BlockPos pos, IBlockState state, EntityLivingBase igniter)
{
    if (!worldIn.isRemote)
    {
        if (((Boolean)state.getValue(EXPLODE)).booleanValue())
        {
            EntityTNTPrimed entitytntprimed = new EntityTNTPrimed(worldIn, (double)((float)pos.getX() + 0.5F), (double)pos.getY(), (double)((float)pos.getZ() + 0.5F), igniter);
            worldIn.spawnEntityInWorld(entitytntprimed);
            worldIn.playSoundAtEntity(entitytntprimed, "game.tnt.primed", 1.0F, 1.0F);
        }
    }
}
 
Example 15
Project: minecraft-quiverbow   File: Seedling.java   View Source Code Vote up 5 votes
private void breakWeapon(World world, ItemStack stack, Entity entity)
{
	if (!(entity instanceof EntityPlayer)) // For QuiverMobs/Arms Assistants
	{
		this.setCooldown(stack, 40);
		return;
	}
	
	EntityPlayer player = (EntityPlayer) entity;
	
	player.renderBrokenItemStack(stack);
	player.destroyCurrentEquippedItem();	// Breaking
	stack.stackSize = 0;
	
	EntityItem piston = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.piston));
	piston.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(piston); }
	else { world.spawnEntityInWorld(piston); }
	
	EntityItem hook = new EntityItem(world, player.posX, player.posY + 1.0F, player.posZ, new ItemStack(Blocks.tripwire_hook));
	hook.delayBeforeCanPickup = 10;
	
	if (player.captureDrops) { player.capturedDrops.add(hook); }
	else { world.spawnEntityInWorld(hook); }
	
	world.playSoundAtEntity(player, "random.break", 1.0F, 1.5F);
}
 
Example 16
Project: minecraft-quiverbow   File: OWR.java   View Source Code Vote up 4 votes
@Override
void doCooldownSFX(World world, Entity entity)
{
	NetHelper.sendParticleMessageToAllPlayers(world, entity.getEntityId(), (byte) 11, (byte) 4);	// large smoke
	world.playSoundAtEntity(entity, "random.fizz", 1.0F, 1.2F);
}
 
Example 17
Project: DecompiledMinecraft   File: ItemBow.java   View Source Code Vote up 4 votes
/**
 * Called when the player stops using an Item (stops holding the right mouse button).
 */
public void onPlayerStoppedUsing(ItemStack stack, World worldIn, EntityPlayer playerIn, int timeLeft)
{
    boolean flag = playerIn.capabilities.isCreativeMode || EnchantmentHelper.getEnchantmentLevel(Enchantment.infinity.effectId, stack) > 0;

    if (flag || playerIn.inventory.hasItem(Items.arrow))
    {
        int i = this.getMaxItemUseDuration(stack) - timeLeft;
        float f = (float)i / 20.0F;
        f = (f * f + f * 2.0F) / 3.0F;

        if ((double)f < 0.1D)
        {
            return;
        }

        if (f > 1.0F)
        {
            f = 1.0F;
        }

        EntityArrow entityarrow = new EntityArrow(worldIn, playerIn, f * 2.0F);

        if (f == 1.0F)
        {
            entityarrow.setIsCritical(true);
        }

        int j = EnchantmentHelper.getEnchantmentLevel(Enchantment.power.effectId, stack);

        if (j > 0)
        {
            entityarrow.setDamage(entityarrow.getDamage() + (double)j * 0.5D + 0.5D);
        }

        int k = EnchantmentHelper.getEnchantmentLevel(Enchantment.punch.effectId, stack);

        if (k > 0)
        {
            entityarrow.setKnockbackStrength(k);
        }

        if (EnchantmentHelper.getEnchantmentLevel(Enchantment.flame.effectId, stack) > 0)
        {
            entityarrow.setFire(100);
        }

        stack.damageItem(1, playerIn);
        worldIn.playSoundAtEntity(playerIn, "random.bow", 1.0F, 1.0F / (itemRand.nextFloat() * 0.4F + 1.2F) + f * 0.5F);

        if (flag)
        {
            entityarrow.canBePickedUp = 2;
        }
        else
        {
            playerIn.inventory.consumeInventoryItem(Items.arrow);
        }

        playerIn.triggerAchievement(StatList.objectUseStats[Item.getIdFromItem(this)]);

        if (!worldIn.isRemote)
        {
            worldIn.spawnEntityInWorld(entityarrow);
        }
    }
}
 
Example 18
Project: minecraft-quiverbow   File: OSR.java   View Source Code Vote up 4 votes
@Override
void doCooldownSFX(World world, Entity entity)
{
	NetHelper.sendParticleMessageToAllPlayers(world, entity.getEntityId(), (byte) 3, (byte) 4);	// smoke
	world.playSoundAtEntity(entity, "random.fizz", 0.5F, 1.2F);
}
 
Example 19
Project: minecraft-quiverbow   File: Mortar_Dragon.java   View Source Code Vote up 4 votes
@Override
void doCooldownSFX(World world, Entity entity) // Server side
{
	world.playSoundAtEntity(entity, "random.click", 0.6F, 2.0F);
}
 
Example 20
Project: minecraft-quiverbow   File: ProximityNeedler.java   View Source Code Vote up 4 votes
@Override
void doCooldownSFX(World world, Entity entity)
{
	world.playSoundAtEntity(entity, "random.glass", 0.3F, 0.3F);
}