Files
src
build.gradle
README.md
settings.gradle
Code
16 1,211
src/main/java/com/example/spotifyplayer/client/SpotifyPlayerClient.java
package com.example.spotifyplayer.client;
import com.example.spotifyplayer.SpotifyPlayerMod;
import com.example.spotifyplayer.config.SpotifyConfig;
import com.example.spotifyplayer.gui.SpotifyHud;
import com.example.spotifyplayer.gui.SpotifyPlayerScreen;
import com.example.spotifyplayer.spotify.SpotifyApi;
import net.fabricmc.api.ClientModInitializer;
import net.fabricmc.fabric.api.client.rendering.v1.HudRenderCallback;
import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents;
import net.minecraft.client.MinecraftClient;
public class SpotifyPlayerClient implements ClientModInitializer {
@Override
public void onInitializeClient() {
SpotifyPlayerMod.LOGGER.info("Spotify Liquid Glass Player wird initialisiert ...");
KeyBindings.init();
// Mini-HUD über den normalen HUD-Renderpass zeichnen (nicht interaktiv)
HudRenderCallback.EVENT.register((drawContext, tickCounter) -> {
MinecraftClient client = MinecraftClient.getInstance();
if (client.currentScreen == null) {
SpotifyHud.render(drawContext);
}
});
// Tastenkürzel jeden Client-Tick prüfen
ClientTickEvents.END_CLIENT_TICK.register(client -> {
while (KeyBindings.OPEN_PLAYER.wasPressed()) {
if (client.currentScreen == null) {
client.setScreen(new SpotifyPlayerScreen());
}
}
while (KeyBindings.TOGGLE_HUD.wasPressed()) {
SpotifyConfig cfg = SpotifyConfig.get();
cfg.hudEnabled = !cfg.hudEnabled;
cfg.save();
}
while (KeyBindings.PLAY_PAUSE.wasPressed()) {
SpotifyApi.playPause(SpotifyHud.getLastTrack().playing);
}
while (KeyBindings.NEXT_TRACK.wasPressed()) {
SpotifyApi.next();
}
while (KeyBindings.PREVIOUS_TRACK.wasPressed()) {
SpotifyApi.previous();
}
});
}
}