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 Mar 7, 2024
1 parent 674781d commit d04409f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 38 deletions.
10 changes: 1 addition & 9 deletions src/main/java/aeronicamc/mods/mxtune/gui/TestScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions src/main/java/aeronicamc/mods/mxtune/render/OverlayInst.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
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 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;
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}
}
53 changes: 27 additions & 26 deletions src/main/java/aeronicamc/mods/mxtune/render/OverlayVenueTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down Expand Up @@ -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;
}
}

0 comments on commit d04409f

Please sign in to comment.