Add fluid GUI to me chest, fixed some warnings while at it. (#3579)
Fixes #3555
This commit is contained in:
@@ -36,6 +36,7 @@ import net.minecraft.util.text.TextFormatting;
|
||||
import net.minecraftforge.fml.common.Loader;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.api.util.IConfigurableObject;
|
||||
@@ -54,7 +55,6 @@ import appeng.core.sync.packets.PacketInventoryAction;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.container.ContainerFluidTerminal;
|
||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||
import appeng.fluids.parts.PartFluidTerminal;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
@@ -75,16 +75,21 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
||||
private int rows = 6;
|
||||
private int perRow = 9;
|
||||
|
||||
protected PartFluidTerminal terminal;
|
||||
protected ITerminalHost terminal;
|
||||
|
||||
private MEGuiTextField searchField;
|
||||
private GuiImgButton sortByBox;
|
||||
private GuiImgButton sortDirBox;
|
||||
|
||||
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, PartFluidTerminal terminal )
|
||||
public GuiFluidTerminal( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||
{
|
||||
super( new ContainerFluidTerminal( inventoryPlayer, terminal ) );
|
||||
this.terminal = terminal;
|
||||
this( inventoryPlayer, te, new ContainerFluidTerminal( inventoryPlayer, te ) );
|
||||
}
|
||||
|
||||
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidTerminal c )
|
||||
{
|
||||
super( c );
|
||||
this.terminal = te;
|
||||
this.xSize = 185;
|
||||
this.ySize = 222;
|
||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||
@@ -235,7 +240,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
||||
if( mouseButton == 0 && meSlot.getHasStack() )
|
||||
{
|
||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
||||
AELog.info( "mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
AELog.debug( "mouse0 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
else
|
||||
@@ -243,7 +248,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
||||
if( meSlot.getAEFluidStack() != null )
|
||||
{
|
||||
AELog.info( "mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
AELog.debug( "mouse1 GUI STACK SIZE %s", meSlot.getAEFluidStack().getStackSize() );
|
||||
}
|
||||
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.EMPTY_ITEM, slot.slotNumber, 0 ) );
|
||||
}
|
||||
|
||||
@@ -44,12 +44,16 @@ import appeng.api.config.SortDir;
|
||||
import appeng.api.config.SortOrder;
|
||||
import appeng.api.config.ViewItems;
|
||||
import appeng.api.networking.IGrid;
|
||||
import appeng.api.networking.IGridHost;
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.energy.IEnergyGrid;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
import appeng.api.networking.security.IActionHost;
|
||||
import appeng.api.networking.security.IActionSource;
|
||||
import appeng.api.networking.storage.IBaseMonitor;
|
||||
import appeng.api.storage.IMEMonitor;
|
||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||
import appeng.api.storage.ITerminalHost;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEFluidStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
@@ -63,7 +67,6 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.packets.PacketMEFluidInventoryUpdate;
|
||||
import appeng.core.sync.packets.PacketTargetFluidStack;
|
||||
import appeng.core.sync.packets.PacketValueConfig;
|
||||
import appeng.fluids.parts.PartFluidTerminal;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.helpers.InventoryAction;
|
||||
import appeng.me.helpers.ChannelPowerSrc;
|
||||
@@ -84,14 +87,14 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||
@GuiSync( 99 )
|
||||
public boolean hasPower = false;
|
||||
private PartFluidTerminal terminal;
|
||||
private ITerminalHost terminal;
|
||||
private IConfigManager serverCM;
|
||||
private IConfigManagerHost gui;
|
||||
private IGridNode networkNode;
|
||||
// Holds the fluid the client wishes to extract, or null for insert
|
||||
private IAEFluidStack clientRequestedTargetFluid = null;
|
||||
|
||||
public ContainerFluidTerminal( InventoryPlayer ip, PartFluidTerminal terminal )
|
||||
public ContainerFluidTerminal( InventoryPlayer ip, ITerminalHost terminal )
|
||||
{
|
||||
super( ip, terminal );
|
||||
this.terminal = terminal;
|
||||
@@ -104,19 +107,42 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
{
|
||||
this.serverCM = terminal.getConfigManager();
|
||||
this.monitor = terminal.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||
|
||||
if( this.monitor != null )
|
||||
{
|
||||
{
|
||||
this.monitor.addListener( this, null );
|
||||
final IGridNode node = terminal.getGridNode( AEPartLocation.INTERNAL );
|
||||
if( node != null )
|
||||
|
||||
|
||||
if( terminal instanceof IEnergySource )
|
||||
{
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, g.getCache( IEnergyGrid.class ) ) );
|
||||
}
|
||||
this.setPowerSource( (IEnergySource) terminal );
|
||||
}
|
||||
else if( terminal instanceof IGridHost || terminal instanceof IActionHost )
|
||||
{
|
||||
final IGridNode node;
|
||||
if( terminal instanceof IGridHost )
|
||||
{
|
||||
node = ( (IGridHost) terminal ).getGridNode( AEPartLocation.INTERNAL );
|
||||
}
|
||||
else if( terminal instanceof IActionHost )
|
||||
{
|
||||
node = ( (IActionHost) terminal ).getActionableNode();
|
||||
}
|
||||
else
|
||||
{
|
||||
node = null;
|
||||
}
|
||||
|
||||
if( node != null )
|
||||
{
|
||||
this.networkNode = node;
|
||||
final IGrid g = node.getGrid();
|
||||
if( g != null )
|
||||
{
|
||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, (IEnergySource) g.getCache( IEnergyGrid.class ) ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -348,7 +374,7 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
{
|
||||
AEFluidStack stack = (AEFluidStack) this.clientRequestedTargetFluid.copy();
|
||||
|
||||
AELog.info( "Filling %s with %s, %s mb", held.getDisplayName(), this.clientRequestedTargetFluid.getFluidStack().getLocalizedName(),
|
||||
AELog.debug( "Filling %s with %s, %s mb", held.getDisplayName(), this.clientRequestedTargetFluid.getFluidStack().getLocalizedName(),
|
||||
stack.getStackSize() );
|
||||
|
||||
if( isBucket && stack.getStackSize() < 1000 )
|
||||
@@ -394,7 +420,7 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
||||
else if( action == InventoryAction.EMPTY_ITEM )
|
||||
{
|
||||
// Empty held item
|
||||
AELog.info( "Emptying %s", held.getDisplayName() );
|
||||
AELog.debug( "Emptying %s", held.getDisplayName() );
|
||||
|
||||
// See how much we can drain from the item
|
||||
FluidStack extract = fh.drain( Integer.MAX_VALUE, false );
|
||||
|
||||
@@ -21,6 +21,7 @@ package appeng.fluids.registries;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
@@ -33,8 +34,11 @@ import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.fluids.storage.FluidCellInventory;
|
||||
import appeng.fluids.storage.FluidCellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BasicFluidCellHandler implements ICellHandler
|
||||
@@ -51,7 +55,7 @@ public class BasicFluidCellHandler implements ICellHandler
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
return FluidCellInventory.getCell( is, container );
|
||||
return (IMEInventoryHandler<T>) FluidCellInventory.getCell( is, container );
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -62,8 +66,7 @@ public class BasicFluidCellHandler implements ICellHandler
|
||||
{
|
||||
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||
{
|
||||
//TODO: Open Gui
|
||||
//Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_ME );
|
||||
Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_FLUID_TERMINAL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
||||
super( o, container, 8000 );
|
||||
}
|
||||
|
||||
public static IMEInventoryHandler getCell( final ItemStack o, final ISaveProvider container2 )
|
||||
public static IMEInventoryHandler<IAEFluidStack> getCell( final ItemStack o, final ISaveProvider container2 )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user