Skip to content

Commit

Permalink
Add craftable icon in terminal (#665)
Browse files Browse the repository at this point in the history
  • Loading branch information
MCTBL authored Feb 5, 2025
1 parent 7c17c3d commit 69f9368
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/main/java/appeng/client/gui/AEBaseGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ public AEBaseGui(final Container container) {
super(container);
this.subGui = switchingGuis;
switchingGuis = false;
aeRenderItem.parent = this;
}

protected static String join(final Collection<String> toolTip, final String delimiter) {
Expand Down
37 changes: 28 additions & 9 deletions src/main/java/appeng/client/render/AppEngRenderItem.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

import org.lwjgl.opengl.GL11;

import appeng.api.AEApi;
import appeng.api.config.TerminalFontSize;
import appeng.api.storage.IItemDisplayRegistry.ItemRenderHook;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.gui.AEBaseGui;
import appeng.core.AEConfig;
import appeng.core.localization.GuiText;

Expand All @@ -36,8 +38,13 @@
*/
public class AppEngRenderItem extends AERenderItem {

public AEBaseGui parent;

private IAEItemStack aeStack = null;

private static final ItemStack PATTERN = AEApi.instance().definitions().items().encodedPattern().maybeStack(1)
.orNull();

/**
* Post render hooks. All are called.
*/
Expand Down Expand Up @@ -89,15 +96,27 @@ public void renderItemOverlayIntoGUI(final FontRenderer fontRenderer, final Text
}

// Display "craftable" text
if (is.stackSize == 0 && showCraftLabelText && this.aeStack != null && this.aeStack.isCraftable()) {
final String craftLabelText = fontSize == TerminalFontSize.SMALL ? GuiText.SmallFontCraft.getLocal()
: GuiText.LargeFontCraft.getLocal();

GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
this.drawStackSize(par4, par5, craftLabelText, fontRenderer, fontSize);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
if (showCraftLabelText && this.aeStack != null && this.aeStack.isCraftable()) {
if (is.stackSize == 0) {
final String craftLabelText = fontSize == TerminalFontSize.SMALL ? GuiText.SmallFontCraft.getLocal()
: GuiText.LargeFontCraft.getLocal();

GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
this.drawStackSize(par4, par5, craftLabelText, fontRenderer, fontSize);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
} else {
if (this.parent != null) {
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
GL11.glScalef(0.4f, 0.4f, 0.4f);
this.parent.drawItem((int) ((par4 + 10) * 2.5), (int) (par5 * 2.5), PATTERN);
GL11.glScalef(2.5f, 2.5f, 2.5f);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
}
}
}

// Display stack quantity
Expand Down

0 comments on commit 69f9368

Please sign in to comment.