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 8, 2024
1 parent 2d5a99e commit 0076bbc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/main/java/aeronicamc/mods/mxtune/render/IOverlayItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,6 @@ public void playSound(SoundHandler pHandler) {
pHandler.play(SimpleSound.forUI(this.soundEvent, 1.0F, 1.0F));
}
}

enum Position { LEFT, CENTER, RIGHT }
}
23 changes: 18 additions & 5 deletions src/main/java/aeronicamc/mods/mxtune/render/OverlayItemGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

public class OverlayItemGui extends AbstractGui {
private final Minecraft minecraft;
private final OverlayInstance<?>[] visible = { null, null, null, null };
private final OverlayInstance<?>[] visible = { null };
private int lastSlot = -1;

public OverlayItemGui(Minecraft pMinecraft) {
Expand Down Expand Up @@ -110,11 +110,24 @@ public boolean render(int x, int y, MatrixStack pPoseStack) {
this.visibleTime = i;
}

float right = (float)x - (float)this.overlayItem.totalHeight();
float center = (x * 0.5F) - this.overlayItem.totalHeight() * 0.5F;
float left = 0F;
IOverlayItem.Position position = IOverlayItem.Position.LEFT;
float xPos = -1F;
float yPos = ((float)0 * this.overlayItem.baseHeight() - this.overlayItem.baseHeight()) + ((float)(this.overlayItem.baseHeight()) * this.getVisibility(i));
switch (position) {
case LEFT:
xPos = 0F;
break;
case CENTER:
xPos = (x * 0.5F) - this.overlayItem.totalWidth() * 0.5F;
break;
case RIGHT:
xPos = (float)x - (float)this.overlayItem.totalWidth();
break;
default:
throw new IllegalStateException("Unexpected value: " + position);
}
RenderSystem.pushMatrix();
RenderSystem.translatef(left, ((float)0 * this.overlayItem.baseHeight() - this.overlayItem.baseHeight()) + ((float)(this.overlayItem.baseHeight()) * this.getVisibility(i)), (float)(800 + y));
RenderSystem.translatef(xPos, yPos, 800F + y);
IOverlayItem.Visibility overlayVisibility = this.overlayItem.render(pPoseStack, OverlayItemGui.this, i - this.visibleTime);
RenderSystem.popMatrix();
if (overlayVisibility != this.visibility) {
Expand Down

0 comments on commit 0076bbc

Please sign in to comment.