diff --git a/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java b/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java index 51a81f41..efc2786e 100644 --- a/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java +++ b/src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java @@ -9,16 +9,13 @@ import aeronicamc.mods.mxtune.gui.widget.MXTextFieldWidget; import aeronicamc.mods.mxtune.gui.widget.list.SoundFontList; import aeronicamc.mods.mxtune.init.ModItems; -import aeronicamc.mods.mxtune.inventory.MultiInstInventory; import aeronicamc.mods.mxtune.util.Misc; -import aeronicamc.mods.mxtune.util.SoundFontProxyManager; import com.mojang.blaze3d.matrix.MatrixStack; import net.minecraft.client.gui.screen.Screen; import net.minecraft.item.ItemStack; import net.minecraft.item.Items; import net.minecraft.util.text.StringTextComponent; import net.minecraft.util.text.TranslationTextComponent; -import org.apache.commons.lang3.RandomUtils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; @@ -91,12 +88,7 @@ public void init() public void onButtonOpen() { - ItemStack itemStack = new ItemStack(ModItems.getMultiInst(1).getItem(),1); - MultiInstInventory m = new MultiInstInventory(itemStack); - 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)); + /* NOOP */ } public void onButtonFile() diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java index 31d3b475..90744f98 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java @@ -1,5 +1,6 @@ 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; @@ -7,8 +8,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; +import static aeronicamc.mods.mxtune.render.RenderHelper.*; public class OverlayInst implements IOverlayItem { private final ItemStack itemStack; @@ -47,6 +47,10 @@ public int totalWidth() { return this.totalWidth; } + private boolean isNotInstrumentItem() { + return !(getPlayer().inventory.getSelected().getItem() instanceof IInstrument); + } + @SuppressWarnings("deprecation") @Override public Visibility render(MatrixStack pPoseStack, OverlayItemGui pOverlayComponent, long delta) { @@ -64,6 +68,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 || lastSlot != getSelectedSlot() ? Visibility.HIDE : Visibility.SHOW; + return delta - this.lastChanged >= 5000L || lastSlot != getSelectedSlot() || isNotInstrumentItem() ? Visibility.HIDE : Visibility.SHOW; } } diff --git a/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java b/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java index 3dfacf45..89f57d98 100644 --- a/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java +++ b/src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java @@ -4,6 +4,7 @@ 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.gui.toasts.IToast; @@ -22,22 +23,37 @@ public class OverlayVenueTool implements IOverlayItem { private final ItemStack itemStack; - private long lastChanged; - private boolean changed; private int totalWidth; - private int lastSlot; + private final int lastSlot; + public OverlayVenueTool(ItemStack itemStack) { this.lastSlot = RenderHelper.getSelectedSlot(); this.itemStack = itemStack; } + @Override + public ItemStack getItemStack() { + return itemStack; + } + + @Override + public int totalHeight() { + return this.baseHeight(); + } + + @Override + public int totalWidth() { + return totalWidth; + } + + private boolean isNotToolItem() { + return !(getPlayer().inventory.getSelected().getItem() instanceof MusicVenueToolItem); + } + @SuppressWarnings("deprecation") @Override public Visibility render(MatrixStack pPoseStack, OverlayItemGui pOverlayComponent, long delta) { - 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()); @@ -69,29 +85,14 @@ else if (raytraceresult instanceof EntityRayTraceResult) 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); + RenderHelper.blit(pPoseStack, 0, 0, 0, 0, this.baseWidth(), this.baseHeight()); + RenderHelper.blit(pPoseStack, ((totalWidth - this.baseWidth())/2) + 5, 0, 10, 0, this.baseWidth() -10, this.baseHeight()); + RenderHelper.blit(pPoseStack, totalWidth - this.baseWidth() + 10, 0, 10, 0, this.baseWidth(), this.baseHeight()); 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 itemStack; - } - - @Override - public int totalHeight() { - return this.baseHeight(); - } - - @Override - public int totalWidth() { - return totalWidth; + return lastSlot != getSelectedSlot() || isNotToolItem() ? Visibility.HIDE : Visibility.SHOW; } }