crap

make a mod that plays specific songs on specific events;

  1. title screen is bromeliad
  2. when the create world button is pressed, play echo in the wind
  3. also have echo in the wind randomly play in the end dimension other than the "the end" song
  4. randomly play puzzlebox in the nether
  5. other than echo in the wind, randomly play puzzlebox in the end too.
  6. play below and above after the ender dragon is killed

this should be fully client side, for fabric and neoforge, use the games own song files, and also be inintrusive; it should wait until the song thats currently playing to stop, and it shouldnt play songs while a jukebox is playing a song and the player is in a 96 block radius of it.

should have mod menu support with the attached icon, name should be "Songularity" in mod menu and stuff, etc.

1 image attached
Kodari AI
KodariOct 2 at 2:59 pm 5
Songularity
A fully client-side Fabric and NeoForge mod that dynamically plays specific game music tracks on specific events. It plays "Bromeliad" on the title screen, "Echo in the Wind" when creating a world, randomly plays "Echo in the Wind" and "Puzzlebox" in the End dimension, randomly plays "Puzzlebox" in the Nether, and plays "Below and Above" after defeating the Ender Dragon. It is non-intrusive: it waits for the current song to finish before switching, and never plays while a jukebox is active within a 96-block radius of the player. Includes Mod Menu support with the provided icon and the name "Songularity".
  1. Build the Fabric 26.2 client mod around vanilla music playback, event hooks, and jukebox-range suppression.

  2. Set the Songularity metadata and include its Mod Menu presentation.

  3. Add a NeoForge variant only where the available 26.2 APIs/build setup can be verified.

Created the Fabric 26.2 client-only Songularity project. It requests Bromeliad on the title screen, Echo in the Wind after Create World is pressed, random Echo/Puzzlebox tracks in the End, Puzzlebox in the Nether, and Below and Above after detecting the dragon’s death. Playback uses the vanilla music manager so a current track can finish first; custom playback is suppressed near an active jukebox within 96 blocks. The mod metadata name is Songularity, which Mod Menu can display.

This is Fabric-only, not NeoForge: the available project support and 26.2 source cover Fabric, so I couldn’t verify or add a NeoForge build. The mounted source also lacks vanilla sound asset metadata, so the mod searches loaded music.game entries for names matching the requested tracks; if a name doesn’t match an asset path, vanilla’s random selection remains. I couldn’t package the attached image as an icon file, so no icon is configured.

crap

look for and fix bugs and inefficiencies in the code

Kodari AI
KodariOct 2 at 3:08 pm 3

Fixed the identified playback bugs in Songularity:

  • Nearby jukeboxes now suppress vanilla as well as custom music, and stop any active background track. Removed a duplicate jukebox check and skip chunks outside the 96-block scan radius.

  • Nether and End tracks are now occasional additions to vanilla music rather than replacing it continuously. Existing songs can finish first, and End dragon music is preserved.

  • If a requested song can’t be found, the mod now plays silence instead of mistakenly treating a different song as the requested one. It also avoids scanning the weighted sound list when the selected song already matches.

  • A pending “Below and Above” request is cleared when the client changes levels before it starts.

crap

the mod is kinda buggy and the icon doesnt show up in mod menu. also add a description for mod menu: "Makes some songs play based on the dimension and the mood! Kinda!" fix some extra bugs and optimize more and, using the cloth config api, add a config accessible through mod menu that lets you disable or enable the extra random songs and/or set a keybind for disabling the songs! by pressing the keybinds, the mod will stop adding the designated songs to the queue, but songs will work as normal.

OPTIMIZEEEEEEEEEEE PLSSSSSSSSSSSSSSSSSS

Kodari AI
KodariOct 2 at 5:17 pm 5
  1. Fix Mod Menu icon and add the requested description.

  2. Add Cloth Config settings and a toggle keybind, then tighten playback behavior and performance.

  • Added a Mod Menu settings screen using Cloth Config: toggle all Songularity songs, toggle the extra random dimension songs, and edit the song-toggle keybind. Settings persist; the default key is K.

  • Disabling songs cancels pending custom tracks but lets a track already playing finish. Vanilla music selection continues normally.

  • Fixed custom tracks preempting active music and jukebox detection suppressing vanilla music. Reduced repeated work by avoiding regex allocation during track matching and scanning for dragons and nearby jukeboxes every 10 ticks.

  • Added the requested Mod Menu description and wired the icon resource into the mod metadata.

The attached artwork wasn’t available as a project image file, so I generated a fallback music-note icon. Upload the artwork as a file if you want that exact image used.

crap

