Skip to content

Commit

Permalink
WIP: Improve Instrument and MusicVenueTool overlays.
Browse files Browse the repository at this point in the history
  • Loading branch information
Aeronica committed Feb 29, 2024
1 parent eec3d71 commit a751a76
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
import static aeronicamc.mods.mxtune.render.RenderHelper.mc;

public class InstrumentOverlayRenderer {
@SuppressWarnings("deprecation")
public static void render(ItemStack itemStack, RenderGameOverlayEvent.Post event) {
// Display basic info about the instrument and tune. Optionally, displays some debug info depending on MXTune.isDevEnv flag.
// Based on the toast renderer for testing some ideas.
// Display basic info about the instrument and tune.
if (event.getType() == RenderGameOverlayEvent.ElementType.ALL && (mc.screen == null) && itemStack.getItem() instanceof IInstrument) {
final ItemStack sheetMusic = SheetMusicHelper.getIMusicFromIInstrument(itemStack);
final ITextComponent titleText = SheetMusicHelper.getFormattedMusicTitle(sheetMusic);
Expand Down
9 changes: 0 additions & 9 deletions src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
package aeronicamc.mods.mxtune.render;

import aeronicamc.mods.mxtune.sound.ClientAudio;
import aeronicamc.mods.mxtune.util.SheetMusicHelper;
import com.mojang.blaze3d.matrix.MatrixStack;
import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.client.gui.toasts.IToast;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraft.util.text.StringTextComponent;
import net.minecraft.util.text.TextFormatting;

import static aeronicamc.mods.mxtune.render.RenderHelper.mc;

public class OverlayInst implements IOverlayItem {
private final ItemStack itemStack;
private long lastChanged;
private boolean changed;

private ItemStack sheetMusic;
private ITextComponent titleText;
private ITextComponent extraText;
private ITextComponent infoText;


private int offset;

private OverlayInst() {
Expand All @@ -34,8 +27,6 @@ public OverlayInst(ItemStack itemStack) {
this.sheetMusic = SheetMusicHelper.getIMusicFromIInstrument(itemStack);
this.titleText = SheetMusicHelper.getFormattedMusicTitle(sheetMusic);
this.extraText = SheetMusicHelper.getFormattedExtraText(sheetMusic);
this.infoText = new StringTextComponent("").append(SheetMusicHelper.getFormattedMusicDuration(sheetMusic))
.append(String.format(" %s %s", mc.getSoundManager().getDebugString(), ClientAudio.getDebugString())).withStyle(TextFormatting.WHITE);
offset = Math.max(Math.max(mc.font.width(titleText), mc.font.width(extraText)) + 40, this.width());
}

Expand Down

0 comments on commit a751a76

Please sign in to comment.