本文整理汇总了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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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); }
}
示例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;
}
}
示例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);
}
示例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); } // +++
}
示例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); }
}
示例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;
}
示例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);
}
}
}
示例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);
}
示例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);
}