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.
Example 1
Project: minecraft-quiverbow   File: Potatosser.java   Source Code and License 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 2
Project: minecraft-quiverbow   File: LightningRed.java   Source Code and License 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 3
Project: minecraft-quiverbow   File: LapisCoil.java   Source Code and License 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 4
Project: BaseClient   File: ItemExpBottle.java   Source Code and License 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 5
Project: minecraft-quiverbow   File: Seedling.java   Source Code and License 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 6
Project: minecraft-quiverbow   File: RPG_Imp.java   Source Code and License 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 7
Project: minecraft-quiverbow   File: SugarEngine.java   Source Code and License 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 8
Project: minecraft-quiverbow   File: SeedSweeper.java   Source Code and License 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 9
Project: connor41-etfuturum2   File: LingeringPotion.java   Source Code and License 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 10
Project: BaseClient   File: BlockTNT.java   Source Code and License 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 11
Project: minecraft-quiverbow   File: Seedling.java   Source Code and License 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 12
Project: minecraft-quiverbow   File: OWR.java   Source Code and License 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 13
Project: minecraft-quiverbow   File: OSR.java   Source Code and License 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 14
Project: minecraft-quiverbow   File: Mortar_Dragon.java   Source Code and License Vote up 4 votes
@Override
void doCooldownSFX(World world, Entity entity) // Server side
{
	world.playSoundAtEntity(entity, "random.click", 0.6F, 2.0F);
}
 
Example 15
Project: minecraft-quiverbow   File: ProximityNeedler.java   Source Code and License Vote up 4 votes
@Override
void doCooldownSFX(World world, Entity entity)
{
	world.playSoundAtEntity(entity, "random.glass", 0.3F, 0.3F);
}