make it more robust and optimized. then make the mod play: -a familiar room when the player is in a cave or a close space -dead voxel after a mob is killed -warmth when the player is in a 16 block radius of an item that emits light (excluding mushrooms) -left to bloom when the player places a flower -o's piano when the player places a note block -yakusoku at nighttime if the player is within 256 blocks of an ocean all of these should play after the current song, but only if the requirements are still met.

1 image attached
Kodari AI
KodariOct 16 at 9:40 am 9
  1. Audit and harden the existing playback/config logic, fixing concrete bugs and avoidable work.

  2. Add the five situation-triggered songs with deferred playback and rechecking conditions before they start.

Added all six situational tracks. They queue without interrupting the current song, then their conditions are checked again before playback: cave/covered Overworld for A Familiar Room, a nearby mob death for Dead Voxel, a dropped light-emitting block item within 16 blocks for Warmth (excluding red and brown mushrooms), a successfully placed flower for Left to Bloom, a successfully placed note block for O’s Piano, and nighttime within 256 blocks of an ocean for Yakusoku.

Also hardened playback: if a requested track isn’t found, normal music continues instead of starting silence; track matching handles underscores and hyphens. Environmental checks are throttled, and ocean and placement checks avoid loading chunks.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
manifest.kod
settings.gradle
Code
16 1,016
src/client/java/com/songularity/SongularityClient.java
package com.songularity;

import java.util.ArrayDeque;
import java.util.Iterator;
import java.util.Map;
import java.util.concurrent.ThreadLocalRandom;

import com.songularity.mixin.MusicManagerAccessor;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.event.player.UseBlockCallback;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.client.multiplayer.ClientLevel;
import net.minecraft.client.resources.sounds.SoundInstance;
import net.minecraft.client.sounds.MusicManager;
import net.minecraft.core.BlockPos;
import net.minecraft.tags.BiomeTags;
import net.minecraft.tags.BlockTags;
import net.minecraft.sounds.Music;
import net.minecraft.sounds.SoundEvents;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.entity.boss.enderdragon.EnderDragon;
import net.minecraft.world.entity.boss.enderdragon.phases.EnderDragonPhase;
import net.minecraft.world.entity.item.ItemEntity;
import net.minecraft.world.entity.LivingEntity;
import net.minecraft.world.entity.Mob;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.Level;
import net.minecraft.world.level.block.entity.BlockEntity;
import net.minecraft.world.level.block.entity.JukeboxBlockEntity;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.chunk.LevelChunk;
import net.minecraft.world.level.chunk.status.ChunkStatus;
import net.minecraft.world.phys.AABB;
import net.minecraft.world.phys.BlockHitResult;
import net.minecraft.world.InteractionResult;

public class SongularityClient implements ClientModInitializer {
	private static final double JUKEBOX_RADIUS_SQUARED = 96.0 * 96.0;
	private static final double LIGHT_ITEM_RADIUS_SQUARED = 16.0 * 16.0;
	private static final double MOB_DEATH_RADIUS_SQUARED = 64.0 * 64.0;
	private static final int TRIGGER_SCAN_INTERVAL = 20;
	private static final int PLACEMENT_WAIT_TICKS = 40;

	private static Track oneShotTrack;
	private static boolean oneShotStarted;
	private static SoundInstance oneShotInstance;
	private static Track startedOneShotTrack;
	private static PendingSong startedTriggeredSong;
	private static final ArrayDeque<PendingSong> pendingTriggeredSongs = new ArrayDeque<>();
	private static PendingSong selectedTriggeredSong;
	private static PendingSong startingTriggeredSong;
	private static Track selectedTrackForStart;
	private static Track startingTrack;
	private static boolean requestedTrackFound;
	private static SoundInstance customMusicInstance;
	private static ClientLevel observedLevel;
	private static boolean nearbyJukebox;
	private static boolean dragonDeathTriggered;
	private static int jukeboxScanCountdown;
	private static int dragonScanCountdown;
	private static int triggerScanCountdown;
	private static boolean wasInCave;
	private static boolean wasNearLightItem;
	private static boolean wasNearNightOcean;

