SoulForged
📎 1 file 2,283 chars
📄
pasted-code-1790170428913.txt
txt 14 lines
▶
You are an expert Minecraft Fabric mod developer. Create a complete, compilable, client-side Fabric mod for Minecraft 26.2 (Fabric 26.2) that integrates Spotify playback and displays synchronized lyrics as floating text in the world. The mod must be client-side only and work on any server without server installation.

Requirements:
- Fabric Loader + Fabric API for Minecraft 26.2, Yarn mappings, Java 21 (or the Java version required by 26.2).
- Spotify Web API integration: OAuth PKCE authentication, ability to paste Spotify track/playlist URLs, fetch track metadata, control playback (play/pause, next, previous, seek), and get current playback progress. Note: playback control requires Spotify Premium.
- Playlist management: create custom playlists from pasted URLs, reorder tracks, set playback mode (sequential or shuffle), save/load config.
- Now Playing overlay: semi-transparent panel in the top-left corner showing track name, artist, album art (if possible), progress bar, and controls. Should be toggleable.
- Keybinds: skip track, play/pause, next/prev, toggle overlay, toggle lyrics.
- Main feature: in-world lyrics/subtitles. Fetch timed lyrics from LRCLIB API or local .lrc files (since Spotify API does not provide lyrics). Synchronize with Spotify playback progress. Display each lyric line as floating text in the world, positioned to the side of the player’s view (e.g., right side), always facing the player (billboard). Not on HUD. Each line stays visible while its timestamp range is active, then remains for exactly 0.5 seconds after the line ends before disappearing. If the next line starts, replace immediately. Use WorldRenderEvents to render text in world space.
- Config screen or file for Spotify Client ID, lyrics source, overlay position, text size, offset, etc.
- Include error handling for no lyrics, auth failure, no Premium.
- Output the complete project: file tree, build.gradle, settings.gradle, gradle.properties, fabric.mod.json, mixins.json, all Java classes, resources, and a README with setup instructions.

Return the full code for every file. Do not omit any file. Use a clear package structure (e.g., com.example.spotifylyrics). Ensure the code compiles against Fabric 26.2 and Fabric API. Use official Fabric documentation patterns.
Kodari AI
KodariSep 23 at 2:00 pm 14
SpotifyWorldLyrics
A client-side Fabric mod for Minecraft 26.2 that integrates Spotify playback with synchronized in-world lyrics. Features OAuth PKCE authentication, track/playlist URL handling, playback controls (play/pause, next/previous, seek), custom playlist management with sequential/shuffle modes, and a toggleable Now Playing overlay showing track info, album art, and progress. The core feature renders timed lyrics from LRCLIB or local .lrc files as floating billboard text in world space, synchronized to Spotify playback progress, positioned beside the player's view. Includes configurable keybinds, settings screen, and comprehensive error handling for auth failures, missing lyrics, and non-Premium accounts.
  1. Set up a Java 25 / Minecraft 26.2 client-only Fabric project.

  2. Implement Spotify PKCE/API and persisted playlist/config handling.

  3. Add keybind controls, the HUD overlay, and timestamp-synchronized world lyrics.

  4. Include resources and setup documentation.

Created the client-only Fabric 26.2 project with Spotify PKCE login and playback controls, local playlist management, a now-playing HUD, LRCLIB/local LRC lyric support, world-space lyrics, configurable keybinds, and setup instructions.

The project targets Java 25 and uses official unobfuscated 26.2 names. I couldn’t run a build here, so compilation remains unverified. Note: the overlay shows track details and progress, but does not yet display album art.

Kodari can make mistakes. Review important code before using.
Files
src
build.gradle
gradle.properties
README.md
settings.gradle
Code
12 979
src/client/java/com/example/spotifylyrics/SpotifyLyricsClient.java
package com.example.spotifylyrics;

