Add support for the Advanced Blocking Card to Dual Interfaces (#123)

* Update ae2 to latest (beta-203)

* Add support for the Advanced Blocking Card to Dual Interfaces

Behavior: The Dual Interface acts in the same way as the regular ME
interface when the advanced blocking card is used, but has an additional
check for fluids on top of items contained in the ME system.
This commit is contained in:
firenoo authored and GitHub committed 2023-05-05 20:19:55 +02:00
1 parent d2df9beb31
commit 97c7533ffb
4 files changed
+32 -13

No files matched your search

@@ -6,10 +6,7 @@ import net.minecraft.util.StatCollector;
import org.lwjgl.input.Mouse;
import appeng.api.config.InsertionMode;
import appeng.api.config.Settings;
import appeng.api.config.SidelessMode;
import appeng.api.config.YesNo;
import appeng.api.config.*;
import appeng.client.gui.implementations.GuiUpgradeable;
import appeng.client.gui.widgets.GuiImgButton;
import appeng.client.gui.widgets.GuiTabButton;
@@ -38,6 +35,7 @@ public class GuiDualInterface extends GuiUpgradeable {
private GuiToggleButton interfaceMode;
private GuiImgButton insertionMode;
private GuiImgButton sidelessMode;
private GuiImgButton advancedBlockingMode;
private final IInterfaceHost host;
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
@@ -85,10 +83,17 @@ public class GuiDualInterface extends GuiUpgradeable {
InsertionMode.DEFAULT);
this.buttonList.add(this.insertionMode);
this.advancedBlockingMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 62,
Settings.ADVANCED_BLOCKING_MODE,
AdvancedBlockingMode.DEFAULT);
this.buttonList.add(this.advancedBlockingMode);
if (isTile()) {
this.sidelessMode = new GuiImgButton(
this.guiLeft - 18,
this.guiTop + 62,
this.guiTop + 80,
Settings.SIDELESS_MODE,
SidelessMode.SIDELESS);
this.buttonList.add(this.sidelessMode);
@@ -110,7 +115,9 @@ public class GuiDualInterface extends GuiUpgradeable {
if (this.sidelessMode != null) {
this.sidelessMode.set(((ContainerDualInterface) this.cvb).getSidelessMode());
}
if (this.advancedBlockingMode != null) {
this.advancedBlockingMode.set(((ContainerDualInterface) this.cvb).getAdvancedBlockingMode());
}
this.fontRendererObj.drawString(
getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)),
8,
@@ -160,6 +167,10 @@ public class GuiDualInterface extends GuiUpgradeable {
if (btn == this.sidelessMode) {
NetworkHandler.instance.sendToServer(new PacketConfigButton(this.sidelessMode.getSetting(), backwards));
}
if (btn == this.advancedBlockingMode) {
NetworkHandler.instance
.sendToServer(new PacketConfigButton(this.advancedBlockingMode.getSetting(), backwards));
}
}
private boolean isPart() {
@@ -13,8 +13,7 @@ import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import appeng.api.config.FuzzyMode;
import appeng.api.config.InsertionMode;
import appeng.api.config.*;
import appeng.api.parts.IPart;
import appeng.helpers.DualityInterface;
import appeng.helpers.IInterfaceHost;
@@ -47,14 +46,15 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
// facing is the target TE direction
// |T|-facing->|I|
public FluidConvertingInventoryAdaptor(@Nullable InventoryAdaptor invItems, @Nullable IFluidHandler invFluids,
ForgeDirection facing, BlockPos pos, boolean isOnmi) {
public FluidConvertingInventoryAdaptor(TileEntity te, @Nullable InventoryAdaptor invItems,
@Nullable IFluidHandler invFluids, ForgeDirection facing, BlockPos pos, boolean isOnmi) {
this.invItems = invItems;
this.invFluids = invFluids;
this.side = facing;
this.posInterface = pos;
this.onmi = isOnmi;
this.selfInterface = getInterfaceTE(pos.getTileEntity(), facing.getOpposite());
this.targetInterface = getInterfaceTE(te, facing);
}
private final InventoryAdaptor invItems;
@@ -62,6 +62,8 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
private final ForgeDirection side;
private final BlockPos posInterface;
@Nullable
private final IInterfaceHost targetInterface;
@Nullable
private final IInterfaceHost selfInterface;
private final boolean onmi;
private static Method eioTypeCheck;
@@ -96,7 +98,7 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
if (inter instanceof TileInterface) {
onmi = ((TileInterface) inter).getTargets().size() > 1;
}
return new FluidConvertingInventoryAdaptor(item, fluid, face, new BlockPos(inter), onmi);
return new FluidConvertingInventoryAdaptor(capProvider, item, fluid, face, new BlockPos(inter), onmi);
}
public ItemStack addItems(ItemStack toBeAdded, InsertionMode insertionMode) {
@@ -368,6 +370,11 @@ public class FluidConvertingInventoryAdaptor extends InventoryAdaptor {
if (tank == null && inv == null) {
return 2;
}
if (targetInterface != null && targetInterface.getInstalledUpgrades(Upgrades.ADVANCED_BLOCKING) > 0
&& targetInterface instanceof IDualHost
&& !((IDualHost) targetInterface).getDualityFluid().getFluidInventory().getStorageList().isEmpty()) {
return 1;
}
if (tank != null && tank.getTankInfo(direction) != null) {
List<FluidTankInfo[]> tankInfos = new LinkedList<>();
if (Util.getPart(tank, direction) instanceof PartP2PLiquids) {
@@ -43,9 +43,10 @@ public class CommonProxy {
}
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.CRAFTING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
Upgrades.ADVANCED_BLOCKING.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_INTERFACE), 1);
Upgrades.ADVANCED_BLOCKING.registerItem(new ItemStack(ItemAndBlockHolder.INTERFACE), 1);
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 5);
Upgrades.INVERTER.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_STORAGE_BUS), 1);
if (Config.fluidIOBus) {
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_EXPORT_BUS), 2);
Upgrades.CAPACITY.registerItem(new ItemStack(ItemAndBlockHolder.FLUID_IMPORT_BUS), 2);