PHP code example of diamondstrider1 / sounds

1. Go to this page and download the library: Download diamondstrider1/sounds library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

diamondstrider1 / sounds example snippets


use DiamondStrider1\Sounds\VanillaSounds;

$sound = VanillaSounds::NOTE_BELL();
$sound->setVolume(2);
$sound->setPitch(2);
$currentVolume = $sound->getVolume();
$currentPitch = $sound->getPitch();
$world->addSound($position, $sound, $players);

use DiamondStrider1\Sounds\SoundFactory;

$sound = SoundFactory::create("my.custom.sound", volume: 1, pitch: 1);
$world->addSound($position, $sound, $players);

$anotherSound = SoundFactory::create("my.custom.sound2");
$anotherSound->setVolume(2);
$world->addSound($position, $anotherSound, $players);

use DiamondStrider1\Sounds\SoundIds;
use DiamondStrider1\Sounds\SoundFactory;

$pigStep = SoundIds::MOB_PIG_STEP
$pigStepSound = SoundFactory::create($pigStep);
// Not my favorite pig step, but let's play it anyways!
$world->addSound($position, $pigStepSound, $players);