From 674781d7e45d7763111a8ab0cb8b78f4c9a27c6c Mon Sep 17 00:00:00 2001 From: Aeronica Date: Wed, 6 Mar 2024 08:30:53 -0600 Subject: [PATCH] WIP: Improve Instrument and MusicVenueTool overlays. --- .../mods/mxtune/gui/TestScreen.java | 4 +- .../render/InstrumentOverlayRenderer.java | 37 ---------- .../mods/mxtune/render/MXOverlay.java | 47 ------------ .../render/MusicVenueToolOverlayRenderer.java | 71 ------------------ .../mxtune/render/MusicVenueToolRenderer.java | 33 --------- .../mods/mxtune/render/OverlayInst.java | 5 +- .../mods/mxtune/render/OverlayItemGui.java | 54 +++++++++----- .../mods/mxtune/render/OverlayVenueTool.java | 73 ++++++++++++++++++- .../mods/mxtune/render/RenderEvents.java | 9 +-- .../mods/mxtune/render/RenderHelper.java | 6 +- 10 files changed, 118 insertions(+), 221 deletions(-) delete mode 100644 src/main/java/aeronicamc/mods/mxtune/render/InstrumentOverlayRenderer.java delete mode 100644 src/main/java/aeronicamc/mods/mxtune/render/MXOverlay.java delete mode 100644 src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolOverlayRenderer.java delete mode 100644 src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolRenderer.java diff --git a/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java b/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java index bf5c6e01..51a81f41 100644 --- a/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java +++ b/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java @@ -10,8 +10,6 @@ import aeronicamc.mods.mxtune.gui.widget.list.SoundFontList; import aeronicamc.mods.mxtune.init.ModItems; import aeronicamc.mods.mxtune.inventory.MultiInstInventory; -import aeronicamc.mods.mxtune.render.OverlayInst; -import aeronicamc.mods.mxtune.render.RenderHelper; import aeronicamc.mods.mxtune.util.Misc; import aeronicamc.mods.mxtune.util.SoundFontProxyManager; import com.mojang.blaze3d.matrix.MatrixStack; @@ -98,7 +96,7 @@ public void onButtonOpen() m.setItem(0, Objects.requireNonNull(getMinecraft().player).inventory.getSelected()); m.setChanged(); ModItems.MULTI_INST.get().setPatch(itemStack, RandomUtils.nextInt(0, SoundFontProxyManager.getProxies().size())); - RenderHelper.getOverlayItemGui().addOverlay(new OverlayInst(itemStack)); +// RenderHelper.getOverlayItemGui().addOverlay(new OverlayInst(itemStack)); } public void onButtonFile() diff --git a/src/main/java/aeronicamc/mods/mxtune/render/InstrumentOverlayRenderer.java b/src/main/java/aeronicamc/mods/mxtune/render/InstrumentOverlayRenderer.java deleted file mode 100644 index c060bf66..00000000 --- a/src/main/java/aeronicamc/mods/mxtune/render/InstrumentOverlayRenderer.java +++ /dev/null @@ -1,37 +0,0 @@ -package aeronicamc.mods.mxtune.render; - -import aeronicamc.mods.mxtune.util.IInstrument; -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.minecraftforge.client.event.RenderGameOverlayEvent; - -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. - 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); - final ITextComponent extraText = SheetMusicHelper.getFormattedExtraText(sheetMusic); - - final int offset = Math.max(Math.max(mc.font.width(titleText), mc.font.width(extraText)) + 40, RenderHelper.WIDTH); - final MatrixStack pPoseStack = event.getMatrixStack(); - mc.getTextureManager().bind(IToast.TEXTURE); - - RenderSystem.color3f(1.0F, 1.0F, 1.0F); - RenderHelper.blit(pPoseStack, 0, 0, 0, 0, RenderHelper.WIDTH, RenderHelper.HEIGHT); - RenderHelper.blit(pPoseStack, ((offset - RenderHelper.WIDTH)/2) + 5, 0, 10, 0, RenderHelper.WIDTH -10, RenderHelper.HEIGHT); - RenderHelper.blit(pPoseStack, offset - RenderHelper.WIDTH + 10, 0, 10, 0, RenderHelper.WIDTH, RenderHelper.HEIGHT); - mc.getItemRenderer().renderAndDecorateItem(itemStack, 8, 8); - - mc.font.draw(pPoseStack, titleText, 30.0F, 7.0F, -11534256); - mc.font.draw(pPoseStack, extraText, 30.0F, 17.0F, -11534256); - } - } -} diff --git a/src/main/java/aeronicamc/mods/mxtune/render/MXOverlay.java b/src/main/java/aeronicamc/mods/mxtune/render/MXOverlay.java deleted file mode 100644 index 7d5394c5..00000000 --- a/src/main/java/aeronicamc/mods/mxtune/render/MXOverlay.java +++ /dev/null @@ -1,47 +0,0 @@ -package aeronicamc.mods.mxtune.render; - -import aeronicamc.mods.mxtune.init.ModItems; -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.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; - -public class MXOverlay implements IOverlayItem { - private static final ITextComponent TITLE_TEXT = new TranslationTextComponent("itemGroup.mxtune").withStyle(TextFormatting.YELLOW); - private final ItemStack itemStack = ModItems.getMultiInst(27); - private long lastChanged; - private boolean changed; - - @SuppressWarnings("deprecation") - @Override - public Visibility render(MatrixStack pPoseStack, OverlayItemGui pOverlayComponent, long delta) { - if (this.changed) { - this.lastChanged = delta; - this.changed = false; - } - pOverlayComponent.getMinecraft().getTextureManager().bind(TEXTURE); - RenderSystem.color3f(1.0F, 1.0F, 1.0F); - pOverlayComponent.blit(pPoseStack, 0, 0, 0, 0, this.baseWidth(), this.baseHeight()); - pOverlayComponent.getMinecraft().font.draw(pPoseStack, TITLE_TEXT, 30.0F, 7.0F, -11534256); - - pOverlayComponent.getMinecraft().getItemRenderer().renderAndDecorateItem(itemStack, 8, 8); - return delta - this.lastChanged >= 5000L ? IOverlayItem.Visibility.HIDE : IOverlayItem.Visibility.SHOW; - } - - @Override - public ItemStack getItemStack() { - return itemStack; - } - - @Override - public int totalHeight() { - return this.baseWidth(); - } - - @Override - public int totalWidth() { - return this.baseWidth(); - } -} diff --git a/src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolOverlayRenderer.java b/src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolOverlayRenderer.java deleted file mode 100644 index 2f6108a3..00000000 --- a/src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolOverlayRenderer.java +++ /dev/null @@ -1,71 +0,0 @@ -package aeronicamc.mods.mxtune.render; - -import aeronicamc.mods.mxtune.caps.venues.EntityVenueState; -import aeronicamc.mods.mxtune.caps.venues.MusicVenueHelper; -import aeronicamc.mods.mxtune.caps.venues.ToolManager; -import aeronicamc.mods.mxtune.caps.venues.ToolState; -import aeronicamc.mods.mxtune.items.MusicVenueToolItem; -import com.mojang.blaze3d.matrix.MatrixStack; -import com.mojang.blaze3d.systems.RenderSystem; -import net.minecraft.client.entity.player.ClientPlayerEntity; -import net.minecraft.client.gui.toasts.IToast; -import net.minecraft.item.ItemStack; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.BlockRayTraceResult; -import net.minecraft.util.math.EntityRayTraceResult; -import net.minecraft.util.math.RayTraceResult; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.ITextComponent; -import net.minecraft.util.text.StringTextComponent; -import net.minecraft.util.text.TextFormatting; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraftforge.client.event.RenderGameOverlayEvent; - -import static aeronicamc.mods.mxtune.render.RenderHelper.mc; - -public class MusicVenueToolOverlayRenderer { - static void render(ClientPlayerEntity player, ItemStack itemStack, RenderGameOverlayEvent.Post event) { - if (event.getType() == RenderGameOverlayEvent.ElementType.ALL && (mc.screen == null) && itemStack.getItem() instanceof MusicVenueToolItem) - { - final MatrixStack pPoseStack = event.getMatrixStack(); - final RayTraceResult raytraceresult = mc.hitResult; - final Vector3d vector3d; - final EntityVenueState evs = MusicVenueHelper.getEntityVenueState(player.level, player.getId()); - final ITextComponent blockName; - BlockPos blockpos = BlockPos.ZERO; - - if (raytraceresult instanceof BlockRayTraceResult) - { - blockpos = ((BlockRayTraceResult) raytraceresult).getBlockPos(); - } - else if (raytraceresult instanceof EntityRayTraceResult) - { - vector3d = ((EntityRayTraceResult) raytraceresult).getEntity().getPosition(mc.getFrameTime()); - blockpos = new BlockPos(vector3d.x, vector3d.y, vector3d.z); - } - - ToolState.Type[] stateName = {ToolState.Type.START}; - ToolManager.getToolOpl(player).ifPresent(tool-> stateName[0] = tool.getToolState()); - - ITextComponent testText = new TranslationTextComponent(stateName[0].getTranslationKey()).withStyle(TextFormatting.WHITE).append(" ").append(evs.inVenue() ? evs.getVenue().getVenueAABB().getCenter().toString() : ""); - int offset = Math.max(mc.font.width(testText) + 40, RenderHelper.WIDTH); - - if (mc.level != null && raytraceresult instanceof BlockRayTraceResult) - blockName = mc.level.getBlockState(blockpos).getBlock().getName().withStyle(TextFormatting.YELLOW); - else if (raytraceresult instanceof EntityRayTraceResult) - blockName = new StringTextComponent(((EntityRayTraceResult) raytraceresult).getEntity().getName().getString()).withStyle(TextFormatting.YELLOW); - else - blockName = new StringTextComponent("---").withStyle(TextFormatting.AQUA); - - mc.getTextureManager().bind(IToast.TEXTURE); - RenderSystem.color3f(1.0F, 1.0F, 1.0F); - RenderHelper.blit(pPoseStack, 0, 0, 0, 0, RenderHelper.WIDTH, RenderHelper.HEIGHT); - RenderHelper.blit(pPoseStack, ((offset - RenderHelper.WIDTH)/2) + 5, 0, 10, 0, RenderHelper.WIDTH -10, RenderHelper.HEIGHT); - RenderHelper.blit(pPoseStack, offset - RenderHelper.WIDTH + 10, 0, 10, 0, RenderHelper.WIDTH, RenderHelper.HEIGHT); - - mc.font.draw(pPoseStack, testText, 30.0F, 7.0F, -11534256); - mc.font.draw(pPoseStack, blockName, 30.0F, 17.0F, -11534256); - mc.getItemRenderer().renderAndDecorateItem(itemStack, 8, 8); - } - } -} diff --git a/src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolRenderer.java b/src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolRenderer.java deleted file mode 100644 index e5245a76..00000000 --- a/src/main/java/aeronicamc/mods/mxtune/render/MusicVenueToolRenderer.java +++ /dev/null @@ -1,33 +0,0 @@ -package aeronicamc.mods.mxtune.render; - -import com.mojang.blaze3d.matrix.MatrixStack; -import net.minecraft.client.Minecraft; -import net.minecraft.client.renderer.ActiveRenderInfo; -import net.minecraft.client.renderer.IRenderTypeBuffer; -import net.minecraft.client.renderer.culling.ClippingHelper; -import net.minecraft.util.math.vector.Vector3d; -import net.minecraft.util.text.StringTextComponent; - -@SuppressWarnings("unused") -public class MusicVenueToolRenderer -{ - private static final Minecraft mc = Minecraft.getInstance(); - - private MusicVenueToolRenderer() { /* NOP */ } - - static void renderUUID(MatrixStack pMatrixStack, IRenderTypeBuffer.Impl pBuffer, ActiveRenderInfo pActiveRenderInfo, float pPartialTicks, ClippingHelper pClippingHelper) - { - if (mc.player != null && mc.level != null) - { - mc.level.players().stream().filter(p -> pClippingHelper.isVisible(p.getBoundingBoxForCulling())).forEach(player -> { - int packedLight = mc.getEntityRenderDispatcher().getPackedLightCoords(player, pPartialTicks); - Vector3d playerPos = player.getPosition(pPartialTicks); - RenderHelper.renderFloatingText( - new Vector3d(playerPos.x(), playerPos.y()+ player.getBbHeight() + 0.8, playerPos.z()), - pMatrixStack, pBuffer, pActiveRenderInfo, -1, - new StringTextComponent(player.getUUID().toString()), packedLight); - pBuffer.endBatch(); - }); - } - } -} diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java index d01edda3..31d3b475 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java @@ -7,6 +7,7 @@ import net.minecraft.item.ItemStack; import net.minecraft.util.text.ITextComponent; +import static aeronicamc.mods.mxtune.render.RenderHelper.getSelectedSlot; import static aeronicamc.mods.mxtune.render.RenderHelper.mc; public class OverlayInst implements IOverlayItem { @@ -16,12 +17,14 @@ public class OverlayInst implements IOverlayItem { private ITextComponent titleText; private ITextComponent extraText; private int totalWidth; + private int lastSlot; private OverlayInst() { this.itemStack = ItemStack.EMPTY; } public OverlayInst(ItemStack itemStack) { + this.lastSlot = RenderHelper.getSelectedSlot(); this.itemStack = itemStack; ItemStack sheetMusic = SheetMusicHelper.getIMusicFromIInstrument(itemStack); this.titleText = SheetMusicHelper.getFormattedMusicTitle(sheetMusic); @@ -61,6 +64,6 @@ public Visibility render(MatrixStack pPoseStack, OverlayItemGui pOverlayComponen mc.font.draw(pPoseStack, titleText, 30.0F, 7.0F, -11534256); mc.font.draw(pPoseStack, extraText, 30.0F, 17.0F, -11534256); - return delta - this.lastChanged >= 5000L ? Visibility.HIDE : Visibility.SHOW; + return delta - this.lastChanged >= 5000L || lastSlot != getSelectedSlot() ? Visibility.HIDE : Visibility.SHOW; } } diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java index 12716e68..061abe6b 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java @@ -1,43 +1,59 @@ package aeronicamc.mods.mxtune.render; -import com.google.common.collect.Queues; +import aeronicamc.mods.mxtune.items.MusicVenueToolItem; +import aeronicamc.mods.mxtune.util.IInstrument; import com.mojang.blaze3d.matrix.MatrixStack; import com.mojang.blaze3d.systems.RenderSystem; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.AbstractGui; +import net.minecraft.item.ItemStack; import net.minecraft.util.Util; import net.minecraft.util.math.MathHelper; import javax.annotation.Nullable; import java.util.Arrays; -import java.util.Deque; ; public class OverlayItemGui extends AbstractGui { private final Minecraft minecraft; - private final OverlayInstance[] visible = new OverlayInstance[4]; - private final Deque queued = Queues.newArrayDeque(); + private final OverlayInstance[] visible = { null, null, null, null }; public OverlayItemGui(Minecraft pMinecraft) { this.minecraft = pMinecraft; } + private int lastSlot = -1; + public void render(MatrixStack pPoseStack) { if (!this.minecraft.options.hideGui) { + OverlayInstance overlayInstance; for(int i = 0; i < this.visible.length; ++i) { - OverlayInstance overlayInstance = this.visible[i]; - if (overlayInstance != null && overlayInstance.render(this.minecraft.getWindow().getGuiScaledWidth(), i, pPoseStack)) { - this.visible[i] = null; + overlayInstance = null; + if (this.visible[i] == null && getMinecraft().player != null && lastSlot != RenderHelper.getSelectedSlot()) { + lastSlot = RenderHelper.getSelectedSlot(); + this.visible[i] = getOverLayInstance(); } - if (this.visible[i] == null && !this.queued.isEmpty()) { - this.visible[i] = new OverlayInstance<>(this.queued.removeFirst()); + if (this.visible[i] != null) + overlayInstance = this.visible[i]; + if (overlayInstance != null && overlayInstance.render(this.minecraft.getWindow().getGuiScaledWidth(), i, pPoseStack)) { + this.visible[i] = null; } } } } + @Nullable + private OverlayInstance getOverLayInstance() { + ItemStack stack = RenderHelper.getPlayer().inventory.getSelected(); + if (stack.getItem() instanceof IInstrument) + return new OverlayInstance<>(new OverlayInst(stack)); + else if (stack.getItem() instanceof MusicVenueToolItem) + return new OverlayInstance<>(new OverlayVenueTool(stack)); + return null; + } + @SuppressWarnings("unchecked") @Nullable public T getOverlay(Class pIOverlayItem, Object pToken) { @@ -47,23 +63,23 @@ public T getOverlay(Class pIOverlayItem, O } } - for(IOverlayItem overlayItem : this.queued) { - if (pIOverlayItem.isAssignableFrom(overlayItem.getClass()) && overlayItem.getToken().equals(pToken)) { - return (T)overlayItem; - } - } +// for(IOverlayItem overlayItem : this.queued) { +// if (pIOverlayItem.isAssignableFrom(overlayItem.getClass()) && overlayItem.getToken().equals(pToken)) { +// return (T)overlayItem; +// } +// } return (T)null; } public void clear() { Arrays.fill(this.visible, (Object)null); - this.queued.clear(); +// this.queued.clear(); } - public void addOverlay(IOverlayItem overlayItem) { - this.queued.add(overlayItem); - } +// public void addOverlay(IOverlayItem overlayItem) { +// this.queued.add(overlayItem); +// } public Minecraft getMinecraft() { return this.minecraft; @@ -112,7 +128,7 @@ public boolean render(int x, int y, MatrixStack pPoseStack) { float center = (x * 0.5F) - this.overlayItem.totalHeight() * 0.5F; float left = 0F; RenderSystem.pushMatrix(); - RenderSystem.translatef(left, ((float)y * this.overlayItem.baseHeight() - this.overlayItem.baseHeight()) + ((float)(this.overlayItem.baseHeight()) * this.getVisibility(i)), (float)(800 + y)); + RenderSystem.translatef(left, ((float)0 * this.overlayItem.baseHeight() - this.overlayItem.baseHeight()) + ((float)(this.overlayItem.baseHeight()) * this.getVisibility(i)), (float)(800 + y)); IOverlayItem.Visibility overlayVisibility = this.overlayItem.render(pPoseStack, OverlayItemGui.this, i - this.visibleTime); RenderSystem.popMatrix(); if (overlayVisibility != this.visibility) { diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java index dbeec975..3dfacf45 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java @@ -1,23 +1,88 @@ package aeronicamc.mods.mxtune.render; +import aeronicamc.mods.mxtune.caps.venues.EntityVenueState; +import aeronicamc.mods.mxtune.caps.venues.MusicVenueHelper; +import aeronicamc.mods.mxtune.caps.venues.ToolManager; +import aeronicamc.mods.mxtune.caps.venues.ToolState; 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.math.BlockPos; +import net.minecraft.util.math.BlockRayTraceResult; +import net.minecraft.util.math.EntityRayTraceResult; +import net.minecraft.util.math.RayTraceResult; +import net.minecraft.util.math.vector.Vector3d; +import net.minecraft.util.text.ITextComponent; +import net.minecraft.util.text.StringTextComponent; +import net.minecraft.util.text.TextFormatting; +import net.minecraft.util.text.TranslationTextComponent; + +import static aeronicamc.mods.mxtune.render.RenderHelper.*; public class OverlayVenueTool implements IOverlayItem { private final ItemStack itemStack; - + private long lastChanged; + private boolean changed; + private int totalWidth; + private int lastSlot; public OverlayVenueTool(ItemStack itemStack) { + this.lastSlot = RenderHelper.getSelectedSlot(); this.itemStack = itemStack; } + @SuppressWarnings("deprecation") @Override public Visibility render(MatrixStack pPoseStack, OverlayItemGui pOverlayComponent, long delta) { - return null; + if (this.changed) { + this.lastChanged = delta; + this.changed = false; + } + final RayTraceResult raytraceresult = mc.hitResult; + final Vector3d vector3d; + final EntityVenueState evs = MusicVenueHelper.getEntityVenueState(getPlayer().level, getPlayer().getId()); + final ITextComponent blockName; + BlockPos blockpos = BlockPos.ZERO; + + if (raytraceresult instanceof BlockRayTraceResult) + { + blockpos = ((BlockRayTraceResult) raytraceresult).getBlockPos(); + } + else if (raytraceresult instanceof EntityRayTraceResult) + { + vector3d = ((EntityRayTraceResult) raytraceresult).getEntity().getPosition(mc.getFrameTime()); + blockpos = new BlockPos(vector3d.x, vector3d.y, vector3d.z); + } + + ToolState.Type[] stateName = {ToolState.Type.START}; + ToolManager.getToolOpl(getPlayer()).ifPresent(tool-> stateName[0] = tool.getToolState()); + + ITextComponent testText = new TranslationTextComponent(stateName[0].getTranslationKey()).withStyle(TextFormatting.WHITE).append(" ").append(evs.inVenue() ? evs.getVenue().getVenueAABB().getCenter().toString() : ""); + totalWidth = Math.max(mc.font.width(testText) + 40, RenderHelper.WIDTH); + + if (mc.level != null && raytraceresult instanceof BlockRayTraceResult) + blockName = mc.level.getBlockState(blockpos).getBlock().getName().withStyle(TextFormatting.YELLOW); + else if (raytraceresult instanceof EntityRayTraceResult) + blockName = new StringTextComponent(((EntityRayTraceResult) raytraceresult).getEntity().getName().getString()).withStyle(TextFormatting.YELLOW); + else + blockName = new StringTextComponent("---").withStyle(TextFormatting.AQUA); + + mc.getTextureManager().bind(IToast.TEXTURE); + RenderSystem.color3f(1.0F, 1.0F, 1.0F); + RenderHelper.blit(pPoseStack, 0, 0, 0, 0, RenderHelper.WIDTH, RenderHelper.HEIGHT); + RenderHelper.blit(pPoseStack, ((totalWidth - RenderHelper.WIDTH)/2) + 5, 0, 10, 0, RenderHelper.WIDTH -10, RenderHelper.HEIGHT); + RenderHelper.blit(pPoseStack, totalWidth - RenderHelper.WIDTH + 10, 0, 10, 0, RenderHelper.WIDTH, RenderHelper.HEIGHT); + + mc.font.draw(pPoseStack, testText, 30.0F, 7.0F, -11534256); + mc.font.draw(pPoseStack, blockName, 30.0F, 17.0F, -11534256); + mc.getItemRenderer().renderAndDecorateItem(itemStack, 8, 8); + + return delta - this.lastChanged >= 5000L || lastSlot != getSelectedSlot() ? Visibility.HIDE : Visibility.SHOW; } @Override public ItemStack getItemStack() { - return null; + return itemStack; } @Override @@ -27,6 +92,6 @@ public int totalHeight() { @Override public int totalWidth() { - return 0; + return totalWidth; } } diff --git a/src/main/java/aeronicamc/mods/mxtune/render/RenderEvents.java b/src/main/java/aeronicamc/mods/mxtune/render/RenderEvents.java index 648a9162..0660f977 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/RenderEvents.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/RenderEvents.java @@ -134,11 +134,10 @@ public static void event(DrawHighlightEvent.HighlightEntity event) public static void event(RenderGameOverlayEvent.Post event) { if (mc.options.renderDebug ) return; - final ItemStack itemStack = getPlayer().inventory.getSelected(); - InstrumentOverlayRenderer.render(itemStack, event); - MusicVenueToolOverlayRenderer.render(getPlayer(), itemStack, event); - RenderHelper.getOverlayItemGui().render(event.getMatrixStack()); - ActiveAudioOverlay.render(event); + if (event.getType() == RenderGameOverlayEvent.ElementType.ALL && (mc.screen == null)) { + RenderHelper.getOverlayItemGui().render(event.getMatrixStack()); + ActiveAudioOverlay.render(event); + } } static void renderGroupStatusPlacard(MatrixStack pMatrixStack, IRenderTypeBuffer.Impl pBuffer, ActiveRenderInfo pActiveRenderInfo, float pPartialTicks, ClippingHelper pClippingHelper) diff --git a/src/main/java/aeronicamc/mods/mxtune/render/RenderHelper.java b/src/main/java/aeronicamc/mods/mxtune/render/RenderHelper.java index a3987591..06108a3d 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/RenderHelper.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/RenderHelper.java @@ -32,6 +32,8 @@ public class RenderHelper static final Minecraft mc = Minecraft.getInstance(); private static OverlayItemGui overlayItem; + private RenderHelper() { /* NOP */ } + public static void init() { overlayItem = new OverlayItemGui(mc); } @@ -44,7 +46,9 @@ static ClientPlayerEntity getPlayer() { return Objects.requireNonNull(mc.player); } - private RenderHelper() { /* NOP */ } + static int getSelectedSlot() { + return getPlayer().inventory.selected; + } /** * Defaults to 256x256 texture sheet for use with the vanilla toast textures.