Skip to content

Commit

Permalink
Merge remote-tracking branch 'Laiff/feature/level-maintainer-terminal…
Browse files Browse the repository at this point in the history
…' into dev
  • Loading branch information
Dream-Master committed Oct 13, 2023
2 parents 1058e60 + 1a81100 commit 0fe7875
Show file tree
Hide file tree
Showing 63 changed files with 4,090 additions and 464 deletions.
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();
}
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 @@ -8,25 +8,26 @@
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;
}
Expand All @@ -37,17 +38,20 @@ public void initGui() {
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL, 1));
else if (host instanceof PartFluidPatternTerminalEx)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERMINAL_EX, 1));
else if (host instanceof PartFluidTerminal) {
else if (host instanceof PartFluidTerminal)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1));
} else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) {
else if (host instanceof PartLevelTerminal)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.LEVEL_TERMINAL, 1));
else if (host instanceof IWirelessTerminal terminal && terminal.isUniversal(host))
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1));
} else if (host instanceof WirelessFluidTerminalInventory) {
else if (host instanceof WirelessFluidTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_FLUID_TERM, 1));
} else if (host instanceof WirelessPatternTerminalInventory) {
else if (host instanceof WirelessPatternTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1));
} else if (host instanceof WirelessInterfaceTerminalInventory) {
else if (host instanceof WirelessInterfaceTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_INTERFACE_TERM, 1));
}
else if (host instanceof WirelessLevelTerminalInventory)
Ae2ReflectClient.rewriteIcon(this, new ItemStack(ItemAndBlockHolder.WIRELESS_LEVEL_TERM, 1));
super.initGui();
originalGuiBtn = Ae2ReflectClient.getOriginalGuiButton(this);
}
Expand All @@ -59,6 +63,7 @@ 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 PartLevelTerminal) InventoryHandler.switchGui(GuiType.LEVEL_TERMINAL);
else if (host instanceof IWirelessTerminal && ((IWirelessTerminal) host).isUniversal(host)) InventoryHandler
.switchGui(ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) host).getItemStack()));
else if (host instanceof WirelessFluidTerminalInventory)
Expand All @@ -67,6 +72,8 @@ 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
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
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.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.loader.ItemAndBlockHolder;
import com.glodblock.github.network.CPacketCraftRequest;
Expand Down Expand Up @@ -73,12 +75,18 @@ protected void setOriginGUI(Object target) {
} else if (target instanceof PartFluidTerminal) {
this.myIcon = new ItemStack(ItemAndBlockHolder.FLUID_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof PartLevelTerminal) {
myIcon = new ItemStack(ItemAndBlockHolder.LEVEL_TERMINAL, 1);
originalGui = GuiType.LEVEL_TERMINAL;
} else if (target instanceof IWirelessTerminal && ((IWirelessTerminal) target).isUniversal(target)) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_ULTRA_TERM, 1);
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) target).getItemStack());
} else if (target instanceof WirelessPatternTerminalInventory) {
this.myIcon = new ItemStack(ItemAndBlockHolder.WIRELESS_PATTERN_TERM, 1);
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (target instanceof WirelessLevelTerminalInventory) {
myIcon = new ItemStack(ItemAndBlockHolder.LEVEL_TERMINAL, 1);
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,33 +6,39 @@
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.PartLevelTerminal;
import com.glodblock.github.inventory.gui.GuiType;
import com.glodblock.github.inventory.item.IWirelessTerminal;
import com.glodblock.github.inventory.item.WirelessLevelTerminalInventory;
import com.glodblock.github.inventory.item.WirelessPatternTerminalInventory;
import com.glodblock.github.network.CPacketSwitchGuis;

import appeng.api.storage.ITerminalHost;
import appeng.client.gui.implementations.GuiCraftConfirm;

public class GuiFluidCraftConfirm extends GuiCraftConfirm {
public class GuiFluidCraftConfirm extends GuiCraftConfirm implements IGuiTooltipHandler {

private GuiType OriginalGui;
private GuiType originalGui;

public GuiFluidCraftConfirm(final InventoryPlayer inventoryPlayer, final ITerminalHost te) {
super(inventoryPlayer, te);
if (te instanceof PartFluidPatternTerminal) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL;
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL;
} else if (te instanceof PartFluidPatternTerminalEx) {
this.OriginalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
this.originalGui = GuiType.FLUID_PATTERN_TERMINAL_EX;
} else if (te instanceof PartLevelTerminal) {
originalGui = GuiType.LEVEL_TERMINAL;
} else if (te instanceof IWirelessTerminal && ((IWirelessTerminal) te).isUniversal(te)) {
this.OriginalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) te).getItemStack());
this.originalGui = ItemWirelessUltraTerminal.readMode(((IWirelessTerminal) te).getItemStack());
} else if (te instanceof WirelessPatternTerminalInventory) {
this.OriginalGui = GuiType.FLUID_TERMINAL;
this.originalGui = GuiType.FLUID_TERMINAL;
} else if (te instanceof WirelessLevelTerminalInventory) {
originalGui = GuiType.WIRELESS_LEVEL_TERMINAL;
}
}