import com.example.spotifylyrics.client.SpotifyLyricsScreen;
import com.example.spotifylyrics.render.LyricsWorldRenderer;
import com.example.spotifylyrics.service.SpotifyManager;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.fabricmc.fabric.api.client.keymapping.v1.KeyMappingHelper;
import net.fabricmc.fabric.api.client.rendering.v1.hud.HudElementRegistry;
import net.minecraft.client.KeyMapping;
import net.minecraft.resources.Identifier;
import com.mojang.blaze3d.platform.InputConstants;

public final class SpotifyLyricsClient implements ClientModInitializer {
	public static final String MOD_ID = "spotifylyrics";
	public static SpotifyManager MANAGER;

	private static final KeyMapping.Category CATEGORY = KeyMapping.Category.register(Identifier.fromNamespaceAndPath(MOD_ID, "controls"));
	private static final KeyMapping OPEN_SCREEN = register("open", 75);
	private static final KeyMapping PLAY_PAUSE = register("play_pause", 80);
	private static final KeyMapping NEXT = register("next", 78);
	private static final KeyMapping PREVIOUS = register("previous", 66);
	private static final KeyMapping TOGGLE_OVERLAY = register("toggle_overlay", 79);
	private static final KeyMapping TOGGLE_LYRICS = register("toggle_lyrics", 76);

	@Override
	public void onInitializeClient() {
		MANAGER = new SpotifyManager();
		MANAGER.load();
		HudElementRegistry.addLast(Identifier.fromNamespaceAndPath(MOD_ID, "now_playing"), SpotifyLyricsClient::renderHud);
		LyricsWorldRenderer.register();
		ClientTickEvents.END_CLIENT_TICK.register(client -> {
			MANAGER.tick();
			if (OPEN_SCREEN.consumeClick()) {
				client.gui.setScreen(new SpotifyLyricsScreen());
			}
			if (PLAY_PAUSE.consumeClick()) MANAGER.togglePlayback();
			if (NEXT.consumeClick()) MANAGER.next();
			if (PREVIOUS.consumeClick()) MANAGER.previous();
			if (TOGGLE_OVERLAY.consumeClick()) MANAGER.toggleOverlay();
			if (TOGGLE_LYRICS.consumeClick()) MANAGER.toggleLyrics();
		});
	}

	private static KeyMapping register(String id, int key) {
		return KeyMappingHelper.registerKeyMapping(new KeyMapping(
			"key." + MOD_ID + "." + id,
			InputConstants.Type.KEYSYM,
			key,
			CATEGORY
		));
	}

	private static void renderHud(net.minecraft.client.gui.GuiGraphicsExtractor graphics, net.minecraft.client.DeltaTracker deltaTracker) {
		if (MANAGER == null || !MANAGER.isOverlayVisible()) return;
		int x = MANAGER.overlayX();
		int y = MANAGER.overlayY();
		int width = 190;
		graphics.fill(x, y, x + width, y + 62, 0xB0101218);
		graphics.fill(x, y, x + width, y + 1, 0xFF1DB954);
		String title = MANAGER.trackTitle();
		String artist = MANAGER.trackArtist();
		if (title.isBlank()) {
			title = "Spotify Lyrics";
			artist = MANAGER.status();
		}
		graphics.text(net.minecraft.client.Minecraft.getInstance().font, truncate(title, 27), x + 8, y + 7, 0xFFFFFFFF, true);
		graphics.text(net.minecraft.client.Minecraft.getInstance().font, truncate(artist, 29), x + 8, y + 20, 0xFFB8C0CC, true);
		int barX = x + 8;
		int barY = y + 39;
		int barWidth = width - 16;
		graphics.fill(barX, barY, barX + barWidth, barY + 3, 0xFF43464D);
		int played = (int) (barWidth * MANAGER.progressFraction());
		if (played > 0) graphics.fill(barX, barY, barX + played, barY + 3, 0xFF1DB954);
		graphics.text(net.minecraft.client.Minecraft.getInstance().font, MANAGER.status(), x + 8, y + 47, 0xFFB8C0CC, false);
	}

	private static String truncate(String value, int max) {
		return value.length() <= max ? value : value.substring(0, max - 1) + "…";
	}
}