VinURL Music

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 Helper class from VinURL, which contains methods for playing and stopping VinURLDiscs

import com.vinurl.api.VinURLSound;

Add the following lines of code to the end of your method that is responsible for starting the music

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

and in the method that stops the music, add the following at the top

public void dropRecord(){
if (isVinURLLoaded) {
VinURLSound.stop(world, itemStack, blockPos);
}
// Your own Logic...
}