Skip to content

Commit

Permalink
Feature/level maintainer terminal (#166)
Browse files Browse the repository at this point in the history
* Fix `zIndexes` for compatability with `DuraDisplay`

* Update AE2 and fix compatability

---------

Co-authored-by: Andrei Laiff <[email protected]>
  • Loading branch information
Dream-Master and Laiff authored Oct 22, 2023
1 parent 6d646f8 commit bad5622
Show file tree
Hide file tree
Showing 8 changed files with 264 additions and 141 deletions.
41 changes: 38 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,41 @@
// 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')
api('com.github.GTNewHorizons:Applied-Energistics-2-Unofficial:rv3-beta-271-GTNH-pre:dev')
api('curse.maven:cofh-core-69162:2388751')
api('com.github.GTNewHorizons:waila:1.6.2:dev')
api("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.1:dev")
Expand All @@ -23,4 +56,6 @@ dependencies {
compileOnly('com.github.GTNewHorizons:ThaumicEnergistics:1.4.13-GTNH:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:GTplusplus:1.10.21:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:Hodgepodge:2.3.18:dev") { transitive = false }

runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.1.7:dev")
}
197 changes: 113 additions & 84 deletions src/main/java/com/glodblock/github/client/gui/GuiInterfaceWireless.java

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -263,19 +263,6 @@ protected void mouseClicked(final int xCoord, final int yCoord, final int btn) {
}
}
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);
}
Expand Down Expand Up @@ -370,6 +357,17 @@ public boolean handleDragNDrop(GuiContainer gui, int mouseX, int mouseY, ItemSta
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;
}

Expand Down
119 changes: 85 additions & 34 deletions src/main/java/com/glodblock/github/client/gui/GuiLevelTerminal.java
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -440,32 +443,14 @@ private int drawSection(LevelTerminalSection section, int viewY, int relMouseX,
/*
* 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();
Expand All @@ -485,6 +470,36 @@ private int drawSection(LevelTerminalSection section, int viewY, int relMouseX,
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;
}

Expand Down Expand Up @@ -583,21 +598,13 @@ private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int
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();
Expand All @@ -608,6 +615,11 @@ private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int
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();

/*
Expand Down Expand Up @@ -645,6 +657,45 @@ private int drawEntry(LevelTerminalEntry entry, int viewY, int titleBottom, int
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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,10 +135,10 @@ public static ItemStack createLevelValues(ItemStack itemStack) {
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -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) {
Expand All @@ -18,4 +20,12 @@ public boolean hideItemPanelSlot(GuiContainer gui, int x, int y, int w, int h) {
}
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);
}
}
2 changes: 1 addition & 1 deletion src/main/java/com/glodblock/github/nei/NEI_FC_Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down
6 changes: 3 additions & 3 deletions src/main/java/com/glodblock/github/proxy/CommonProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public void postInit(FMLPostInitializationEvent event) {
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 1);
}
AEApi.instance().registries().externalStorage().addExternalStorageInterface(new AEFluidInterfaceHandler());
AEApi.instance().registries().ifaceTerm().register(PartFluidP2PInterface.class);
AEApi.instance().registries().ifaceTerm().register(PartFluidInterface.class);
AEApi.instance().registries().ifaceTerm().register(TileFluidInterface.class);
AEApi.instance().registries().interfaceTerminal().register(PartFluidP2PInterface.class);
AEApi.instance().registries().interfaceTerminal().register(PartFluidInterface.class);
AEApi.instance().registries().interfaceTerminal().register(TileFluidInterface.class);
}

public void registerRenderers() {}
Expand Down

0 comments on commit bad5622

Please sign in to comment.