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

Add LevelMaintainerTerminal rework logic inside TileLevelMaintainer #162

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
ef2281f
Use new interface terminal API
firenoo Sep 27, 2023
42d7eb3
Update dependencies.gradle
Dream-Master Oct 12, 2023
11fd470
Merge branch 'master' into fix_interface_term
Dream-Master Oct 12, 2023
dbc5f41
Merge branch 'master' into fix_interface_term
Dream-Master Oct 13, 2023
3ab27d4
feat: Update core hooks and integrations
Laiff Oct 12, 2023
d025c1f
api: Add `LevelTerminalRegistry` functionality
Laiff Oct 12, 2023
827bbf8
feat: Use `customName` to display in `GuiFluidLevelEmitter`
Laiff Oct 12, 2023
f26d18e
feat: Rework scheduling and data storage in `TileLevelMaintainer` fun…
Laiff Oct 12, 2023
1eadad7
feat: Add new item `LevelTerminal`
Laiff Oct 12, 2023
e78194e
feat: Support back navigation functionality
Laiff Oct 12, 2023
cf3e18a
feat: add back navigation in `LevelMaintainer` from terminal
Laiff Oct 13, 2023
42741d8
use `IGuiTooltipHandler` directly from ae2
Laiff Oct 13, 2023
8ba192c
fix correct `InterfaceTerminalSupportedClassProvider` deprecation
Laiff Oct 13, 2023
79e6448
Implement new version of `InterfaceWireless` based on `InterfaceTermi…
Laiff Oct 14, 2023
f94792b
Fix `LevelTerminal` data recursion and few in fixes gui
Laiff Oct 14, 2023
c429150
Use `aeRenderItem` directly and fix `zIndex` in custom slots
Laiff Oct 15, 2023
0ab8777
Fix rendering numbers bigger than 2.1G through `aeRenderItem`
Laiff Oct 17, 2023
0a3e7de
Fix fails on `getCraftingItem`
Laiff Oct 17, 2023
7ac1c2f
Fix add packet logging and try to not fail after receive corrupted pa…
Laiff Oct 17, 2023
a93f3f5
Fix add logging around empty configuration
Laiff Oct 17, 2023
c92fa2a
Fix packet corruption and log invalid data
Laiff Oct 17, 2023
ffb3b05
Fix packet corruption with level emitters
Laiff Oct 18, 2023
c341f22
Correct handle overwrite packet
Laiff Oct 20, 2023
63b507e
Fix intercept dnd click from GT5 hook for `AppEngGuiHandler`
Laiff Oct 21, 2023
d8877db
Merge remote-tracking branch 'origin/fix_interface_term' into dev
Dream-Master Oct 21, 2023
7a1adb4
update be+deps
Dream-Master Oct 21, 2023
3101820
Update dependencies.gradle
Dream-Master Oct 22, 2023
6d646f8
Update dependencies.gradle
Dream-Master Oct 22, 2023
e09fc05
Fix `zIndexes` for compatability with `DuraDisplay`
Laiff Oct 22, 2023
f76e053
Update AE2 and fix compatability
Laiff Oct 22, 2023
f8dd818
Merge branch 'dev' into feature/level-maintainer-terminal
Dream-Master Oct 22, 2023
3a87975
Change `ForgeDirection` side serialization to `byte`
Laiff Oct 23, 2023
8d8b7d0
Fix tooltip zIndexes
Laiff Oct 23, 2023
a34049a
Rename all rest parts related to `Level terminal`
Laiff Oct 25, 2023
6de4e6f
Merge remote-tracking branch 'gtnh/master' into feature/level-maintai…
Laiff Oct 25, 2023
b9fddcc
Code cleanup after review
Laiff Oct 26, 2023
bc21d4c
Remove duplicated dependency declaration
Laiff Oct 27, 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
47 changes: 41 additions & 6 deletions dependencies.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,48 @@
// 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-262-GTNH: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')
compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')

compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
compileOnly("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.1:dev")
implementation("com.github.GTNewHorizons:WirelessCraftingTerminal:1.10.1:dev")

compileOnly('com.github.GTNewHorizons:Baubles:1.0.1.16:dev')
compileOnly('com.github.GTNewHorizons:ExtraCells2:2.5.34:dev') { transitive = false }
compileOnly('com.github.GTNewHorizons:ForestryMC:4.6.14:dev')
compileOnly('com.github.GTNewHorizons:EnderIO:2.5.3:dev')
compileOnly('com.github.GTNewHorizons:GT5-Unofficial:5.09.44.64:dev') {
Expand All @@ -21,4 +54,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.19:dev") { transitive = false }

runtimeOnlyNonPublishable("com.github.GTNewHorizons:DuraDisplay:1.1.7:dev")
}
8 changes: 8 additions & 0 deletions src/main/java/com/glodblock/github/api/FluidCraftAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

import net.minecraftforge.fluids.Fluid;

import com.glodblock.github.api.registries.ILevelTerminalRegistry;
import com.glodblock.github.coremod.registries.LevelTerminalRegistry;

public final class FluidCraftAPI implements IFluidCraftAPI {

private static final FluidCraftAPI API = new FluidCraftAPI();
Expand Down Expand Up @@ -42,4 +45,9 @@ public boolean isBlacklistedInStorage(Class<? extends Fluid> fluid) {
public boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid) {
return blacklistedDispFluids.contains(fluid);
}

@Override
public ILevelTerminalRegistry levelTerminalRegistry() {
return LevelTerminalRegistry.instance();
}
}
7 changes: 7 additions & 0 deletions src/main/java/com/glodblock/github/api/IFluidCraftAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import net.minecraftforge.fluids.Fluid;

import com.glodblock.github.api.registries.ILevelTerminalRegistry;

@SuppressWarnings("unused")
public interface IFluidCraftAPI {

Expand All @@ -24,4 +26,9 @@ public interface IFluidCraftAPI {
* Mostly for internal use; queries whether the fluid is blacklisted from being displayed.
*/
boolean isBlacklistedInDisplay(Class<? extends Fluid> fluid);

/**
* Get instance of `ILevelTerminalRegistry` to add new supported machines into terminal
*/
ILevelTerminalRegistry levelTerminalRegistry();
}
8 changes: 8 additions & 0 deletions src/main/java/com/glodblock/github/api/ISide.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.glodblock.github.api;

import net.minecraftforge.common.util.ForgeDirection;

public interface ISide {

ForgeDirection getSide();
Laiff marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.glodblock.github.api.registries;

import java.util.Set;

import appeng.api.networking.IGridHost;

public interface ILevelTerminalRegistry {

void register(Class<? extends ILevelViewable> clazz);

void register(Class<? extends IGridHost> aeClass, ILevelViewableAdapter adapter);

Set<Class<? extends ILevelViewable>> getSupportedClasses();

boolean isAdopted(Class<? extends ILevelViewable> clazz);

Class<? extends IGridHost> getAdopted(Class<? extends ILevelViewable> clazz);

ILevelViewableAdapter getAdapter(Class<? extends ILevelViewable> clazz);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package com.glodblock.github.api.registries;

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

import com.glodblock.github.api.ISide;

import appeng.api.implementations.tiles.ISegmentedInventory;
import appeng.api.networking.IGridHost;
import appeng.api.util.DimensionalCoord;
import appeng.helpers.ICustomNameObject;

public interface ILevelViewable extends IGridHost, ISide, ISegmentedInventory, ICustomNameObject {

DimensionalCoord getLocation();

TileEntity getTile();

default long getSortValue() {
TileEntity te = getTile();
return ((long) te.zCoord << 24) ^ ((long) te.xCoord << 8) ^ te.yCoord;
}

default boolean shouldDisplay() {
return true;
}

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

/**
* Number of slots per row.
*/
default int rowSize() {
return 1;
};

default ItemStack getSelfItemStack() {
return null;
}

/**
* "Target" Display representation
*/
default ItemStack getDisplayItemStack() {
return null;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.glodblock.github.api.registries;

import appeng.api.networking.IGridHost;

public interface ILevelViewableAdapter extends ILevelViewable {

ILevelViewable adapt(IGridHost gridHost);
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,52 +2,55 @@

import net.minecraft.client.gui.GuiButton;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.item.ItemStack;

import com.glodblock.github.common.item.ItemWirelessUltraTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminal;
import com.glodblock.github.common.parts.PartFluidPatternTerminalEx;
import com.glodblock.github.common.parts.PartFluidTerminal;
import com.glodblock.github.common.parts.PartLevelTerminal;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessFluidTerminalInventory;
import com.glodblock.github.inventory.item.WirelessInterfaceTerminalInventory;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.util.Ae2ReflectClient;

import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftingStatus;
import appeng.client.gui.widgets.GuiTabButton;

public class GuiFluidPatternTerminalCraftingStatus extends GuiCraftingStatus {
public class GuiCraftingStatus extends appeng.client.gui.implementations.GuiCraftingStatus {

private GuiTabButton originalGuiBtn;
private final ITerminalHost host;

public GuiFluidPatternTerminalCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
public GuiCraftingStatus(InventoryPlayer inventoryPlayer, ITerminalHost te) {
super(inventoryPlayer, te);
host = te;
}

@Override
public void initGui() {
if (host instanceof PartFluidPatternTerminal)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL.stack());
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
else if (host instanceof PartFluidTerminal) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
} else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1));
} else if (host instanceof WirelessFluidTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
} else if (host instanceof WirelessPatternTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
} else if (host instanceof WirelessInterfaceTerminalInventory) {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
}
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERMINAL_EX.stack());
else if (host instanceof PartFluidTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.FLUID_TERM.stack());
else if (host instanceof PartLevelTerminal)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.LEVEL_TERMINAL.stack());
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_ULTRA_TERM.stack());
else if (host instanceof WirelessFluidTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_FLUID_TERM.stack());
else if (host instanceof WirelessPatternTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_PATTERN_TERM.stack());
else if (host instanceof WirelessInterfaceTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_INTERFACE_TERM.stack());
else if (host instanceof WirelessLevelTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, ItemAndBlockHolder.WIRELESS_LEVEL_TERM.stack());
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
Expand All @@ -59,14 +62,17 @@ protected void actionPerformed(final GuiButton btn) {
else if (host instanceof PartFluidPatternTerminalEx)
InventoryHandler.switchGui(GuiType.FLUID_PATTERN_TERMINAL_EX);
else if (host instanceof PartFluidTerminal) InventoryHandler.switchGui(GuiType.FLUID_TERMINAL);
else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
else if (host instanceof PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
InventoryHandler.switchGui(ItemWirelessUltraTerminal.readMode(terminal.getItemStack()));
else if (host instanceof WirelessFluidTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_TERMINAL);
else if (host instanceof WirelessPatternTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_FLUID_PATTERN_TERMINAL);
else if (host instanceof WirelessInterfaceTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_INTERFACE_TERMINAL);
else if (host instanceof WirelessLevelTerminalInventory)
InventoryHandler.switchGui(GuiType.WIRELESS_LEVEL_TERMINAL);
} else {
super.actionPerformed(btn);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

import org.lwjgl.input.Mouse;

import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerDualInterface;
import com.glodblock.github.common.parts.PartFluidInterface;
import com.glodblock.github.common.tile.TileFluidInterface;
import com.glodblock.github.inventory.InventoryHandler;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketSwitchGuis;
import com.glodblock.github.util.ModAndClassUtil;
import com.glodblock.github.util.NameConst;

Expand Down Expand Up @@ -148,9 +147,9 @@ protected void actionPerformed(final GuiButton btn) {
super.actionPerformed(btn);
final boolean backwards = Mouse.isButtonDown(1);
if (btn == this.priority) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.PRIORITY));
InventoryHandler.switchGui(GuiType.PRIORITY);
} else if (btn == this.switcher) {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
InventoryHandler.switchGui(GuiType.DUAL_INTERFACE_FLUID);
} else if (btn == this.interfaceMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(Settings.INTERFACE_TERMINAL, backwards));
} else if (btn == this.BlockMode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import net.minecraft.item.ItemStack;
import net.minecraftforge.fluids.FluidStack;

import org.lwjgl.opengl.GL11;

import com.glodblock.github.FluidCraft;
import com.glodblock.github.client.gui.container.ContainerEssentiaMonitor;
import com.glodblock.github.client.me.EssentiaRepo;
Expand All @@ -21,16 +23,13 @@
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.network.CPacketFluidUpdate;
import com.glodblock.github.util.Ae2ReflectClient;

import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.me.SlotME;
import appeng.client.render.AppEngRenderItem;

public class GuiEssentiaTerminal extends GuiFluidMonitor {

private final AppEngRenderItem stackSizeRenderer = Ae2ReflectClient.getStackSizeRenderer(this);
protected EntityPlayer player;

public GuiEssentiaTerminal(InventoryPlayer inventoryPlayer, IWirelessTerminal te) {
Expand Down Expand Up @@ -64,13 +63,15 @@ public boolean drawSlot0(Slot slot) {
AspectUtil.getAspectFromGas(fluidStack),
fluidStack.amount);
IAEItemStack gas = stack.copy().setStackSize(stack.getStackSize() / AspectUtil.R);
stackSizeRenderer.setAeStack(gas);
stackSizeRenderer.renderItemOverlayIntoGUI(
aeRenderItem.setAeStack(gas);
GL11.glTranslatef(0.0f, 0.0f, 200.0f);
aeRenderItem.renderItemOverlayIntoGUI(
fontRendererObj,
mc.getTextureManager(),
gas.getItemStack(),
slot.xDisplayPosition,
slot.yDisplayPosition);
GL11.glTranslatef(0.0f, 0.0f, -200.0f);
return false;
}
return true;
Expand Down
11 changes: 11 additions & 0 deletions src/main/java/com/glodblock/github/client/gui/GuiFCImgButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ public GuiFCImgButton(final int x, final int y, final String idx, final String v
this.registerApp(15, "PATTERN_EX_TEM", "YES", "pattern_terminal_ex_w");
this.registerApp(16, "FILL_PATTERN", "DO_FILL", "fill_pattern");
this.registerApp(17, "NOT_FILL_PATTERN", "DONT_FILL", "not_fill_pattern");
this.registerApp(20, "LEVEL_TEM", "YES", "level_terminal_w");
this.registerApp(21, "SWITCH", "ON", "edit");
this.registerApp(22, "SWITCH", "OFF", "view");
this.registerApp(21, "SWITCH", "ENABLE", "enable");
this.registerApp(22, "SWITCH", "DISABLE", "disable");
this.registerApp(23, "CONFIG", "YES", "open_configuration");
this.registerApp(24, "HIGHLIGHT", "YES", "block_highlight");
}
}

Expand Down Expand Up @@ -110,6 +117,10 @@ public String getCurrentValue() {
return this.currentValue;
}

public boolean getMouseIn() {
return this.field_146123_n;
}

public void set(final String e) {
if (!this.currentValue.equals(e)) {
this.currentValue = e;
Expand Down
Loading