Java Code Examples for net.minecraft.world.World#playSoundAtEntity()
The following examples show how to use
net.minecraft.world.World#playSoundAtEntity() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ItemSoilKit.java From GardenCollection with MIT License | 6 votes |
@Override public boolean onItemUse (ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if (player.inventory.getFirstEmptyStack() == -1 && player.inventory.getCurrentItem().stackSize > 1) return false; BiomeGenBase biome = world.getBiomeGenForCoords(x, z); int temperature = (int)(Math.min(1, Math.max(0, biome.temperature)) * 255) & 255; int rainfall = (int)(Math.min(1, Math.max(0, biome.rainfall)) * 255) & 255; ItemStack usedKit = new ItemStack(ModItems.usedSoilTestKit, 1, rainfall << 8 | temperature); world.playSoundAtEntity(player, "step.grass", 1.0f, 1.0f); if (player.inventory.getCurrentItem().stackSize == 1) player.inventory.setInventorySlotContents(player.inventory.currentItem, usedKit); else { stack.stackSize--; player.inventory.setInventorySlotContents(player.inventory.getFirstEmptyStack(), usedKit); } return true; }
Example 2
Source File: ItemBallOMoss.java From Chisel with GNU General Public License v2.0 | 6 votes |
@Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } if(par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if(!par2World.isRemote) { par2World.spawnEntityInWorld(new EntityBallOMoss(par2World, par3EntityPlayer)); } return par1ItemStack; }
Example 3
Source File: ItemSmashingRock.java From Chisel with GNU General Public License v2.0 | 6 votes |
@Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } if(par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if(!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySmashingRock(par2World, par3EntityPlayer)); } return par1ItemStack; }
Example 4
Source File: ItemCloudInABottle.java From Chisel with GNU General Public License v2.0 | 6 votes |
@Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if(!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } if(par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if(!par2World.isRemote) { par2World.spawnEntityInWorld(new EntityCloudInABottle(par2World, par3EntityPlayer)); } return par1ItemStack; }
Example 5
Source File: RedstoneEtherServerAddons.java From WirelessRedstone with MIT License | 6 votes |
public void throwREP(ItemStack itemstack, World world, EntityPlayer player) { AddonPlayerInfo info = getPlayerInfo(player); if (info.REPThrowTimeout > 0) { return; } if (!player.capabilities.isCreativeMode) { itemstack.stackSize--; } EntityREP activeREP = new EntityREP(world, player); world.spawnEntityInWorld(activeREP); WRAddonSPH.sendSpawnREP(activeREP); world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); info.activeREP = activeREP; info.REPThrowTimeout = 40; }
Example 6
Source File: ItemWirelessTracker.java From WirelessRedstone with MIT License | 6 votes |
@Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { if (player.isSneaking()) { return super.onItemRightClick(itemstack, world, player); } if (getItemFreq(itemstack) == 0) return itemstack; if (!player.capabilities.isCreativeMode) { itemstack.stackSize--; } if (!world.isRemote) { world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); EntityWirelessTracker tracker = new EntityWirelessTracker(world, getItemFreq(itemstack), player); world.spawnEntityInWorld(tracker); WRAddonSPH.sendThrowTracker(tracker, player); } return itemstack; }
Example 7
Source File: ItemVortexCannon.java From PneumaticCraft with GNU General Public License v3.0 | 6 votes |
/** * Called whenever this item is equipped and the right mouse button is * pressed. Args: itemStack, world, entityPlayer */ @Override public ItemStack onItemRightClick(ItemStack iStack, World world, EntityPlayer player){ if(iStack.getItemDamage() < getMaxDamage()) { double factor = 0.2D * getPressure(iStack); world.playSoundAtEntity(player, Sounds.CANNON_SOUND, 1.0F, 0.7F + (float)factor * 0.2F /* 1.0F */); EntityVortex vortex = new EntityVortex(world, player); vortex.motionX *= factor; vortex.motionY *= factor; vortex.motionZ *= factor; if(!world.isRemote) world.spawnEntityInWorld(vortex); iStack.setItemDamage(iStack.getItemDamage() + PneumaticValues.USAGE_VORTEX_CANNON); if(iStack.getItemDamage() > getMaxDamage()) { iStack.setItemDamage(getMaxDamage()); } } return iStack; }
Example 8
Source File: ItemArcanePackage.java From Gadomancy with GNU Lesser General Public License v3.0 | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) { if (!world.isRemote) { List<ItemStack> contents = getContents(stack); for (ItemStack content : contents) { world.spawnEntityInWorld(new EntityItem(world, player.posX, player.posY, player.posZ, content)); } world.playSoundAtEntity(player, "thaumcraft:coins", 0.75F, 1.0F); } stack.stackSize -= 1; return stack; }
Example 9
Source File: LingeringPotion.java From Et-Futurum with The Unlicense | 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
Source File: ItemBallOMoss.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } if (par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntityBallOMoss(par2World, par3EntityPlayer)); } return par1ItemStack; }
Example 11
Source File: ItemSmashingRock.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } if (par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntitySmashingRock(par2World, par3EntityPlayer)); } return par1ItemStack; }
Example 12
Source File: ItemCloudInABottle.java From Chisel-2 with GNU General Public License v2.0 | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack par1ItemStack, World par2World, EntityPlayer par3EntityPlayer) { if (!par3EntityPlayer.capabilities.isCreativeMode) { --par1ItemStack.stackSize; } if (par2World.isRemote) par2World.playSoundAtEntity(par3EntityPlayer, "random.bow", 0.5F, 0.4F / (itemRand.nextFloat() * 0.4F + 0.8F)); if (!par2World.isRemote) { par2World.spawnEntityInWorld(new EntityCloudInABottle(par2World, par3EntityPlayer)); } return par1ItemStack; }
Example 13
Source File: BlockLargePotStandard.java From GardenCollection with MIT License | 5 votes |
@Override protected boolean applySubstrateToGarden (World world, int x, int y, int z, EntityPlayer player, int slot, ItemStack itemStack) { if (world.getBlockMetadata(x, y, z) == 1) { world.setBlockToAir(x, y, z); world.playSoundAtEntity(player, "dig.sand", 1.0f, 1.0f); for (int i = 0; i < 4; i++) dropBlockAsItem(world, x, y, z, new ItemStack(Items.clay_ball)); return true; } return super.applySubstrateToGarden(world, x, y, z, player, slot, itemStack); }
Example 14
Source File: RedstoneEtherClientAddons.java From WirelessRedstone with MIT License | 5 votes |
public void throwREP(ItemStack itemstack, World world, EntityPlayer player) { if (REPThrowTimeout > 0) { return; } if (!player.capabilities.isCreativeMode) { itemstack.stackSize--; } world.playSoundAtEntity(player, "random.bow", 0.5F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F)); activeREP = new EntityREP(world, player); world.spawnEntityInWorld(activeREP); REPThrowTimeout = 40; }
Example 15
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
public static void playCustomSound(Entity entity, String customSound, World worldObj) { worldObj.playSoundAtEntity(entity, customSound, 1.0F, 1.0F + ((worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F)); }
Example 16
Source File: MoCTools.java From mocreaturesdev with GNU General Public License v3.0 | 4 votes |
public static void playCustomSound(Entity entity, String customSound, World worldObj, float volume) { worldObj.playSoundAtEntity(entity, customSound, volume, 1.0F + ((worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F)); }