-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Improve Instrument and MusicVenueTool overlays.
- Loading branch information
Showing
5 changed files
with
49 additions
and
40 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
src/main/java/aeronicamc/mods/mxtune/render/ActiveAudioOverlay.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package aeronicamc.mods.mxtune.render; | ||
|
||
import aeronicamc.mods.mxtune.init.ModItems; | ||
import aeronicamc.mods.mxtune.sound.ClientAudio; | ||
import com.mojang.blaze3d.matrix.MatrixStack; | ||
import com.mojang.blaze3d.systems.RenderSystem; | ||
import net.minecraft.item.ItemStack; | ||
import net.minecraft.util.text.ITextComponent; | ||
import net.minecraft.util.text.StringTextComponent; | ||
import net.minecraft.util.text.TextFormatting; | ||
import net.minecraftforge.client.event.RenderGameOverlayEvent; | ||
|
||
import static aeronicamc.mods.mxtune.render.RenderHelper.getPlayer; | ||
import static aeronicamc.mods.mxtune.render.RenderHelper.mc; | ||
|
||
public class ActiveAudioOverlay { | ||
private static final ItemStack PLACARD_ITEM = new ItemStack(ModItems.PLACARD_ITEM.get()); | ||
|
||
@SuppressWarnings("deprecation") | ||
public static void render(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. | ||
if (isPlacardInHotBar()) { | ||
final MatrixStack pPoseStack = event.getMatrixStack(); | ||
RenderSystem.color3f(1.0F, 1.0F, 1.0F); | ||
|
||
final ITextComponent infoText = new StringTextComponent("") | ||
.append(String.format("%s, %s", mc.getSoundManager().getDebugString(), ClientAudio.getDebugString())).withStyle(TextFormatting.WHITE); | ||
final int[] posY = { 0 }; | ||
posY[0] = (25); | ||
mc.font.drawShadow(pPoseStack, infoText, 5.0F, posY[0] += 10, -11534256); | ||
ClientAudio.getAudioData().forEach(audioData -> mc.font.drawShadow(pPoseStack, audioData.getInfo(), 5, posY[0] += 10, -11534256)); | ||
} | ||
} | ||
|
||
/** | ||
* @return true if mxtune:placard_item is on the hot-bar, and the player is not in a portal. | ||
*/ | ||
private static boolean isPlacardInHotBar() { | ||
int slot = getPlayer().inventory.findSlotMatchingItem(PLACARD_ITEM); | ||
return slot >= 0 && slot < 9 && !(getPlayer().portalTime > 0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters