Skip to content

Commit

Permalink
petHud/EquipmentHud preview render fix (Moulberry#293)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ascynx authored Sep 16, 2022
1 parent ff5b80c commit 53cc06e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,15 @@ public class GuiInvButtonEditor extends GuiScreen {
private int guiLeft;
private int guiTop;

//region getGuiCoordinates
public int getGuiLeft() {
return this.guiLeft;
}
public int getGuiTop() {
return this.guiTop;
}
//endregion

private static final int BACKGROUND_TYPES = 5;
private static final int ICON_TYPES = 3;
private int iconTypeIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import io.github.moulberry.notenoughupdates.NotEnoughUpdates;
import io.github.moulberry.notenoughupdates.events.GuiInventoryBackgroundDrawnEvent;
import io.github.moulberry.notenoughupdates.miscfeatures.PetInfoOverlay;
import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor;
import io.github.moulberry.notenoughupdates.mixins.AccessorGuiContainer;
import io.github.moulberry.notenoughupdates.options.NEUConfig;
import io.github.moulberry.notenoughupdates.util.ItemUtils;
Expand Down Expand Up @@ -134,6 +135,8 @@ public ResourceLocation getCustomPetTexture(boolean isArmorRendering) {
public static final int ARMOR_OVERLAY_OVERHAND_WIDTH = 24;
public static final int ARMOR_OVERLAY_HEIGHT = 86;
public static final int ARMOR_OVERLAY_WIDTH = 31;
final static int PET_OVERLAY_HEIGHT = 32;
final static int PET_OVERLAY_WIDTH = 31;
public static final int PET_OVERLAY_OFFSET_Y = ARMOR_OVERLAY_HEIGHT - 14 /* overlaying pixels */;
//</editor-fold>

Expand Down Expand Up @@ -259,7 +262,7 @@ private void updateGuiInfo(GuiScreen screen) {
if (screen instanceof GuiChest) {
petStack = getRepoPetStack();
}
if (!(screen instanceof GuiInventory)
if ((!(screen instanceof GuiInventory) && !(screen instanceof GuiInvButtonEditor))
|| !NotEnoughUpdates.INSTANCE.config.misc.hidePotionEffect
|| !NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) {
shouldRenderPets = shouldRenderArmorHud = false;
Expand Down Expand Up @@ -299,7 +302,7 @@ public void renderPets(GuiInventory inventory, int mouseX, int mouseY, int width
int overlayLeft = container.getGuiLeft() - ARMOR_OVERLAY_OVERHAND_WIDTH;
int overlayTop = container.getGuiTop() + PET_OVERLAY_OFFSET_Y;

Utils.drawTexturedRect(overlayLeft, overlayTop, 31, 32, GL11.GL_NEAREST);
Utils.drawTexturedRect(overlayLeft, overlayTop, PET_OVERLAY_WIDTH, PET_OVERLAY_HEIGHT, GL11.GL_NEAREST);
GlStateManager.bindTexture(0);

Utils.drawItemStack(petInfo, overlayLeft + 8, overlayTop + 8, true);
Expand Down Expand Up @@ -423,33 +426,28 @@ private int calculateTooltipXOffset(List<String> tooltipToDisplay, FontRenderer
}

public void renderPreviewArmorHud() {
if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud) return;
if (!NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud || !(Minecraft.getMinecraft().currentScreen instanceof GuiInvButtonEditor)) return;
GuiInvButtonEditor container = (GuiInvButtonEditor) Minecraft.getMinecraft().currentScreen;

int width = Utils.peekGuiScale().getScaledWidth();
int height = Utils.peekGuiScale().getScaledHeight();
int overlayLeft = container.getGuiLeft() - ARMOR_OVERLAY_OVERHAND_WIDTH;
int overlayTop = container.getGuiTop();

Minecraft.getMinecraft().getTextureManager().bindTexture(getCustomEquipmentTexture(NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay));
ResourceLocation equipmentTexture = getCustomEquipmentTexture(shouldRenderPets);
Minecraft.getMinecraft().getTextureManager().bindTexture(equipmentTexture);

GlStateManager.color(1, 1, 1, 1);
GL11.glTranslatef(0, 0, 401);
float yNumber = (float) (height - 167) / 2f;
Utils.drawTexturedRect((float) ((width - 224.1) / 2f), yNumber, 31, 86, GL11.GL_NEAREST);
GlStateManager.bindTexture(0);
Utils.drawTexturedRect(overlayLeft, overlayTop, ARMOR_OVERLAY_WIDTH, ARMOR_OVERLAY_HEIGHT, GL11.GL_NEAREST);
}

public void renderPreviewPetInvHud() {
if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay) return;

int width = Utils.peekGuiScale().getScaledWidth();
int height = Utils.peekGuiScale().getScaledHeight();
if (!NotEnoughUpdates.INSTANCE.config.petOverlay.petInvDisplay || !(Minecraft.getMinecraft().currentScreen instanceof GuiInvButtonEditor)) return;
GuiInvButtonEditor container = (GuiInvButtonEditor) Minecraft.getMinecraft().currentScreen;
int overlayLeft = container.getGuiLeft() - ARMOR_OVERLAY_OVERHAND_WIDTH;
int overlayTop = container.getGuiTop() + PET_OVERLAY_OFFSET_Y;

Minecraft.getMinecraft().getTextureManager().bindTexture(getCustomPetTexture(NotEnoughUpdates.INSTANCE.config.customArmour.enableArmourHud));
ResourceLocation petHudTexture = getCustomPetTexture(shouldRenderArmorHud);
Minecraft.getMinecraft().getTextureManager().bindTexture(petHudTexture);

GlStateManager.color(1, 1, 1, 1);
GL11.glTranslatef(0, 0, 401);
float yNumber = (float) (height - 23) / 2f;
Utils.drawTexturedRect((float) ((width - 224.1) / 2f), yNumber, 31, 32, GL11.GL_NEAREST);
GlStateManager.bindTexture(0);
Utils.drawTexturedRect(overlayLeft, overlayTop, PET_OVERLAY_WIDTH, PET_OVERLAY_HEIGHT, GL11.GL_NEAREST);
}

public ItemStack slot1 = null;
Expand Down

0 comments on commit 53cc06e

Please sign in to comment.