Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reduce interface terminal TPS impact + break some backends + new gui #394

Merged
merged 22 commits into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ac5832f
api/features: Move iface term functionality to API
firenoo Sep 11, 2023
ec392c1
me/cache: Add indication of booting/nonbooting to event
firenoo Sep 11, 2023
203c64c
appeng/core/sync/packets: Add PacketIfaceTermUpdate.java
firenoo Sep 12, 2023
a89f634
appeng/helpers: Use new iface terminal API
firenoo Sep 15, 2023
6597d85
appeng/container/implementations: Optimize iface terminal
firenoo Sep 15, 2023
247c189
appeng/client/render/AppEngRenderItem: Don't disable depth test
firenoo Sep 18, 2023
8bd7c66
appeng/client/gui/widgets: GuiImgButton.java: Add extra options button
firenoo Sep 21, 2023
893e7a6
appeng/client/gui: AEBaseGui.java: bind texture w/ ResourceLocation
firenoo Sep 21, 2023
ff006eb
appeng/client/gui/widgets: GuiScrollbar.java: Add visibility flag
firenoo Sep 27, 2023
6815d91
appeng/client/gui: Add IGuiTooltipHandler
firenoo Sep 24, 2023
1157a4f
appeng/client/gui/implementations: New Interface Terminal GUI
firenoo Sep 27, 2023
1e51d19
Add interface compatibility to use in `ae2fc` (#404)
Laiff Oct 14, 2023
0f3a7eb
Add interface compatibility to use in `ae2fc` and direction tracking …
Laiff Oct 14, 2023
3d3af96
Fix rendering inside `InterfaceTerminal` AEStack should be correctly set
Laiff Oct 15, 2023
38ceda9
Fix `zLevel` in `TranslatedRenderItem` for durability bar
Laiff Oct 15, 2023
c493a4f
Fix `TranslatedRenderItem` integrate `POST_HOOKS` to support DuraDisplay
Laiff Oct 15, 2023
0a366d6
Fix buffer read write inconsistency
Laiff Oct 20, 2023
ef03195
Fix `zIndexes` for compatability with `DuraDisplay`
Laiff Oct 22, 2023
eb78532
Use `IInterfaceViewable` to decide crafting location
Laiff Oct 22, 2023
7fe4981
Fix tooltip zIndex
Laiff Oct 23, 2023
56629f4
Replace `ForgeDirection` serialization with `byte`
Laiff Oct 23, 2023
f35c5af
Code cleanup after review
Laiff Oct 26, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/main/java/appeng/api/config/ActionItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ public enum ActionItems {
TOGGLE_SHOW_FULL_INTERFACES_OFF,
TOGGLE_SHOW_ONLY_INVALID_PATTERN_ON,
TOGGLE_SHOW_ONLY_INVALID_PATTERN_OFF,
HIGHLIGHT_INTERFACE
HIGHLIGHT_INTERFACE,
EXTRA_OPTIONS,
}
14 changes: 14 additions & 0 deletions src/main/java/appeng/api/features/IIfaceTermRegistry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package appeng.api.features;

import appeng.api.util.IIfaceTermViewable;

/**
* Registry for interface terminal support.
*/
public interface IIfaceTermRegistry {

/**
* Registers a class to be considered supported in interface terminals.
*/
void register(Class<? extends IIfaceTermViewable> clazz);
}
2 changes: 2 additions & 0 deletions src/main/java/appeng/api/features/IRegistryContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ public interface IRegistryContainer {
*/
IInscriberRegistry inscriber();

IIfaceTermRegistry ifaceTerm();

/**
* get access to the locatable registry
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,13 @@
* Note: Most machines just need to check {@link IGridNode}.isActive()
*/
public class MENetworkBootingStatusChange extends MENetworkEvent {

/**
* Indicates whether the network has changed to this state when the event is posted.
*/
public final boolean isBooting;

public MENetworkBootingStatusChange(boolean isBooting) {
this.isBooting = isBooting;
}
}
51 changes: 51 additions & 0 deletions src/main/java/appeng/api/util/IIfaceTermViewable.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package appeng.api.util;

import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;

import appeng.api.networking.IGridHost;

/**
* Replacement for {@code IInterfaceTerminalSupport} in API.
*/
public interface IIfaceTermViewable extends IGridHost {

DimensionalCoord getLocation();

/**
* Number of rows to expect. This is used with {@link #rowSize()} to determine how to render the slots.
*/
int rows();

/**
* Number of slots per row.
*/
int rowSize();

/**
* Get the patterns. If multiple rows are supported, this is assumed to be tightly packed. Use {@link #rowSize()}
* with {@link #rows()} to determine where a row starts.
*/
IInventory getPatterns();

String getName();

TileEntity getTileEntity();

boolean shouldDisplay();

/**
* Self representation
*/
default ItemStack getSelfRep() {
return null;
}

/**
* "Target" Display representation
*/
default ItemStack getDisplayRep() {
return null;
}
}
62 changes: 51 additions & 11 deletions src/main/java/appeng/client/gui/AEBaseGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import appeng.client.me.SlotDisconnected;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;
import appeng.client.render.TranslatedRenderItem;
import appeng.container.AEBaseContainer;
import appeng.container.slot.AppEngCraftingSlot;
import appeng.container.slot.AppEngSlot;
Expand Down Expand Up @@ -85,7 +86,8 @@ public abstract class AEBaseGui extends GuiContainer {
private final List<InternalSlotME> meSlots = new LinkedList<>();
// drag y
private final Set<Slot> drag_click = new HashSet<>();
private final AppEngRenderItem aeRenderItem = new AppEngRenderItem();
public static final AppEngRenderItem aeRenderItem = new AppEngRenderItem();
public static final TranslatedRenderItem translatedRenderItem = new TranslatedRenderItem();
private GuiScrollbar scrollBar = null;
private boolean disableShiftClick = false;
private Stopwatch dbl_clickTimer = Stopwatch.createStarted();
Expand Down Expand Up @@ -784,8 +786,10 @@ public void drawItem(final int x, final int y, final ItemStack is) {
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL12.GL_RESCALE_NORMAL);
GL11.glEnable(GL11.GL_DEPTH_TEST);
GL11.glTranslatef(0.0f, 0.0f, 101.0f);
RenderHelper.enableGUIStandardItemLighting();
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.renderEngine, is, x, y);
GL11.glTranslatef(0.0f, 0.0f, -101.0f);
GL11.glPopAttrib();

itemRender.zLevel = 0.0F;
Expand Down Expand Up @@ -817,10 +821,9 @@ private void drawSlot(final Slot s) {

RenderItem pIR = this.setItemRender(this.aeRenderItem);
try {
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;

if (!this.isPowered()) {
this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
GL11.glDisable(GL11.GL_LIGHTING);
drawRect(
s.xDisplayPosition,
Expand All @@ -829,14 +832,14 @@ private void drawSlot(final Slot s) {
16 + s.yDisplayPosition,
GuiColors.ItemSlotOverlayUnpowered.getColor());
GL11.glEnable(GL11.GL_LIGHTING);
}

this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
this.zLevel = 0.0F;
itemRender.zLevel = 0.0F;
} else {
this.aeRenderItem.setAeStack(Platform.getAEStackInSlot(s));

this.aeRenderItem.setAeStack(Platform.getAEStackInSlot(s));
this.drawAESlot(s);
}

this.safeDrawSlot(s);
} catch (final Exception err) {
AELog.warn("[AppEng] AE prevented crash while drawing slot: " + err.toString());
}
Expand Down Expand Up @@ -940,7 +943,7 @@ private void drawSlot(final Slot s) {

if (s instanceof AppEngSlot) {
((AppEngSlot) s).setDisplay(true);
this.safeDrawSlot(s);
this.drawMCSlot(s);
} else {
this.safeDrawSlot(s);
}
Expand All @@ -954,6 +957,39 @@ private void drawSlot(final Slot s) {
this.safeDrawSlot(s);
}

public void drawMCSlot(Slot slotIn) {
int i = slotIn.xDisplayPosition;
int j = slotIn.yDisplayPosition;
ItemStack itemstack = slotIn.getStack();
String s = null;

GL11.glEnable(GL11.GL_DEPTH_TEST);
translatedRenderItem.zLevel = 100.0f;
translatedRenderItem
.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j);
translatedRenderItem.zLevel = 200.0f;
translatedRenderItem
.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j, s);
translatedRenderItem.zLevel = 0.0f;
}

public void drawAESlot(Slot slotIn) {
int i = slotIn.xDisplayPosition;
int j = slotIn.yDisplayPosition;
ItemStack itemstack = slotIn.getStack();
String s = null;

this.zLevel = 100.0F;
itemRender.zLevel = 100.0F;
itemRender.renderItemAndEffectIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j);
itemRender.zLevel = 0.0F;

this.zLevel = 0.0F;
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(this.fontRendererObj, this.mc.getTextureManager(), itemstack, i, j, s);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
}

private RenderItem setItemRender(final RenderItem item) {
if (IntegrationRegistry.INSTANCE.isEnabled(IntegrationType.NEI)) {
return ((INEI) IntegrationRegistry.INSTANCE.getInstance(IntegrationType.NEI)).setItemRender(item);
Expand All @@ -979,6 +1015,10 @@ public void bindTexture(final String file) {
this.mc.getTextureManager().bindTexture(loc);
}

public void bindTexture(final ResourceLocation loc) {
mc.getTextureManager().bindTexture(loc);
}

public void func_146977_a(final Slot s) {
this.drawSlot(s);
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/appeng/client/gui/AEBaseMEGui.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,13 @@
import appeng.core.localization.ButtonToolTips;
import appeng.util.Platform;

public abstract class AEBaseMEGui extends AEBaseGui {
public abstract class AEBaseMEGui extends AEBaseGui implements IGuiTooltipHandler {

public AEBaseMEGui(final Container container) {
super(container);
}

@Override
public List<String> handleItemTooltip(final ItemStack stack, final int mouseX, final int mouseY,
final List<String> currentToolTip) {
if (stack != null) {
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/appeng/client/gui/IGuiTooltipHandler.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package appeng.client.gui;

import java.util.List;

import net.minecraft.item.ItemStack;

/**
* Interface for handling tooltips from NEIGuiContainerManager.
*/
public interface IGuiTooltipHandler {

default List<String> handleItemTooltip(final ItemStack stack, final int mouseX, final int mouseY,
final List<String> currentToolTip) {
return currentToolTip;
}

default ItemStack getHoveredStack() {
return null;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.IGuiTooltipHandler;
import appeng.client.gui.widgets.GuiCraftingCPUTable;
import appeng.client.gui.widgets.GuiCraftingTree;
import appeng.client.gui.widgets.GuiImgButton;
Expand Down Expand Up @@ -63,7 +64,7 @@
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;

public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolder {
public class GuiCraftConfirm extends AEBaseGui implements ICraftingCPUTableHolder, IGuiTooltipHandler {

public static final int TREE_VIEW_TEXTURE_WIDTH = 238;
public static final int TREE_VIEW_TEXTURE_HEIGHT = 238;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import appeng.api.util.DimensionalCoord;
import appeng.api.util.WorldCoord;
import appeng.client.gui.AEBaseGui;
import appeng.client.gui.IGuiTooltipHandler;
import appeng.client.gui.widgets.GuiScrollbar;
import appeng.client.gui.widgets.ISortSource;
import appeng.client.gui.widgets.ITooltip;
Expand All @@ -55,7 +56,7 @@
import appeng.util.Platform;
import appeng.util.ReadableNumberConverter;

public class GuiCraftingCPU extends AEBaseGui implements ISortSource {
public class GuiCraftingCPU extends AEBaseGui implements ISortSource, IGuiTooltipHandler {

private static final int GUI_HEIGHT = 184;
private static final int GUI_WIDTH = 238;
Expand Down Expand Up @@ -616,6 +617,7 @@ public Enum getSortDisplay() {
return ViewItems.ALL;
}

@Override
public ItemStack getHoveredStack() {
return hoveredStack;
}
Expand Down
Loading