mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-11 15:57:55 +00:00
Merge pull request #24 from dipo33/fluid-interface-sideless
Add option to make Fluid Interface sideless
This commit is contained in:
9 files changed
+658
-174
No files matched your search
@@ -2,6 +2,7 @@ package com.glodblock.github.client.gui;
|
||||
|
||||
import appeng.api.config.InsertionMode;
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SidelessMode;
|
||||
import appeng.api.config.YesNo;
|
||||
import appeng.client.gui.implementations.GuiUpgradeable;
|
||||
import appeng.client.gui.widgets.GuiImgButton;
|
||||
@@ -13,6 +14,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketConfigButton;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
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.gui.GuiType;
|
||||
@@ -32,10 +34,11 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
private GuiImgButton BlockMode;
|
||||
private GuiToggleButton interfaceMode;
|
||||
private GuiImgButton insertionMode;
|
||||
private GuiImgButton sidelessMode;
|
||||
private final IInterfaceHost host;
|
||||
|
||||
public GuiDualInterface(InventoryPlayer inventoryPlayer, IInterfaceHost te) {
|
||||
super(new ContainerInterface(inventoryPlayer, te));
|
||||
super(new ContainerDualInterface(inventoryPlayer, te));
|
||||
this.host = te;
|
||||
this.ySize = 211;
|
||||
}
|
||||
@@ -58,6 +61,11 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
|
||||
this.insertionMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 44, Settings.INSERTION_MODE, InsertionMode.DEFAULT );
|
||||
this.buttonList.add( this.insertionMode );
|
||||
|
||||
if (isTile()) {
|
||||
this.sidelessMode = new GuiImgButton( this.guiLeft - 18, this.guiTop + 62, Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
|
||||
this.buttonList.add( this.sidelessMode );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -76,6 +84,9 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
{
|
||||
this.insertionMode.set( ( (ContainerInterface) this.cvb ).getInsertionMode());
|
||||
}
|
||||
if (this.sidelessMode != null) {
|
||||
this.sidelessMode.set( ( (ContainerDualInterface) this.cvb ).getSidelessMode());
|
||||
}
|
||||
|
||||
this.fontRendererObj.drawString( getGuiDisplayName(StatCollector.translateToLocal(NameConst.GUI_FLUID_INTERFACE)), 8, 6, 4210752 );
|
||||
}
|
||||
@@ -106,20 +117,20 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
|
||||
if( btn == this.priority )
|
||||
{
|
||||
if (host instanceof TileFluidInterface) {
|
||||
if (isTile()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY));
|
||||
}
|
||||
else if(host instanceof PartFluidInterface) {
|
||||
else if(isPart()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_PRIORITY_PART));
|
||||
}
|
||||
}
|
||||
|
||||
if( btn == this.switcher )
|
||||
{
|
||||
if (host instanceof TileFluidInterface) {
|
||||
if (isTile()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID));
|
||||
}
|
||||
else if (host instanceof PartFluidInterface) {
|
||||
else if (isPart()) {
|
||||
FluidCraft.proxy.netHandler.sendToServer(new CPacketSwitchGuis(GuiType.DUAL_INTERFACE_FLUID_PART));
|
||||
}
|
||||
}
|
||||
@@ -137,5 +148,17 @@ public class GuiDualInterface extends GuiUpgradeable {
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.insertionMode.getSetting(), backwards ) );
|
||||
}
|
||||
if (btn == this.sidelessMode && this.sidelessMode != null)
|
||||
{
|
||||
NetworkHandler.instance.sendToServer( new PacketConfigButton( this.sidelessMode.getSetting(), backwards ) );
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isPart() {
|
||||
return this.host instanceof PartFluidInterface;
|
||||
}
|
||||
|
||||
private boolean isTile() {
|
||||
return this.host instanceof TileFluidInterface;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.glodblock.github.client.gui.container;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SidelessMode;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.container.guisync.GuiSync;
|
||||
import appeng.container.implementations.ContainerInterface;
|
||||
import appeng.helpers.IInterfaceHost;
|
||||
import net.minecraft.entity.player.InventoryPlayer;
|
||||
|
||||
public class ContainerDualInterface extends ContainerInterface {
|
||||
|
||||
@GuiSync(10)
|
||||
public SidelessMode sidelessMode;
|
||||
|
||||
public ContainerDualInterface(InventoryPlayer ip, IInterfaceHost te) {
|
||||
super(ip, te);
|
||||
this.sidelessMode = SidelessMode.SIDELESS;
|
||||
}
|
||||
|
||||
public SidelessMode getSidelessMode() {
|
||||
return this.sidelessMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loadSettingsFromHost(IConfigManager cm) {
|
||||
super.loadSettingsFromHost(cm);
|
||||
this.sidelessMode = (SidelessMode) cm.getSetting(Settings.SIDELESS_MODE);
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,7 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
|
||||
public class PartFluidImportBus extends PartSharedFluidBus {
|
||||
@@ -72,30 +73,35 @@ public class PartFluidImportBus extends PartSharedFluidBus {
|
||||
final IFluidHandler fh = (IFluidHandler) te;
|
||||
final IMEMonitor<IAEFluidStack> inv = this.getProxy().getStorage().getFluidInventory();
|
||||
|
||||
final FluidStack fluidStack = fh.drain( this.getSide().getOpposite(), this.calculateAmountToSend(), false );
|
||||
|
||||
if( this.filterEnabled() && !this.isInFilter( fluidStack ) )
|
||||
{
|
||||
return TickRateModulation.SLOWER;
|
||||
}
|
||||
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.create( fluidStack );
|
||||
|
||||
if( aeFluidStack != null )
|
||||
{
|
||||
final IAEFluidStack notInserted = inv.injectItems( aeFluidStack, Actionable.MODULATE, this.source );
|
||||
|
||||
if( notInserted != null && notInserted.getStackSize() > 0 )
|
||||
{
|
||||
aeFluidStack.decStackSize( notInserted.getStackSize() );
|
||||
int maxDrain = this.calculateAmountToSend();
|
||||
boolean drained = false;
|
||||
FluidTankInfo[] tanksInfo = fh.getTankInfo(this.getSide().getOpposite());
|
||||
for (FluidTankInfo tankInfo : tanksInfo) {
|
||||
if (tankInfo.fluid == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
fh.drain( this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true );
|
||||
FluidStack fluidStack = new FluidStack(tankInfo.fluid, Math.min(tankInfo.fluid.amount, maxDrain));
|
||||
fluidStack = fh.drain(this.getSide().getOpposite(), fluidStack, false);
|
||||
if (this.filterEnabled() && !this.isInFilter(fluidStack)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
return TickRateModulation.FASTER;
|
||||
final AEFluidStack aeFluidStack = AEFluidStack.create(fluidStack);
|
||||
if (aeFluidStack != null) {
|
||||
final IAEFluidStack notInserted = inv.injectItems(aeFluidStack, Actionable.MODULATE, this.source);
|
||||
|
||||
if (notInserted != null && notInserted.getStackSize() > 0) {
|
||||
aeFluidStack.decStackSize(notInserted.getStackSize());
|
||||
}
|
||||
|
||||
fh.drain(this.getSide().getOpposite(), aeFluidStack.getFluidStack(), true);
|
||||
maxDrain -= aeFluidStack.getFluidStack().amount;
|
||||
drained = true;
|
||||
}
|
||||
}
|
||||
|
||||
return TickRateModulation.IDLE;
|
||||
return drained ? TickRateModulation.FASTER : TickRateModulation.SLOWER;
|
||||
}
|
||||
catch(GridAccessException e )
|
||||
{
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package com.glodblock.github.common.tile;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SidelessMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkChannelsChanged;
|
||||
@@ -8,6 +10,7 @@ import appeng.api.networking.events.MENetworkPowerStatusChange;
|
||||
import appeng.api.networking.ticking.TickRateModulation;
|
||||
import appeng.api.networking.ticking.TickingRequest;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.tile.TileEvent;
|
||||
import appeng.tile.events.TileEventType;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
@@ -35,9 +38,21 @@ import java.io.IOException;
|
||||
public class TileFluidInterface extends TileInterface implements IFluidHandler, IAEFluidInventory
|
||||
{
|
||||
|
||||
public TileFluidInterface() {
|
||||
super.getInterfaceDuality().getConfigManager()
|
||||
.registerSetting(Settings.SIDELESS_MODE, SidelessMode.SIDELESS);
|
||||
}
|
||||
|
||||
private final DualityFluidInterface fluidDuality = new DualityFluidInterface(this.getProxy(), this) {
|
||||
private final IConfigManager dualityConfigManager = getInterfaceDuality().getConfigManager();
|
||||
|
||||
@Override
|
||||
public FluidStack drain(ForgeDirection from, int maxDrain, boolean doDrain) {
|
||||
SidelessMode mode = (SidelessMode) dualityConfigManager.getSetting(Settings.SIDELESS_MODE);
|
||||
if (mode == SidelessMode.SIDELESS) {
|
||||
return this.getTanks().drain(from, maxDrain, doDrain);
|
||||
}
|
||||
|
||||
return this.getTanks().drain(from.ordinal(), maxDrain, doDrain);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -69,7 +69,7 @@ public enum GuiType {
|
||||
DUAL_INTERFACE(new TileGuiFactory<TileFluidInterface>(TileFluidInterface.class) {
|
||||
@Override
|
||||
protected Object createServerGui(EntityPlayer player, TileFluidInterface inv) {
|
||||
return new ContainerInterface(player.inventory, inv);
|
||||
return new ContainerDualInterface(player.inventory, inv);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in new issue
Block a user