Java Code Examples for net.minecraft.world.World#playSoundEffect()
The following examples show how to use
net.minecraft.world.World#playSoundEffect() .
These examples are extracted from open source projects.
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 Project: Et-Futurum File: GrassPath.java License: The Unlicense | 6 votes |
public static void onPlayerInteract(PlayerInteractEvent event) { if (EtFuturum.enableGrassPath) if (event.entityPlayer != null) { World world = event.entityPlayer.worldObj; if (event.action == Action.RIGHT_CLICK_BLOCK) if (world.getBlock(event.x, event.y, event.z) == Blocks.grass) { ItemStack stack = event.entityPlayer.getCurrentEquippedItem(); if (stack != null && (stack.getItem() instanceof ItemSpade || isTinkersShovel(stack))) { world.setBlock(event.x, event.y, event.z, ModBlocks.grass_path); event.entityPlayer.swingItem(); stack.damageItem(1, event.entityPlayer); world.playSoundEffect(event.x + 0.5F, event.y + 0.5F, event.z + 0.5F, Block.soundTypeGravel.getStepResourcePath(), 1.0F, 0.8F); } } } }
Example 2
Source Project: Et-Futurum File: ItemGenericSlab.java License: The Unlicense | 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 (stack.stackSize == 0) return false; else if (!player.canPlayerEdit(x, y, z, side, stack)) return false; else { Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); boolean flag = meta == 1; if (block == field_150939_a && (side == 1 && !flag || side == 0 && flag)) { if (world.checkNoEntityCollision(field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlock(x, y, z, field_150939_a, 2, 3)) { world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F); stack.stackSize--; } return true; } else return func_150946_a(stack, player, world, x, y, z, side) ? true : super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); } }
Example 3
Source Project: GardenCollection File: BlockDecorativePot.java License: MIT License | 6 votes |
@Override protected boolean applyItemToGarden (World world, int x, int y, int z, EntityPlayer player, ItemStack itemStack, float hitX, float hitY, float hitZ, boolean hitValid) { ItemStack item = (itemStack == null) ? player.inventory.getCurrentItem() : itemStack; if (item != null && item.getItem() == Items.flint_and_steel) { ItemStack substrate = getGardenSubstrate(world, x, y, z, Slot2Profile.SLOT_CENTER); if (substrate != null && substrate.getItem() == Item.getItemFromBlock(Blocks.netherrack)) { if (world.isAirBlock(x, y + 1, z)) { world.playSoundEffect(x + .5, y + .5, z + .5, "fire.ignite", 1, world.rand.nextFloat() * .4f + .8f); world.setBlock(x, y + 1, z, ModBlocks.smallFire); world.notifyBlocksOfNeighborChange(x, y, z, this); world.notifyBlocksOfNeighborChange(x, y - 1, z, this); } item.damageItem(1, player); return true; } } return super.applyItemToGarden(world, x, y, z, player, itemStack, hitX, hitY, hitZ, hitValid); }
Example 4
Source Project: GardenCollection File: BlockLargePot.java License: MIT License | 6 votes |
protected boolean applyHoeToSubstrate (World world, int x, int y, int z, TileEntityGarden tile, EntityPlayer player) { Block substrate = Block.getBlockFromItem(tile.getSubstrate().getItem()); if (substrate == Blocks.dirt || substrate == Blocks.grass) tile.setSubstrate(new ItemStack(Blocks.farmland, 1, 7), new ItemStack(Blocks.dirt, 1, tile.getSubstrate().getItemDamage())); else if (substrate == ModBlocks.gardenSoil) tile.setSubstrate(new ItemStack(ModBlocks.gardenFarmland), new ItemStack(ModBlocks.gardenSoil)); else return false; tile.markDirty(); world.markBlockForUpdate(x, y, z); world.playSoundEffect(x + .5f, y + .5f, z + .5f, Blocks.farmland.stepSound.getStepResourcePath(), (Blocks.farmland.stepSound.getVolume() + 1) / 2f, Blocks.farmland.stepSound.getPitch() * .8f); return true; }
Example 5
Source Project: Electro-Magic-Tools File: ItemStreamChainsaw.java License: GNU General Public License v3.0 | 6 votes |
@Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int par7, float par8, float par9, float par10) { Block bi = world.getBlock(x, y, z); if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) { if (!world.isRemote) { if (BlockUtils.breakFurthestBlock(world, x, y, z, bi, player)) { world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F); ElectricItem.manager.use(itemstack, cost, player); this.alternateServer = (!this.alternateServer); } } else { player.swingItem(); ElectricItem.manager.use(itemstack, cost, player); this.alternateClient = (!this.alternateClient); } } return super.onItemUse(itemstack, player, world, x, y, z, par7, par8, par9, par10); }
Example 6
Source Project: Electro-Magic-Tools File: ItemStreamChainsaw.java License: GNU General Public License v3.0 | 6 votes |
@Override public boolean onBlockStartBreak(ItemStack itemstack, int x, int y, int z, EntityPlayer player) { World world = player.worldObj; Block bi = world.getBlock(x, y, z); if ((!player.isSneaking()) && (Utils.isWoodLog(world, x, y, z))) { if (!world.isRemote) { BlockUtils.breakFurthestBlock(world, x, y, z, bi, player); PacketHandler.INSTANCE.sendToAllAround(new PacketFXBlockBubble(x, y, z, new Color(0.33F, 0.33F, 1.0F).getRGB()), new NetworkRegistry.TargetPoint(world.provider.dimensionId, x, y, z, 32.0D)); world.playSoundEffect(x, y, z, "thaumcraft:bubble", 0.15F, 1.0F); } ElectricItem.manager.use(itemstack, cost, player); return true; } return super.onBlockStartBreak(itemstack, x, y, z, player); }
Example 7
Source Project: Artifacts File: ItemStructureGenerator.java License: MIT License | 5 votes |
public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if(!player.capabilities.isCreativeMode) { is.stackSize--; } //System.out.println("Placing Structure!"); if(is != null && is.stackTagCompound != null) { String type = is.stackTagCompound.getString("Type"); if(type.equals("Tier1Tower")) { StructureApprenticeTower.build(world, new Random(), x-3, y-2, z+1); } if(type.equals("Tier1TowerAncient")) { StructureApprenticeTowerAncient.build(world, new Random(), x-3, y-2, z+1); } if(type.equals("Tier2Tower")) { StructureJourneymanTower.build(world, new Random(), x-3, y, z+1); } if(type.equals("Tier2TowerAncient")) { StructureJourneymanTowerAncient.build(world, new Random(), x-3, y, z+1); } if(type.equals("Tier3Tower")) { StructureMasterTower.build(world, new Random(), x-3, y-2, z+1); } if(type.equals("Tier3TowerAncient")) { StructureMasterTowerAncient.build(world, new Random(), x-3, y-2, z+1); } world.playSoundEffect((double)x + 0.5, (double)y + 0.5, (double)z + 0.5, "portal.trigger", 1.0f, 1.0f); return true; } return false; }
Example 8
Source Project: ForbiddenMagic File: ItemTaintShovel.java License: Do What The F*ck You Want To Public License | 5 votes |
@Override public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { int purified = 0; for(int ex = x - 5;ex < x + 6;ex++){ for(int wy = y - 4;wy < y + 5;wy++){ for(int zee = z - 5;zee < z + 6;zee++){ Block target = world.getBlock(ex, wy, zee); if(target != null && (target == ConfigBlocks.blockFluxGoo || target == ConfigBlocks.blockFluxGas)){ purified++; world.setBlockToAir(ex, wy, zee); float d1 = ((float) ex + world.rand.nextFloat()); float d2 = ((float) wy + world.rand.nextFloat()); float d0 = ((float) zee + world.rand.nextFloat()); Thaumcraft.proxy.nodeBolt(world, (float)player.posX, (float)player.posY, (float)player.posZ, d1, d2, d0); } } } } if(purified > 0){ itemstack.damageItem(Math.min(purified, 15), player); player.swingItem(); world.playSoundEffect((double)x + 0.5D, (double)y + 0.5D, (double)z + 0.5D, "thaumcraft:wandfail", 0.2F, 0.2F + world.rand.nextFloat() * 0.2F); return true; } else return super.onItemUse(itemstack, player, world, x, y, z, side, par8, par9, par10); }
Example 9
Source Project: Et-Futurum File: ItemGenericSlab.java License: The Unlicense | 5 votes |
private boolean func_150946_a(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) { if (side == 0) y--; if (side == 1) y++; if (side == 2) z--; if (side == 3) z++; if (side == 4) x--; if (side == 5) x++; Block block = world.getBlock(x, y, z); int meta = world.getBlockMetadata(x, y, z); if (block == field_150939_a && meta != 2) { if (world.checkNoEntityCollision(field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z)) && world.setBlockMetadataWithNotify(x, y, z, 2, 3)) { world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F); stack.stackSize--; } return true; } else return false; }
Example 10
Source Project: Chisel-2 File: ItemBlockChiselTorchPart.java License: GNU General Public License v2.0 | 5 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) { Block block = world.getBlock(x, y, z); BlockCoord pos = new BlockCoord(x, y, z); if (!block.isReplaceable(world, x, y, z)) { pos = new BlockCoord(x, y, z).offset(side); } if (placePart(world, pos, stack, side, !world.isRemote)) { world.playSoundEffect(pos.x + 0.5F, pos.y + 0.5F, pos.z + 0.5F, field_150939_a.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); stack.stackSize -= 1; return true; } return super.onItemUse(stack, player, world, x, y, z, side, hitX, hitY, hitZ); }
Example 11
Source Project: Translocators File: ItemTranslocator.java License: MIT License | 5 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) { Block block = world.getBlock(x, y, z); if (block == Blocks.snow_layer && (world.getBlockMetadata(x, y, z) & 7) < 1) { side = 1; } else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush && !block.isReplaceable(world, x, y, z)) { if (side == 0) --y; if (side == 1) ++y; if (side == 2) --z; if (side == 3) ++z; if (side == 4) --x; if (side == 5) ++x; } if (stack.stackSize == 0 || !player.canPlayerEdit(x, y, z, side, stack)) return false; if (placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, stack.getItemDamage())) { world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, field_150939_a.stepSound.func_150496_b(), (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, field_150939_a.stepSound.getPitch() * 0.8F); --stack.stackSize; return true; } return false; }
Example 12
Source Project: Artifacts File: BlockPedestal.java License: MIT License | 5 votes |
@Override public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int par6, float par7, float par8, float par9) { //Don't activate the block if the player is holding a key if(player.getHeldItem() != null && player.getHeldItem().getItem() == ItemPedestalKey.pedestalKeyItem) { return false; } world.playSoundEffect((double)x + 0.5, (double)y + 0.5, (double)z + 0.5, "random.door_open", 1.0f, 1.2f); if (world.isRemote) { TileEntity te = world.getTileEntity(x, y, z); if(te instanceof TileEntityDisplayPedestal) { String ownerName = ((TileEntityDisplayPedestal) te).ownerName; if(ownerName != null && !ownerName.equals("") && !ownerName.equals(player.getCommandSenderName())) { Minecraft.getMinecraft().ingameGUI.func_110326_a(StatCollector.translateToLocal("misc.Owned by:") + " " + ownerName, false); } } return true; } else { player.openGui(DragonArtifacts.instance, 0, world, x, y, z); return true; } }
Example 13
Source Project: ForbiddenMagic File: ItemDivineOrb.java License: Do What The F*ck You Want To Public License | 5 votes |
@Override public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) { if (!Compat.bm) return itemstack; SoulNetworkHandler.checkAndSetItemOwner(itemstack, player); if (world != null) { double posX = player.posX; double posY = player.posY; double posZ = player.posZ; world.playSoundEffect((double) ((float) posX + 0.5F), (double) ((float) posY + 0.5F), (double) ((float) posZ + 0.5F), "random.fizz", 0.5F, 2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F); } if (world.isRemote) { return itemstack; } NBTTagCompound itemTag = itemstack.stackTagCompound; if (itemTag == null || itemTag.getString("ownerName").equals("")) { return itemstack; } if(itemTag.getString("ownerName").equals(SoulNetworkHandler.getUsername(player))) { SoulNetworkHandler.setMaxOrbToMax(itemTag.getString("ownerName"), 6); } SoulNetworkHandler.addCurrentEssenceToMaximum(itemTag.getString("ownerName"), 200, 700000000); hurtPlayer(player, 200); return itemstack; }
Example 14
Source Project: Gadomancy File: ItemExtendedNodeJar.java License: GNU Lesser General Public License v3.0 | 4 votes |
public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10) { Block var11 = world.getBlock(x, y, z); if (var11 == Blocks.snow_layer) { side = 1; } else if ((var11 != Blocks.vine) && (var11 != Blocks.tallgrass) && (var11 != Blocks.deadbush) && ((var11.isAir(world, x, y, z)) || (!var11.isReplaceable(world, x, y, z)))) { if (side == 0) { y--; } if (side == 1) { y++; } if (side == 2) { z--; } if (side == 3) { z++; } if (side == 4) { x--; } if (side == 5) { x++; } } if (stack.stackSize == 0) { return false; } if (!player.canPlayerEdit(x, y, z, side, stack)) { return false; } if ((y == 255) && (RegisteredBlocks.blockExtendedNodeJar.getMaterial().isSolid())) { return false; } if (world.canPlaceEntityOnSide(RegisteredBlocks.blockExtendedNodeJar, x, y, z, false, side, player, stack)) { Block var12 = RegisteredBlocks.blockExtendedNodeJar; int var13 = 2; int var14 = RegisteredBlocks.blockExtendedNodeJar.onBlockPlaced(world, x, y, z, side, par8, par9, par10, var13); if (placeBlockAt(stack, player, world, x, y, z, side, par8, par9, par10, var14)) { TileEntity te = world.getTileEntity(x, y, z); if ((te != null) && ((te instanceof TileExtendedNodeJar))) { if (stack.hasTagCompound()) { AspectList aspects = getAspects(stack); if (aspects != null) { ((TileExtendedNodeJar) te).setAspects(aspects); ((TileExtendedNodeJar) te).setNodeType(getNodeType(stack)); ((TileExtendedNodeJar) te).setNodeModifier(getNodeModifier(stack)); ((TileExtendedNodeJar) te).setExtendedNodeType(getExtendedNodeType(stack)); ((TileExtendedNodeJar) te).setId(getNodeId(stack)); ((TileExtendedNodeJar) te).setBehaviorSnapshot(getBehaviorSnapshot(stack)); } } } world.playSoundEffect(x + 0.5F, y + 0.5F, z + 0.5F, var12.stepSound.getStepResourcePath(), (var12.stepSound.getVolume() + 1.0F) / 2.0F, var12.stepSound.getPitch() * 0.8F); stack.stackSize -= 1; } return true; } return false; }
Example 15
Source Project: NEI-Integration File: RailTools.java License: MIT License | 4 votes |
/** * Attempts to place a rail of the type provided. There is no need to verify * that the ItemStack contains a valid rail prior to calling this function. * * The function takes care of that and will return false if the ItemStack is * not a valid ITrackItem or an ItemBlock who's id will return true when * passed to BlockRailBase.isRailBlock(itemID). * * That means this function can place any Railcraft or vanilla rail and has * at least a decent chance of being able to place most third party rails. * * @param stack The ItemStack containing the rail * @param world The World object * @param i x-Coord * @param j y-Coord * @param k z-Coord * @return true if successful * @see ITrackItem */ public static boolean placeRailAt(ItemStack stack, World world, int i, int j, int k) { if (stack == null) return false; if (stack.getItem() instanceof ITrackItem) return ((ITrackItem) stack.getItem()).placeTrack(stack.copy(), world, i, j, k); if (stack.getItem() instanceof ItemBlock) { Block block = ((ItemBlock) stack.getItem()).field_150939_a; if (BlockRailBase.func_150051_a(block)) { boolean success = world.setBlock(i, j, k, block); if (success) world.playSoundEffect((float) i + 0.5F, (float) j + 0.5F, (float) k + 0.5F, block.stepSound.func_150496_b(), (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); return success; } } return false; }
Example 16
Source Project: ForbiddenMagic File: ItemArcaneCake.java License: Do What The F*ck You Want To Public License | 4 votes |
@Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World yWorld, int z, int par5, int par6, int par7, float par8, float par9, float par10) { Block block = yWorld.getBlock(z, par5, par6); if (block == Blocks.snow_layer && (yWorld.getBlockMetadata(z, par5, par6) & 7) < 1) { par7 = 1; } else if (block != Blocks.vine && block != Blocks.tallgrass && block != Blocks.deadbush) { if (par7 == 0) { --par5; } if (par7 == 1) { ++par5; } if (par7 == 2) { --par6; } if (par7 == 3) { ++par6; } if (par7 == 4) { --z; } if (par7 == 5) { ++z; } } if (!player.canPlayerEdit(z, par5, par6, par7, stack)) { return false; } else if (stack.stackSize == 0) { return false; } else { Block cake = ForbiddenBlocks.arcaneCake; if (yWorld.canPlaceEntityOnSide(cake, z, par5, par6, false, par7, (Entity) null, stack)) { int j1 = cake.onBlockPlaced(yWorld, z, par5, par6, par7, par8, par9, par10, 0); if (yWorld.setBlock(z, par5, par6, cake, j1, 3)) { if (yWorld.getBlock(z, par5, par6) == cake) { cake.onBlockPlacedBy(yWorld, z, par5, par6, player, stack); cake.onPostBlockPlaced(yWorld, z, par5, par6, j1); } yWorld.playSoundEffect((double) ((float) z + 0.5F), (double) ((float) par5 + 0.5F), (double) ((float) par6 + 0.5F), block.stepSound.soundName, (block.stepSound.getVolume() + 1.0F) / 2.0F, block.stepSound.getPitch() * 0.8F); --stack.stackSize; } } return true; } }
Example 17
Source Project: Chisel-2 File: ItemCarvableSlab.java License: GNU General Public License v2.0 | 4 votes |
private void place(ItemStack stack, World world, int x, int y, int z, Block toPlace, int metadata) { world.setBlock(x, y, z, toPlace, metadata, 2); stack.stackSize -= 1; world.playSoundEffect(x + 0.5f, y + 0.5f, z + 0.5f, this.field_150939_a.stepSound.func_150496_b(), (this.field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F, this.field_150939_a.stepSound.getPitch() * 0.8F); }
Example 18
Source Project: GardenCollection File: BlockGardenSoil.java License: MIT License | 4 votes |
public void convertToFarm (World world, int x, int y, int z) { world.playSoundEffect(x + .5, y + .5, z + .5, stepSound.getStepResourcePath(), (stepSound.getVolume() + 1) / 2, stepSound.getPitch() * .8f); if (!world.isRemote) world.setBlock(x, y, z, ModBlocks.gardenFarmland); }
Example 19
Source Project: Electro-Magic-Tools File: ItemRockbreakerDrill.java License: GNU General Public License v3.0 | 4 votes |
@SuppressWarnings("unused") @Override public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float xOffset, float yOffset, float zOffset) { if (!player.isSneaking()) { for (int i = 0; i < player.inventory.mainInventory.length; i++) { ItemStack torchStack = player.inventory.mainInventory[i]; if (torchStack == null || !torchStack.getUnlocalizedName().toLowerCase().contains("torch")) { continue; } Item item = torchStack.getItem(); if (!(item instanceof ItemBlock)) { continue; } int oldMeta = torchStack.getItemDamage(); int oldSize = torchStack.stackSize; boolean result = torchStack.tryPlaceItemIntoWorld(player, world, x, y, z, side, xOffset, yOffset, zOffset); if (player.capabilities.isCreativeMode) { torchStack.setItemDamage(oldMeta); torchStack.stackSize = oldSize; } else if (torchStack.stackSize <= 0) { ForgeEventFactory.onPlayerDestroyItem(player, torchStack); player.inventory.mainInventory[i] = null; } if (result) { return true; } } } else { ElectricItem.manager.use(stack, searchCost, player); if (!world.isRemote) { world.playSoundEffect(x + 0.5D, y + 0.5D, z + 0.5D, "thaumcraft:wandfail", 0.2F, 0.2F + world.rand.nextFloat() * 0.2F); return super.onItemUse(stack, player, world, x, y, z, side, xOffset, xOffset, zOffset); } Minecraft mc = Minecraft.getMinecraft(); Thaumcraft.instance.renderEventHandler.startScan(player, x, y, z, System.currentTimeMillis() + 5000L); player.swingItem(); return super.onItemUse(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); } return super.onItemUse(stack, player, world, x, y, z, side, xOffset, yOffset, zOffset); }
Example 20
Source Project: Artifacts File: ItemPedestalKey.java License: MIT License | 3 votes |
public boolean onItemUse(ItemStack is, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ) { if(is != null) { TileEntity te = world.getTileEntity(x, y, z); if(te != null && te instanceof TileEntityDisplayPedestal) { TileEntityDisplayPedestal ted = (TileEntityDisplayPedestal) te; if( (ted.ownerName == null || ted.ownerName.equals("")) && (ted.ownerUUID == null || ted.ownerUUID.equals(new UUID(0, 0))) ) { return false; } ted.ownerUUID = new UUID(0, 0); ted.ownerName = ""; if(!player.capabilities.isCreativeMode) { is.stackSize--; } world.playSoundEffect((double)x + 0.5, (double)y + 0.5, (double)z + 0.5, "random.door_close", 1.0f, 1.5f); return true; } } return false; }