Fix zIndexes for compatability with DuraDisplay

This commit is contained in:
Andrei Laiff committed 2023-10-22 21:50:46 +03:00
1 parent 63b507edb0
commit e09fc05ba2
7 files changed
+187 -77

No files matched your search

+37 -2
View File
@@ -1,5 +1,38 @@
// Add your dependencies here
/*
* Add your dependencies here. Supported configurations:
* - api("group:name:version:classifier"): if you use the types from this dependency in the public API of this mod
* Available at runtime and compiletime for mods depending on this mod
* - implementation("g:n:v:c"): if you need this for internal implementation details of the mod, but none of it is visible via the public API
* Available at runtime but not compiletime for mods depending on this mod
* - compileOnly("g:n:v:c"): if the mod you're building doesn't need this dependency during runtime at all, e.g. for optional mods
* Not available at all for mods depending on this mod, only visible at compiletime for this mod
* - compileOnlyApi("g:n:v:c"): like compileOnly, but also visible at compiletime for mods depending on this mod
* Available at compiletime but not runtime for mods depending on this mod
* - runtimeOnlyNonPublishable("g:n:v:c"): if you want to include a mod in this mod's runClient/runServer runs, but not publish it as a dependency
* Not available at all for mods depending on this mod, only visible at runtime for this mod
* - devOnlyNonPublishable("g:n:v:c"): a combination of runtimeOnlyNonPublishable and compileOnly for dependencies present at both compiletime and runtime,
* but not published as Maven dependencies - useful for RFG-deobfuscated dependencies or local testing
* - runtimeOnly("g:n:v:c"): if you don't need this at compile time, but want it to be present at runtime
* Available at runtime for mods depending on this mod
* - annotationProcessor("g:n:v:c"): mostly for java compiler plugins, if you know you need this, use it, otherwise don't worry
* - testCONFIG("g:n:v:c") - replace CONFIG by one of the above (except api), same as above but for the test sources instead of main
*
* - shadowImplementation("g:n:v:c"): effectively the same as API, but the dependency is included in your jar under a renamed package name
* Requires you to enable usesShadowedDependencies in gradle.properties
*
* - compile("g:n:v:c"): deprecated, replace with "api" (works like the old "compile") or "implementation" (can be more efficient)
*
* You can exclude transitive dependencies (dependencies of the chosen dependency) by appending { transitive = false } if needed,
* but use this sparingly as it can break using your mod as another mod's dependency if you're not careful.
*
* To depend on obfuscated jars you can use `devOnlyNonPublishable(rfg.deobf("dep:spec:1.2.3"))` to fetch an obfuscated jar from maven,
* or `devOnlyNonPublishable(rfg.deobf(project.files("libs/my-mod-jar.jar")))` to use a file.
*
* Gradle names for some of the configuration can be misleading, compileOnlyApi and runtimeOnly both get published as dependencies in Maven, but compileOnly does not.
* The buildscript adds runtimeOnlyNonPublishable to also have a runtime dependency that's not published.
*
* For more details, see https://docs.gradle.org/8.0.1/userguide/java_library_plugin.html#sec:java_library_configurations_graph
*/
dependencies {
api('com.github.GTNewHorizons:NotEnoughItems:2.4.5-GTNH:dev')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-268-GTNH-pre:dev')
@@ -22,4 +55,6 @@ dependencies {
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.13-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.17:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.14:dev") { transitive = false }
runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.1.7:dev")
}
@@ -100,11 +100,13 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
* Z-level Map (FLOATS) 0.0 - BACKGROUND 1.0 - ItemStacks 2.0 - Slot color overlays 20.0 - ItemStack overlays 21.0 -
* Slot mouse hover overlay 200.0 - Tooltips
*/
private static final float ITEMSTACK_Z = 1.0f;
private static final float ITEM_STACK_Z = 100.0f;
private static final float SLOT_Z = 0.5f;
private static final float ITEMSTACK_OVERLAY_Z = 20.0f;
private static final float SLOT_HOVER_Z = 31.0f;
private static final float TOOLTIP_Z = 200.0f;
private static final float ITEM_STACK_OVERLAY_Z = 200.0f;
private static final float SLOT_HOVER_Z = 310.0f;
private static final float TOOLTIP_Z = 210.0f;
private static final float STEP_Z = 10.0f;
private static final float MAGIC_RENDER_ITEM_Z = 50.0f;
protected int offsetY;
@@ -409,31 +411,19 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
/*
* Render title
*/
GL11.glTranslatef(0.0f, 0.0f, 50f);
bindTexture(BACKGROUND);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < IfaceSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + IfaceSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj.drawString(section.name, 2, sectionBottom - IfaceSection.TITLE_HEIGHT + 2, fontColor);
title = sectionBottom;
} else if (viewY < 0) {
/* Hidden title draw */
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
title = 0;
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -50f);
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Iterator<IfaceEntry> visible = section.getVisible();
@@ -451,6 +441,32 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
entry.optionsButton.yPosition = -1;
}
}
bindTexture(BACKGROUND);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < IfaceSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + IfaceSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj.drawString(section.name, 2, sectionBottom - IfaceSection.TITLE_HEIGHT + 2, fontColor);
} else if (viewY < 0) {
/* Hidden title draw */
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0.0f, 0.0f, 100f);
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
GL11.glEnable(GL11.GL_DEPTH_TEST);
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, IfaceSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
}
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
return IfaceSection.TITLE_HEIGHT + renderY;
}
@@ -538,23 +554,23 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
final ItemStack toRender = iep.getOutput(stack);
GL11.glPushMatrix();
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEMSTACK_Z);
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
translatedRenderItem.zLevel = 3.0f - 50.0f;
translatedRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
translatedRenderItem
.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
GL11.glTranslatef(0.0f, 0.0f, ITEMSTACK_OVERLAY_Z - ITEMSTACK_Z);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
aeRenderItem.setAeStack(AEItemStack.create(toRender));
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), toRender, 0, 0);
aeRenderItem.zLevel = 0.0f;
RenderHelper.disableStandardItemLighting();
if (!tooltip) {
if (entry.brokenRecipes[slotIdx]) {
GL11.glTranslatef(0.0f, 0.0f, SLOT_Z - ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(0.0f, 0.0f, SLOT_Z - ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayInvalid.getColor());
} else if (entry.filteredRecipes[slotIdx]) {
GL11.glTranslatef(0.0f, 0.0f, ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
}
} else {
@@ -563,7 +579,7 @@ public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillText
GL11.glPopMatrix();
} else if (entry.filteredRecipes[slotIdx]) {
GL11.glPushMatrix();
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEMSTACK_OVERLAY_Z);
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_OVERLAY_Z);
drawRect(0, 0, 16, 16, GuiColors.ItemSlotOverlayUnpowered.getColor());
GL11.glPopMatrix();
}
@@ -263,19 +263,6 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
}
}
this.input = null;
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
ItemStack currentStack = this.cont.getPlayerInv().getItemStack();
if (getSlotArea(slot).contains(xCoord, yCoord) && currentStack != null) {
ItemStack itemStack = createLevelValues(currentStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
return;
}
}
}
super.mouseClicked(xCoord, yCoord, btn);
}
@@ -370,6 +357,17 @@ public class GuiLevelMaintainer extends AEBaseGui implements INEIGuiHandler {
if (draggedStack != null) {
draggedStack.stackSize = 0;
}
for (int i = 0; i < this.cont.getRequestSlots().length; i++) {
SlotFluidConvertingFake slot = this.cont.getRequestSlots()[i];
if (getSlotArea(slot).contains(mouseX, mouseY) && draggedStack != null) {
ItemStack itemStack = createLevelValues(draggedStack.copy());
itemStack.getTagCompound().setInteger(TLMTags.Index.tagName, i);
slot.putStack(itemStack);
NetworkHandler.instance.sendToServer(new PacketNEIDragClick(itemStack, slot.getSlotIndex()));
this.updateAmount(slot.getSlotIndex(), itemStack.stackSize);
return true;
}
}
return false;
}
@@ -81,6 +81,7 @@ import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;
import appeng.util.item.AEItemStack;
import cpw.mods.fml.common.Loader;
@@ -114,11 +115,13 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
// private GuiFCImgButton modeSwitchEdit;
private final LevelTerminalList masterList = new LevelTerminalList();
private final List<String> extraOptionsText = new ArrayList<>(2);
private static final float ITEM_STACK_Z = 1.0f;
private static final float ITEM_STACK_Z = 100.0f;
private static final float SLOT_Z = 0.5f;
private static final float ITEM_STACK_OVERLAY_Z = 20.0f;
private static final float SLOT_HOVER_Z = 31.0f;
private static final float TOOLTIP_Z = 200.0f;
private static final float ITEM_STACK_OVERLAY_Z = 200.0f;
private static final float SLOT_HOVER_Z = 310.0f;
private static final float TOOLTIP_Z = 210.0f;
private static final float STEP_Z = 10.0f;
private static final float MAGIC_RENDER_ITEM_Z = 50.0f;
public GuiLevelTerminal(InventoryPlayer inventoryPlayer, Container container) {
super(inventoryPlayer, container);
@@ -440,32 +443,14 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
/*
* Render title
*/
GL11.glTranslatef(0.0f, 0.0f, 50f);
mc.getTextureManager().bindTexture(TEX_BG);
if (sectionBottom > 0 && sectionBottom < LevelTerminalSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj
.drawString(section.name, 2, sectionBottom - LevelTerminalSection.TITLE_HEIGHT + 2, fontColor);
title = sectionBottom;
} else if (viewY < 0) {
/* Hidden title draw */
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
title = 0;
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
title = 0;
}
GL11.glTranslatef(0.0f, 0.0f, -50f);
GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
Iterator<LevelTerminalEntry> visible = section.getVisible();
@@ -485,6 +470,36 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
entry.configButton.yPosition = -1;
}
}
/*
* Render title
*/
mc.getTextureManager().bindTexture(TEX_BG);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z);
if (sectionBottom > 0 && sectionBottom < LevelTerminalSection.TITLE_HEIGHT) {
/* Transition draw */
drawTexturedModalRect(
0,
0,
VIEW_LEFT,
HEADER_HEIGHT + LevelTerminalSection.TITLE_HEIGHT - sectionBottom,
VIEW_WIDTH,
sectionBottom);
fontRendererObj
.drawString(section.name, 2, sectionBottom - LevelTerminalSection.TITLE_HEIGHT + 2, fontColor);
} else if (viewY < 0) {
/* Hidden title draw */
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0.0f, 0.0f, 100f);
drawTexturedModalRect(0, 0, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, 2, fontColor);
GL11.glEnable(GL11.GL_DEPTH_TEST);
} else {
/* Normal title draw */
drawTexturedModalRect(0, viewY, VIEW_LEFT, HEADER_HEIGHT, VIEW_WIDTH, LevelTerminalSection.TITLE_HEIGHT);
fontRendererObj.drawString(section.name, 2, viewY + 2, fontColor);
}
GL11.glTranslatef(0.0f, 0.0f, -(ITEM_STACK_OVERLAY_Z + ITEM_STACK_Z + STEP_Z));
return LevelTerminalSection.TITLE_HEIGHT + renderY;
}
@@ -583,21 +598,13 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
GL11.glTranslatef(colLeft, viewY + rowYTop + 1, ITEM_STACK_Z);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
RenderHelper.enableGUIStandardItemLighting();
aeItemStack.setStackSize(1);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.zLevel = 3.0f - 50.0f;
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aeRenderItem.zLevel = 0.0f;
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
itemStack.stackSize = 1;
aeItemStack.setStackSize(quantity);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem.zLevel = ITEM_STACK_Z - MAGIC_RENDER_ITEM_Z;
aeRenderItem.renderItemAndEffectIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
aeRenderItem.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, 0);
if (batch > 0) {
aeItemStack.setStackSize(batch);
aeRenderItem.setAeStack(aeItemStack);
aeRenderItem
.renderItemOverlayIntoGUI(fontRendererObj, mc.getTextureManager(), itemStack, 0, -11);
}
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
int color = switch (state) {
case Idle -> FCGuiColors.StateIdle.getColor();
case Craft -> FCGuiColors.StateCraft.getColor();
@@ -608,6 +615,11 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
int offset = 0;
int size = 4;
drawRect(offset, offset, offset + size, offset + size, color);
GL11.glTranslatef(0.0f, 0.0f, ITEM_STACK_OVERLAY_Z - ITEM_STACK_Z);
this.drawReadableAmount(fontRendererObj, quantity, 16.0f, 12f, 16777215);
if (batch > 0) {
this.drawReadableAmount(fontRendererObj, batch, 16.0f, 1f, 16777215);
}
RenderHelper.disableStandardItemLighting();
/*
@@ -645,6 +657,45 @@ public class GuiLevelTerminal extends FCBaseMEGui implements IDropToFillTextFiel
return relY + 1;
}
public void drawReadableAmount(final FontRenderer fontRenderer, long amount, float x, float y, int color) {
final float scaleFactor = AEConfig.instance.useTerminalUseLargeFont() ? 0.85f : 0.5f;
final float inverseScaleFactor = 1.0f / scaleFactor;
final int offset = AEConfig.instance.useTerminalUseLargeFont() ? 0 : -1;
final boolean unicodeFlag = fontRenderer.getUnicodeFlag();
final String stackSize = this.getToBeRenderedStackSize(amount);
fontRenderer.setUnicodeFlag(false);
GL11.glDisable(GL11.GL_LIGHTING);
GL11.glPushMatrix();
GL11.glScaled(scaleFactor, scaleFactor, scaleFactor);
final int X = (int) (((float) x + offset - fontRenderer.getStringWidth(stackSize) * scaleFactor)
* inverseScaleFactor);
final int Y = (int) (((float) y + offset * scaleFactor) * inverseScaleFactor);
fontRenderer.drawString(stackSize, X + 1, Y, 0);
fontRenderer.drawString(stackSize, X - 1, Y, 0);
fontRenderer.drawString(stackSize, X, Y + 1, 0);
fontRenderer.drawString(stackSize, X, Y - 1, 0);
fontRenderer.drawString(stackSize, X, Y, color);
GL11.glPopMatrix();
GL11.glEnable(GL11.GL_LIGHTING);
fontRenderer.setUnicodeFlag(unicodeFlag);
}
private String getToBeRenderedStackSize(final long originalSize) {
if (AEConfig.instance.useTerminalUseLargeFont()) {
return ReadableNumberConverter.INSTANCE.toSlimReadableForm(originalSize);
} else {
return ReadableNumberConverter.INSTANCE.toWideReadableForm(originalSize);
}
}
@SuppressWarnings("unchecked")
@Override
public void drawHoveringText(List textLines, int x, int y, FontRenderer font) {
@@ -135,10 +135,10 @@ public class ContainerLevelMaintainer extends AEBaseContainer {
data.setTag(TLMTags.Stack.tagName, itemStackTag);
}
if (!data.hasKey(TLMTags.Quantity.tagName)) {
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize);
data.setLong(TLMTags.Quantity.tagName, itemStack.stackSize > 0 ? itemStack.stackSize : 1);
}
if (!data.hasKey(TLMTags.Batch.tagName)) {
data.setLong(TLMTags.Batch.tagName, 0);
data.setLong(TLMTags.Batch.tagName, 1);
}
if (!data.hasKey(TLMTags.Enable.tagName)) {
data.setBoolean(TLMTags.Enable.tagName, false);
@@ -1,13 +1,15 @@
package com.glodblock.github.nei;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.item.ItemStack;
import com.glodblock.github.client.gui.GuiFluidMonitor;
import com.glodblock.github.client.gui.GuiItemMonitor;
import com.glodblock.github.client.gui.GuiLevelMaintainer;
import codechicken.nei.api.INEIGuiAdapter;
public class NEIGuiHandler extends INEIGuiAdapter {
public class AE2FC_NEIGuiHandler extends INEIGuiAdapter {
@Override
public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
@@ -18,4 +20,12 @@ public class NEIGuiHandler extends INEIGuiAdapter {
}
return false;
}
@Override
public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemStack draggedStack, int button) {
if (gui instanceof GuiLevelMaintainer guiLevelMaintainer) {
return guiLevelMaintainer.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button);
}
return super.handleDragNDrop(gui, mouseX, mouseY, draggedStack, button);
}
}
@@ -17,7 +17,7 @@ public class NEI_FC_Config implements IConfigureNEI {
@Override
public void loadConfig() {
API.registerNEIGuiHandler(new NEIGuiHandler());
API.registerNEIGuiHandler(new AE2FC_NEIGuiHandler());
API.addSearchProvider(new NEIItemFilter());
API.registerStackStringifyHandler(new FCStackStringifyHandler());