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


Java World.playSoundAtEntity方法代碼示例

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


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

示例1: onItemRightClick

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:21,代碼來源:ItemEgg.java

示例2: onItemRightClick

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:27,代碼來源:ItemFishingRod.java

示例3: doSingleFire

import net.minecraft.world.World; //導入方法依賴的package包/類
@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);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:24,代碼來源:Potatosser.java

示例4: dropMagazine

import net.minecraft.world.World; //導入方法依賴的package包/類
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);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:24,代碼來源:LightningRed.java

示例5: dropMagazine

import net.minecraft.world.World; //導入方法依賴的package包/類
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);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:24,代碼來源:LapisCoil.java

示例6: onItemRightClick

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * 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;
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:21,代碼來源:ItemExpBottle.java

示例7: doSingleFire

import net.minecraft.world.World; //導入方法依賴的package包/類
@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); }
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:18,代碼來源:Seedling.java

示例8: onItemRightClick

import net.minecraft.world.World; //導入方法依賴的package包/類
/**
 * 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;
    }
}
 
開發者ID:Notoh,項目名稱:DecompiledMinecraft,代碼行數:29,代碼來源:ItemPotion.java

示例9: doSingleFire

import net.minecraft.world.World; //導入方法依賴的package包/類
@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);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:21,代碼來源:RPG_Imp.java

示例10: doSpinSFX

import net.minecraft.world.World; //導入方法依賴的package包/類
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); }	// +++
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:28,代碼來源:SugarEngine.java

示例11: doSingleFire

import net.minecraft.world.World; //導入方法依賴的package包/類
@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); }
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:29,代碼來源:SeedSweeper.java

示例12: onItemRightClick

import net.minecraft.world.World; //導入方法依賴的package包/類
@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;
}
 
開發者ID:jm-organization,項目名稱:connor41-etfuturum2,代碼行數:13,代碼來源:LingeringPotion.java

示例13: explode

import net.minecraft.world.World; //導入方法依賴的package包/類
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);
        }
    }
}
 
開發者ID:SkidJava,項目名稱:BaseClient,代碼行數:13,代碼來源:BlockTNT.java

示例14: breakWeapon

import net.minecraft.world.World; //導入方法依賴的package包/類
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);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:29,代碼來源:Seedling.java

示例15: doCooldownSFX

import net.minecraft.world.World; //導入方法依賴的package包/類
@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);
}
 
開發者ID:Domochevsky,項目名稱:minecraft-quiverbow,代碼行數:7,代碼來源:OWR.java


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