Integration

Easy Method

The easiest way to ensure the functionality of a self-developed jukebox with VinURL is to extend the standard jukebox.

public class CustomJukeBox extends JukeboxBlock{
public CustomJukeBox(Settings settings) {
super(settings);
}
// Your own Logic...
}

Advanced Method

This method should only be used if a separate entity class has been created for your use case, and therefore you implemented separate functions for starting and stopping jukebox sounds.

Setup

Add the following repository to your ../../build.gradle.

build.gradle
repositories {
maven { url 'https://api.modrinth.com/maven' }
}

Then the following dependency must be added in the ../../build.gradle to reference VinURL specific code. The version of VinURL needs to be declared in the ../../gradle.properties.

build.gradle
dependencies {
modCompileOnly "maven.modrinth:vinurl:${project.vinurl_version}"
}
gradle.properties
vinurl_version=...

Implementation

First declare a static variable to determine if VinURL is loaded

public static boolean isVinURLLoaded = FabricLoader.getInstance().isModLoaded("vinurl");

Import the VinURL API, which contains methods for playing and stopping custom sounds.

import com.vinurl.api.VinURLSound;

Positional Sounds

This method starts a positional custom sound for all players in a 64 block range from the specified blockPos.

public void startPlaying(){
// Your own Logic...
if (isVinURLLoaded) {
VinURLSound.playAt(serverLevel, itemStack, blockPos);
}
}

This method stops a positional custom sound at the specified blockPos for all players. If a custom sound is still downloading when this function is called, then the parameter cancelable is responsible for whether the active download is aborted or not.

public void stopPlaying(){
if (isVinURLLoaded) {
VinURLSound.stopAt(serverLevel, itemStack, blockPos, cancelable);
}
// Your own Logic...
}

Entity-Bound Sounds / Moving Sounds

This method starts a movable custom sound for all players in a 64 block range from the specified entity.

public void startPlaying(){
// Your own Logic...
if (isVinURLLoaded) {
VinURLSound.playFor(serverLevel, itemStack, entity);
}
}

This method stops a movable custom sound of the specified entity for all players. If a custom sound is still downloading when this function is called, then the parameter cancelable is responsible for whether the active download is aborted or not.

public void stopPlaying(){
if (isVinURLLoaded) {
VinURLSound.stopFor(serverLevel, itemStack, entity, cancelable);
}
// Your own Logic...
}