	@Override
	public void onInitializeClient() {
		SongularityConfig.initialize();
		ClientTickEvents.END_CLIENT_TICK.register(SongularityClient::onClientTick);
		UseBlockCallback.EVENT.register((player, level, hand, hitResult) -> {
			if (!level.isClientSide() || player != Minecraft.getInstance().player || !SongularityConfig.songsEnabled) {
				return InteractionResult.PASS;
			}

			ItemStack heldStack = player.getItemInHand(hand);
			if (heldStack.getItem() instanceof BlockItem blockItem) {
				Block block = blockItem.getBlock();
				Track track = block == Blocks.NOTE_BLOCK
						? Track.OS_PIANO
						: block.defaultBlockState().is(BlockTags.FLOWERS) ? Track.LEFT_TO_BLOOM : null;
				if (track != null) {
					BlockPos clickedPosition = hitResult.getBlockPos();
					requestTriggeredTrack(track, clickedPosition, clickedPosition.relative(hitResult.getDirection()), true);
				}
			}
			return InteractionResult.PASS;
		});
	}

	public static void onCreateWorldPressed() {
		requestOneShot(Track.ECHO_IN_THE_WIND);
	}

	public static Music selectSituationalMusic(Minecraft client, Music vanillaMusic) {
		selectedTrackForStart = null;
		selectedTriggeredSong = null;
		if (!SongularityConfig.songsEnabled || nearbyJukebox) {
			return vanillaMusic;
		}

		SoundInstance current = ((MusicManagerAccessor) client.getMusicManager()).songularity$getCurrentMusic();
		if (current != null && client.getSoundManager().isActive(current)) {
			if (current == customMusicInstance) {
				return new Music(SoundEvents.MUSIC_GAME, 6000, 24000, false);
			}
			return vanillaMusic;
		}

		Track track = oneShotTrack;
		if (track == null) {
			selectedTriggeredSong = nextTriggeredSong(client);
			if (selectedTriggeredSong != null) {
				track = selectedTriggeredSong.track;
			}
		}
		boolean titleScreen = client.gui.screen() instanceof TitleScreen;
		if (track == null && titleScreen) {
			track = Track.BROMELIAD;
		} else if (track == null && SongularityConfig.extraRandomSongs && client.level != null && client.player != null) {
			if (client.level.dimension().equals(Level.NETHER) && ThreadLocalRandom.current().nextBoolean()) {
				track = Track.PUZZLEBOX;
			} else if (client.level.dimension().equals(Level.END)) {
				if (vanillaMusic != null && vanillaMusic.sound().equals(SoundEvents.MUSIC_DRAGON)) {
					return vanillaMusic;
				}
				if (ThreadLocalRandom.current().nextBoolean()) {
					track = ThreadLocalRandom.current().nextBoolean() ? Track.ECHO_IN_THE_WIND : Track.PUZZLEBOX;
				}
			}
		}

		if (track == null) {
			return vanillaMusic;
		}

		selectedTrackForStart = track;
		boolean immediate = oneShotTrack != null || selectedTriggeredSong != null || titleScreen;
		int minDelay = immediate ? 0 : 6000;
		int maxDelay = immediate ? 0 : 24000;
		return new Music(SoundEvents.MUSIC_GAME, minDelay, maxDelay, false);
	}

	public static void beginTrackStart(Music music) {
		startingTrack = null;
		startingTriggeredSong = null;
		requestedTrackFound = false;
		if (selectedTrackForStart != null && SongularityConfig.songsEnabled && !nearbyJukebox
				&& music.sound().value().equals(SoundEvents.MUSIC_GAME.value())) {
			if (selectedTriggeredSong != null && !isTriggeredConditionMet(Minecraft.getInstance(), selectedTriggeredSong)) {
				pendingTriggeredSongs.remove(selectedTriggeredSong);
				selectedTriggeredSong = null;
				selectedTrackForStart = null;
				return;
			}
			startingTrack = selectedTrackForStart;
			startingTriggeredSong = selectedTriggeredSong;
		}
	}

	public static Track trackBeingStarted() {
		return startingTrack;
	}

	public static void requestedTrackFound(Track track) {
		if (startingTrack == track) {
			requestedTrackFound = true;
		}
	}

	public static void finishTrackStart(MusicManager musicManager) {
		Track track = startingTrack;
		PendingSong triggeredSong = startingTriggeredSong;
		startingTrack = null;
		startingTriggeredSong = null;
		boolean trackFound = requestedTrackFound;
		requestedTrackFound = false;
		selectedTrackForStart = null;
		selectedTriggeredSong = null;
		if (track == null) {
			return;
		}
		if (!trackFound) {
			if (oneShotTrack == track) {
				oneShotTrack = null;
				oneShotStarted = false;
				oneShotInstance = null;
			}
			if (triggeredSong != null) {
				pendingTriggeredSongs.remove(triggeredSong);
			}
			return;
		}

		SoundInstance instance = ((MusicManagerAccessor) musicManager).songularity$getCurrentMusic();
		if (instance == null) {