@Override
public void switchToOriginalGUI() {
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.OriginalGui));
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(this.originalGui));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected void addButtons() {
@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
this.fontRendererObj.drawString(
NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER),
getGuiDisplayName(NameConst.i18n(NameConst.GUI_FLUID_LEVEL_EMITTER)),
8,
6,
GuiColors.UpgradableTitle.getColor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
import appeng.integration.IntegrationType;
import appeng.util.Platform;

public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropToFillTextField {
public class GuiInterfaceWireless extends FCBaseMEGui implements IDropToFillTextField {

protected int offsetY;
private static final int MAGIC_HEIGHT_NUMBER = 52 + 99;
Expand Down Expand Up @@ -93,7 +93,7 @@ public class GuiInterfaceTerminalWireless extends FCBaseMEGui implements IDropTo

private static final String MOLECULAR_ASSEMBLER = "tile.appliedenergistics2.BlockMolecularAssembler";

public GuiInterfaceTerminalWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
public GuiInterfaceWireless(final InventoryPlayer inventoryPlayer, final IWirelessTerminal te) {
super(inventoryPlayer, new ContainerInterfaceWireless(inventoryPlayer, te));

this.setScrollBar(new GuiScrollbar());
Expand Down Expand Up @@ -248,7 +248,7 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final
GuiColors.InterfaceTerminalTitle.getColor());
fontRendererObj.drawString(
GuiText.inventory.getLocal(),
GuiInterfaceTerminalWireless.offsetX + 2,
GuiInterfaceWireless.offsetX + 2,
this.ySize - 96,
GuiColors.InterfaceTerminalInventory.getColor());

Expand Down Expand Up @@ -279,7 +279,7 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final

this.fontRendererObj.drawString(
name + postfix,
GuiInterfaceTerminalWireless.offsetX + 3,
GuiInterfaceWireless.offsetX + 3,
6 + offset,
GuiColors.InterfaceTerminalName.getColor());
}
Expand All @@ -288,6 +288,7 @@ public void drawFG(final int offsetX, final int offsetY, final int mouseX, final
}
}

@SuppressWarnings("unchecked")
@Override
public void drawScreen(final int mouseX, final int mouseY, final float btn) {

Expand Down Expand Up @@ -383,7 +384,6 @@ protected void actionPerformed(final GuiButton btn) {
blockPos.getDimension(),
blockPos.getSide()));
} else {

WorldCoord blockPos2 = new WorldCoord(
(int) mc.thePlayer.posX,
(int) mc.thePlayer.posY,
Expand Down
Loading

0 comments on commit 0fe7875

Please sign in to comment.