-
Notifications
You must be signed in to change notification settings - Fork 0
ReactiveMusicAPI
Packages:
circuitlord.reactivemusic.apicircuitlord.reactivemusic.api.audiocircuitlord.reactivemusic.api.eventsyscircuitlord.reactivemusic.api.songpack
A static, utility-style API for Reactive Music. It exposes global state (current song/entry, selection history) and access to the audio subsystem manager.
This class is final with a private constructor — it’s not intended to be instantiated or extended.
-
Package:
circuitlord.reactivemusic.api.songpackPath getPath()-
String getErrorString()- for custom parsing and logging.
-
List<RuntimeEntry> getEntries()
Meant to be used withReactiveMusicAPI.Songpack.getAvailable()for plugins that will utilize the songpack config for asset selection.
-
Package:
circuitlord.reactivemusic.api.songpackSongpackEvent get(String id)SongpackEvent register(String id)SongpackEvent[] values()
-
Map<String, ? extends SongpackEvent> getMap()
Returns the songpack event map for the client. This is already passed ingameTick()of the final plugin class loaded by the service loader, so you shouldn't need this unless you're doing something that cannot be handled there.
-
Package:
circuitlord.reactivemusic.api.eventsysString getEventId()PluginIdentifier getPluginId()
-
Package:
circuitlord.reactivemusic.api.eventsysString getNamespace()String getPath()-
String getId()- Returnsnamespace:path -
void setTitle()- For planned feature - plugin info.
-
Package:
circuitlord.reactivemusic.api.songpackString getSongpack()String getEventString()String getErrorString()-
List<String> getSongs()- returns the list of the entry's songs. -
boolean fallbackAllowed()- returns the value offallbackAllowedfor the entry. -
boolean shouldOverlay()- returns the value ofuseOverlayfor the entry. boolean shouldStopMusicOnValid()boolean shouldStopMusicOnInvalid()boolean shouldStartMusicOnValid()float getForceChanceList<RMEntryCondition> getConditions()-
boolean fallbackAllowed()- returns the value ofallowFallbackfor the entry. -
boolean shouldOverlay()- returns the value ofuseOverlayfor the entry.
-
Package:
circuitlord.reactivemusic.api.audio-
void setGainPercent(float p)void setFadePercent(float p)void setFadeTarget(float p)void setFadeDuration(float tickDuration)
-
float getGainPercent()float getFadePercent()float getFadeTarget()-
float getFadeStart()- returns thefloat pof the lastsetFadeTarget(float p)call. int getFadeDuration()
void clearFadeStart()-
float supplyComputedPercent- used internally in the player implementation.
-
-
Package:
circuitlord.reactivemusic.api.audio-
-
void play()- make sure to set the source before calling. void stop()
-
-
-
void setSong(String songId)
Will resolve to a file in themusicdirectory of the songpack. Accepts strings with or without"music/"and appends it to the start if not already included.
-
void setFile(String fileId)
Source setter that does not auto-append"music/"to the start. Useful for plugin developers who want to accept separate assets that are not music still within the songpack files.
-
void setStream(java.util.function.Supplier<java.io.InputStream> streamSupplier)
Advanced custom source - only use if you know what you are doing.
-
-
-
ConcurrentHashMap<String, GainSupplier> getGainSuppliers()- use.put()or.computeIfAbsent()to add a gain supplier. void requestGainRecompute()-
void fade(float target, int tickDuration)
Sets the fade target and duration values for the primary gain supplier (created by Reactive Music). Fading is handled by the Player Manager each tick.
void setMute(boolean v)
-
-
void setGroup(String group)String getGroup()
-
boolean isPlaying()-
boolean isIdle()- also checks if the player is queued to play.
-
boolean stopOnFadeOut()
Returns whether the manager will call.stop()once the fade percent has reached the target of0.
-
boolean resetOnFadeOut()
Returns whether the manager will call.reset()once the fade percent has reached the target of0.
float getRealGainDb()
-
⚠️ The following controls are also used internally on the built-in players, and will affect the flow of the core logic if called from there. Please try to use them only on players you create.stopOnFadeOut(boolean v)resetOnFadeOut(boolean v)
-
-
Package:
circuitlord.reactivemusic.api.audio⚠️ Unless you are doing something very complicated, you should not need to instance a new manager. Use the following controls from the main player manager.ReactivePlayer create(String id, ReactivePlayerOptions opts)ReactivePlayer get(String id)Collection<ReactivePlayer> getAll()Collection<ReactivePlayer> getByGroup(String group)void setGroupDuck(String group, float percent)float getGroupDuck(String group)void closeAllForPlugin(String pluginNamespace)void closeAll()
⚠️ This will only be needed if you instance a new manager. Currently, it handles setting the gain stage for fading.void tick()
-
Package:
circuitlord.reactivemusic.api.audioReactivePlayerOptions namespace(String ns)ReactivePlayerOptions group(String g)ReactivePlayerOptions loop(boolean v)ReactivePlayerOptions autostart(boolean v)ReactivePlayerOptions linkToMinecraftVolumes(boolean v)ReactivePlayerOptions quietWhenGamePaused(boolean v)ReactivePlayerOptions gainRefreshIntervalTicks(int ticks)
-
ReactivePlayerOptions gain(float pct)ReactivePlayerOptions duck(float pct)ReactivePlayerOptions fade(float pct)
Accessible through dot chaining.
ReactiveMusicAPI.ModConfigReactiveMusicAPI.EventSysReactiveMusicAPI.Songpack
Access configuration settings for the mod, which are set by the player via the UI provided by YetAnotherConfigLib.
static boolean debugModeEnabled()
Access values set by the core logic of the Event System.
- None yet - this interface will mainly be convenience functions for developers working with the event system in a more complex manner.
Access data of imported songpacks, and access values set by the built-in music switching logic.
static SongpackZip getCurrent()static List<SongpackZip> getAvailable()static RuntimeEntry currentEntry()static String currentSong()static List<String> recentSongs()static List<RuntimeEntry> validEntries()static List<RuntimeEntry> loadedEntries()static List<RuntimeEntry> previousValidEntries()
Returns the audio subsystem manager (backed by a singleton RMPlayerManager). Use this to create players, group them, control ducking, and enumerate active players via audio().getAll().
This is the built-in actions plugin. In init(), we register new events that can be declared in a songpack entry. During gameTick() we check if the player is doing something that would trigger the event, and if so we place a boolean into the value of the map under the event's key.
package circuitlord.reactivemusic.plugins;
import circuitlord.reactivemusic.api.*;
import circuitlord.reactivemusic.api.eventsys.EventRecord;
import circuitlord.reactivemusic.api.eventsys.songpack.SongpackEvent;
import net.minecraft.entity.Entity;
import net.minecraft.entity.passive.HorseEntity;
import net.minecraft.entity.passive.PigEntity;
import net.minecraft.entity.vehicle.BoatEntity;
import net.minecraft.entity.vehicle.MinecartEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.world.World;
import java.util.Map;
public final class ActionsPlugin extends ReactiveMusicPlugin {
public ActionsPlugin() {
super("reactivemusic", "actions");
}
private static EventRecord FISHING, MINECART, BOAT, HORSE, PIG;
@Override
public void init() {
registerSongpackEvents("FISHING","MINECART","BOAT","HORSE","PIG");
FISHING = SongpackEvent.get("FISHING");
MINECART = SongpackEvent.get("MINECART");
BOAT = SongpackEvent.get("BOAT");
HORSE = SongpackEvent.get("HORSEING");
PIG = SongpackEvent.get("PIG");
}
@Override
public void gameTick(PlayerEntity player, World world, Map<EventRecord, Boolean> eventMap) {
if (player == null) return;
eventMap.put(FISHING, player.fishHook != null);
Entity v = player.getVehicle();
eventMap.put(MINECART, v instanceof MinecartEntity);
eventMap.put(BOAT, v instanceof BoatEntity);
eventMap.put(HORSE, v instanceof HorseEntity);
eventMap.put(PIG, v instanceof PigEntity);
}
}Here, we are creating a new audio player for the built in Overlay Track feature, which uses the useOverlay option from the songpack config.
ReactiveMusicAPI.audioManager().create(
"reactive:overlay",
ReactivePlayerOptions.create()
.namespace("reactive")
.group("overlay")
.loop(false)
.gain(1.0f)
.fade(0f)
.quietWhenGamePaused(false)
.linkToMinecraftVolumes(true)
);Welcome to the wiki!
If you are new to modding and want to create a RM plugin click here.