Add fluid GUI to me chest, fixed some warnings while at it. (#3579)
Fixes #3555
This commit is contained in:
@@ -180,7 +180,7 @@ public enum GuiBridge implements IGuiHandler
|
|||||||
|
|
||||||
GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ),
|
GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ),
|
||||||
|
|
||||||
GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, PartFluidTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, ITerminalHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||||
|
|
||||||
// extends (Container/Gui) + Bus
|
// extends (Container/Gui) + Bus
|
||||||
GUI_LEVEL_EMITTER( ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
GUI_LEVEL_EMITTER( ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ import net.minecraft.util.text.TextFormatting;
|
|||||||
import net.minecraftforge.fml.common.Loader;
|
import net.minecraftforge.fml.common.Loader;
|
||||||
|
|
||||||
import appeng.api.config.Settings;
|
import appeng.api.config.Settings;
|
||||||
|
import appeng.api.storage.ITerminalHost;
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.api.util.IConfigManager;
|
import appeng.api.util.IConfigManager;
|
||||||
import appeng.api.util.IConfigurableObject;
|
import appeng.api.util.IConfigurableObject;
|
||||||
@@ -54,7 +55,6 @@ import appeng.core.sync.packets.PacketInventoryAction;
|
|||||||
import appeng.core.sync.packets.PacketValueConfig;
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
import appeng.fluids.container.ContainerFluidTerminal;
|
import appeng.fluids.container.ContainerFluidTerminal;
|
||||||
import appeng.fluids.container.slots.IMEFluidSlot;
|
import appeng.fluids.container.slots.IMEFluidSlot;
|
||||||
import appeng.fluids.parts.PartFluidTerminal;
|
|
||||||
import appeng.helpers.InventoryAction;
|
import appeng.helpers.InventoryAction;
|
||||||
import appeng.util.IConfigManagerHost;
|
import appeng.util.IConfigManagerHost;
|
||||||
import appeng.util.Platform;
|
import appeng.util.Platform;
|
||||||
@@ -75,16 +75,21 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
private int rows = 6;
|
private int rows = 6;
|
||||||
private int perRow = 9;
|
private int perRow = 9;
|
||||||
|
|
||||||
protected PartFluidTerminal terminal;
|
protected ITerminalHost terminal;
|
||||||
|
|
||||||
private MEGuiTextField searchField;
|
private MEGuiTextField searchField;
|
||||||
private GuiImgButton sortByBox;
|
private GuiImgButton sortByBox;
|
||||||
private GuiImgButton sortDirBox;
|
private GuiImgButton sortDirBox;
|
||||||
|
|
||||||
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, PartFluidTerminal terminal )
|
public GuiFluidTerminal( final InventoryPlayer inventoryPlayer, final ITerminalHost te )
|
||||||
{
|
{
|
||||||
super( new ContainerFluidTerminal( inventoryPlayer, terminal ) );
|
this( inventoryPlayer, te, new ContainerFluidTerminal( inventoryPlayer, te ) );
|
||||||
this.terminal = terminal;
|
}
|
||||||
|
|
||||||
|
public GuiFluidTerminal( InventoryPlayer inventoryPlayer, final ITerminalHost te, final ContainerFluidTerminal c )
|
||||||
|
{
|
||||||
|
super( c );
|
||||||
|
this.terminal = te;
|
||||||
this.xSize = 185;
|
this.xSize = 185;
|
||||||
this.ySize = 222;
|
this.ySize = 222;
|
||||||
final GuiScrollbar scrollbar = new GuiScrollbar();
|
final GuiScrollbar scrollbar = new GuiScrollbar();
|
||||||
@@ -235,7 +240,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
if( mouseButton == 0 && meSlot.getHasStack() )
|
if( mouseButton == 0 && meSlot.getHasStack() )
|
||||||
{
|
{
|
||||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
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 ) );
|
NetworkHandler.instance().sendToServer( new PacketInventoryAction( InventoryAction.FILL_ITEM, slot.slotNumber, 0 ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -243,7 +248,7 @@ public class GuiFluidTerminal extends AEBaseMEGui implements ISortSource, IConfi
|
|||||||
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
this.container.setTargetStack( meSlot.getAEFluidStack() );
|
||||||
if( meSlot.getAEFluidStack() != null )
|
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 ) );
|
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.SortOrder;
|
||||||
import appeng.api.config.ViewItems;
|
import appeng.api.config.ViewItems;
|
||||||
import appeng.api.networking.IGrid;
|
import appeng.api.networking.IGrid;
|
||||||
|
import appeng.api.networking.IGridHost;
|
||||||
import appeng.api.networking.IGridNode;
|
import appeng.api.networking.IGridNode;
|
||||||
import appeng.api.networking.energy.IEnergyGrid;
|
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.security.IActionSource;
|
||||||
import appeng.api.networking.storage.IBaseMonitor;
|
import appeng.api.networking.storage.IBaseMonitor;
|
||||||
import appeng.api.storage.IMEMonitor;
|
import appeng.api.storage.IMEMonitor;
|
||||||
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
import appeng.api.storage.IMEMonitorHandlerReceiver;
|
||||||
|
import appeng.api.storage.ITerminalHost;
|
||||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||||
import appeng.api.storage.data.IAEFluidStack;
|
import appeng.api.storage.data.IAEFluidStack;
|
||||||
import appeng.api.storage.data.IItemList;
|
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.PacketMEFluidInventoryUpdate;
|
||||||
import appeng.core.sync.packets.PacketTargetFluidStack;
|
import appeng.core.sync.packets.PacketTargetFluidStack;
|
||||||
import appeng.core.sync.packets.PacketValueConfig;
|
import appeng.core.sync.packets.PacketValueConfig;
|
||||||
import appeng.fluids.parts.PartFluidTerminal;
|
|
||||||
import appeng.fluids.util.AEFluidStack;
|
import appeng.fluids.util.AEFluidStack;
|
||||||
import appeng.helpers.InventoryAction;
|
import appeng.helpers.InventoryAction;
|
||||||
import appeng.me.helpers.ChannelPowerSrc;
|
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();
|
private final IItemList<IAEFluidStack> fluids = AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ).createList();
|
||||||
@GuiSync( 99 )
|
@GuiSync( 99 )
|
||||||
public boolean hasPower = false;
|
public boolean hasPower = false;
|
||||||
private PartFluidTerminal terminal;
|
private ITerminalHost terminal;
|
||||||
private IConfigManager serverCM;
|
private IConfigManager serverCM;
|
||||||
private IConfigManagerHost gui;
|
private IConfigManagerHost gui;
|
||||||
private IGridNode networkNode;
|
private IGridNode networkNode;
|
||||||
// Holds the fluid the client wishes to extract, or null for insert
|
// Holds the fluid the client wishes to extract, or null for insert
|
||||||
private IAEFluidStack clientRequestedTargetFluid = null;
|
private IAEFluidStack clientRequestedTargetFluid = null;
|
||||||
|
|
||||||
public ContainerFluidTerminal( InventoryPlayer ip, PartFluidTerminal terminal )
|
public ContainerFluidTerminal( InventoryPlayer ip, ITerminalHost terminal )
|
||||||
{
|
{
|
||||||
super( ip, terminal );
|
super( ip, terminal );
|
||||||
this.terminal = terminal;
|
this.terminal = terminal;
|
||||||
@@ -104,17 +107,40 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
|||||||
{
|
{
|
||||||
this.serverCM = terminal.getConfigManager();
|
this.serverCM = terminal.getConfigManager();
|
||||||
this.monitor = terminal.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
this.monitor = terminal.getInventory( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||||
|
|
||||||
if( this.monitor != null )
|
if( this.monitor != null )
|
||||||
{
|
{
|
||||||
this.monitor.addListener( this, null );
|
this.monitor.addListener( this, null );
|
||||||
final IGridNode node = terminal.getGridNode( AEPartLocation.INTERNAL );
|
|
||||||
if( node != null )
|
|
||||||
|
if( terminal instanceof IEnergySource )
|
||||||
{
|
{
|
||||||
this.networkNode = node;
|
this.setPowerSource( (IEnergySource) terminal );
|
||||||
final IGrid g = node.getGrid();
|
}
|
||||||
if( g != null )
|
else if( terminal instanceof IGridHost || terminal instanceof IActionHost )
|
||||||
|
{
|
||||||
|
final IGridNode node;
|
||||||
|
if( terminal instanceof IGridHost )
|
||||||
{
|
{
|
||||||
this.setPowerSource( new ChannelPowerSrc( this.networkNode, g.getCache( IEnergyGrid.class ) ) );
|
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 ) ) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,7 +374,7 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
|||||||
{
|
{
|
||||||
AEFluidStack stack = (AEFluidStack) this.clientRequestedTargetFluid.copy();
|
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() );
|
stack.getStackSize() );
|
||||||
|
|
||||||
if( isBucket && stack.getStackSize() < 1000 )
|
if( isBucket && stack.getStackSize() < 1000 )
|
||||||
@@ -394,7 +420,7 @@ public class ContainerFluidTerminal extends AEBaseContainer implements IConfigMa
|
|||||||
else if( action == InventoryAction.EMPTY_ITEM )
|
else if( action == InventoryAction.EMPTY_ITEM )
|
||||||
{
|
{
|
||||||
// Empty held 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
|
// See how much we can drain from the item
|
||||||
FluidStack extract = fh.drain( Integer.MAX_VALUE, false );
|
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.entity.player.EntityPlayer;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
|
||||||
import appeng.api.AEApi;
|
import appeng.api.AEApi;
|
||||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||||
@@ -33,8 +34,11 @@ import appeng.api.storage.ISaveProvider;
|
|||||||
import appeng.api.storage.IStorageChannel;
|
import appeng.api.storage.IStorageChannel;
|
||||||
import appeng.api.storage.channels.IFluidStorageChannel;
|
import appeng.api.storage.channels.IFluidStorageChannel;
|
||||||
import appeng.api.storage.data.IAEStack;
|
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.FluidCellInventory;
|
||||||
import appeng.fluids.storage.FluidCellInventoryHandler;
|
import appeng.fluids.storage.FluidCellInventoryHandler;
|
||||||
|
import appeng.util.Platform;
|
||||||
|
|
||||||
|
|
||||||
public class BasicFluidCellHandler implements ICellHandler
|
public class BasicFluidCellHandler implements ICellHandler
|
||||||
@@ -51,7 +55,7 @@ public class BasicFluidCellHandler implements ICellHandler
|
|||||||
{
|
{
|
||||||
if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
return FluidCellInventory.getCell( is, container );
|
return (IMEInventoryHandler<T>) FluidCellInventory.getCell( is, container );
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@@ -62,8 +66,7 @@ public class BasicFluidCellHandler implements ICellHandler
|
|||||||
{
|
{
|
||||||
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
if( chan == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
//TODO: Open Gui
|
Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_FLUID_TERMINAL );
|
||||||
//Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_ME );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class FluidCellInventory extends AbstractCellInventory<IAEFluidStack>
|
|||||||
super( o, container, 8000 );
|
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
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
|
|||||||
private int storedItemCount = 0;
|
private int storedItemCount = 0;
|
||||||
protected IItemList<T> cellItems;
|
protected IItemList<T> cellItems;
|
||||||
protected ItemStack i;
|
protected ItemStack i;
|
||||||
protected IStorageCell cellType;
|
protected IStorageCell<T> cellType;
|
||||||
protected final int itemsPerByte;
|
protected final int itemsPerByte;
|
||||||
|
|
||||||
protected AbstractCellInventory( final NBTTagCompound data, final ISaveProvider container, final int itemsPerByte )
|
protected AbstractCellInventory( final NBTTagCompound data, final ISaveProvider container, final int itemsPerByte )
|
||||||
@@ -96,7 +96,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
|
|||||||
final Item type = this.i.getItem();
|
final Item type = this.i.getItem();
|
||||||
if( type instanceof IStorageCell )
|
if( type instanceof IStorageCell )
|
||||||
{
|
{
|
||||||
this.cellType = (IStorageCell) this.i.getItem();
|
this.cellType = (IStorageCell<T>) this.i.getItem();
|
||||||
this.maxItemTypes = this.cellType.getTotalTypes( this.i );
|
this.maxItemTypes = this.cellType.getTotalTypes( this.i );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,7 +126,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
|
|||||||
this.cellItems = null;
|
this.cellItems = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isEmpty( final IMEInventory meInventory )
|
protected boolean isEmpty( final IMEInventory<T> meInventory )
|
||||||
{
|
{
|
||||||
return meInventory.getAvailableItems( getChannel().createList() ).isEmpty();
|
return meInventory.getAvailableItems( getChannel().createList() ).isEmpty();
|
||||||
}
|
}
|
||||||
@@ -224,7 +224,7 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
|
|||||||
protected abstract void loadCellItem( NBTTagCompound compoundTag, int stackSize );
|
protected abstract void loadCellItem( NBTTagCompound compoundTag, int stackSize );
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public IItemList getAvailableItems( final IItemList out )
|
public IItemList<T> getAvailableItems( final IItemList<T> out )
|
||||||
{
|
{
|
||||||
for( final T item : this.getCellItems() )
|
for( final T item : this.getCellItems() )
|
||||||
{
|
{
|
||||||
@@ -234,7 +234,6 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
|
|||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemStack()
|
public ItemStack getItemStack()
|
||||||
{
|
{
|
||||||
@@ -317,7 +316,6 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
|
|||||||
return basedOnStorage > baseOnTotal ? baseOnTotal : basedOnStorage;
|
return basedOnStorage > baseOnTotal ? baseOnTotal : basedOnStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getUsedBytes()
|
public long getUsedBytes()
|
||||||
{
|
{
|
||||||
@@ -359,4 +357,3 @@ public abstract class AbstractCellInventory<T extends IAEStack<T>> implements IC
|
|||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,8 +121,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
private AEColor paintedColor = AEColor.TRANSPARENT;
|
private AEColor paintedColor = AEColor.TRANSPARENT;
|
||||||
private boolean isCached = false;
|
private boolean isCached = false;
|
||||||
private ICellHandler cellHandler;
|
private ICellHandler cellHandler;
|
||||||
private MEMonitorHandler itemCell;
|
private MEMonitorHandler<IAEItemStack> itemCell;
|
||||||
private MEMonitorHandler fluidCell;
|
private MEMonitorHandler<IAEFluidStack> fluidCell;
|
||||||
private Accessor accessor;
|
private Accessor accessor;
|
||||||
private IFluidHandler fluidHandler;
|
private IFluidHandler fluidHandler;
|
||||||
|
|
||||||
@@ -210,7 +210,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IMEInventoryHandler getHandler( final IStorageChannel channel ) throws ChestNoHandler
|
@SuppressWarnings( "unchecked" )
|
||||||
|
private <T extends IAEStack<T>> IMEInventoryHandler<T> getHandler( final IStorageChannel<T> channel ) throws ChestNoHandler
|
||||||
{
|
{
|
||||||
if( !this.isCached )
|
if( !this.isCached )
|
||||||
{
|
{
|
||||||
@@ -248,10 +249,6 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
this.itemCell = this.wrap( itemCell );
|
this.itemCell = this.wrap( itemCell );
|
||||||
this.fluidCell = this.wrap( fluidCell );
|
this.fluidCell = this.wrap( fluidCell );
|
||||||
|
|
||||||
if( this.itemCell != null )
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
this.accessor = new Accessor();
|
this.accessor = new Accessor();
|
||||||
|
|
||||||
if( this.fluidCell != null )
|
if( this.fluidCell != null )
|
||||||
@@ -268,15 +265,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
{
|
{
|
||||||
throw NO_HANDLER;
|
throw NO_HANDLER;
|
||||||
}
|
}
|
||||||
return this.itemCell;
|
return (IMEInventoryHandler<T>) this.itemCell;
|
||||||
}
|
}
|
||||||
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) && this.fluidCell != null )
|
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
if( this.fluidCell == null )
|
if( this.fluidCell == null )
|
||||||
{
|
{
|
||||||
throw NO_HANDLER;
|
throw NO_HANDLER;
|
||||||
}
|
}
|
||||||
return this.fluidCell;
|
return (IMEInventoryHandler<T>) this.fluidCell;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -290,11 +287,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final MEInventoryHandler<T> ih = new MEInventoryHandler( h, h.getChannel() );
|
final MEInventoryHandler<T> ih = new MEInventoryHandler<T>( h, h.getChannel() );
|
||||||
ih.setPriority( this.priority );
|
ih.setPriority( this.priority );
|
||||||
|
|
||||||
final MEMonitorHandler<T> g = new ChestMonitorHandler<T>( ih );
|
final MEMonitorHandler<T> g = new ChestMonitorHandler<T>( ih );
|
||||||
g.addListener( new ChestNetNotifier( h.getChannel() ), g );
|
g.addListener( new ChestNetNotifier<T>( h.getChannel() ), g );
|
||||||
|
|
||||||
return g;
|
return g;
|
||||||
}
|
}
|
||||||
@@ -314,10 +311,10 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler handler = this.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
final IMEInventoryHandler<IAEItemStack> handler = this.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||||
if( handler instanceof ChestMonitorHandler )
|
if( handler instanceof ChestMonitorHandler )
|
||||||
{
|
{
|
||||||
return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() );
|
return ch.getStatusForCell( cell, ( (ChestMonitorHandler<IAEItemStack>) handler ).getInternalHandler() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( final ChestNoHandler ignored )
|
catch( final ChestNoHandler ignored )
|
||||||
@@ -326,10 +323,11 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler handler = this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
final IMEInventoryHandler<IAEFluidStack> handler = this
|
||||||
|
.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||||
if( handler instanceof ChestMonitorHandler )
|
if( handler instanceof ChestMonitorHandler )
|
||||||
{
|
{
|
||||||
return ch.getStatusForCell( cell, ( (ChestMonitorHandler) handler ).getInternalHandler() );
|
return ch.getStatusForCell( cell, ( (ChestMonitorHandler<IAEFluidStack>) handler ).getInternalHandler() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( final ChestNoHandler ignored )
|
catch( final ChestNoHandler ignored )
|
||||||
@@ -541,16 +539,17 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
this.recalculateDisplay();
|
this.recalculateDisplay();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings( "unchecked" )
|
||||||
@Override
|
@Override
|
||||||
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
|
public <T extends IAEStack<T>> IMEMonitor<T> getInventory( IStorageChannel<T> channel )
|
||||||
{
|
{
|
||||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
return this.itemCell;
|
return (IMEMonitor<T>) this.itemCell;
|
||||||
}
|
}
|
||||||
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
else if( channel == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
return this.fluidCell;
|
return (IMEMonitor<T>) this.fluidCell;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -642,7 +641,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler handler = this.getHandler( channel );
|
final IMEInventoryHandler<?> handler = this.getHandler( channel );
|
||||||
|
|
||||||
if( handler != null )
|
if( handler != null )
|
||||||
{
|
{
|
||||||
@@ -722,7 +721,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler invHandler = this.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
final IMEInventoryHandler<IAEItemStack> invHandler = this.getHandler( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||||
if( ch != null && invHandler != null )
|
if( ch != null && invHandler != null )
|
||||||
{
|
{
|
||||||
ch.openChestGui( p, this, ch, invHandler, cell, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
ch.openChestGui( p, this, ch, invHandler, cell, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
|
||||||
@@ -736,7 +735,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler invHandler = this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
final IMEInventoryHandler<IAEFluidStack> invHandler = this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||||
if( ch != null && invHandler != null )
|
if( ch != null && invHandler != null )
|
||||||
{
|
{
|
||||||
ch.openChestGui( p, this, ch, invHandler, cell, AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
ch.openChestGui( p, this, ch, invHandler, cell, AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||||
@@ -774,7 +773,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
@Override
|
@Override
|
||||||
public void saveChanges( final IMEInventory cellInventory )
|
public void saveChanges( final IMEInventory cellInventory )
|
||||||
{
|
{
|
||||||
this.world.markChunkDirty( this.pos, this );
|
this.markDirty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class ChestNoHandler extends Exception
|
private static class ChestNoHandler extends Exception
|
||||||
@@ -785,9 +784,9 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
private class ChestNetNotifier<T extends IAEStack<T>> implements IMEMonitorHandlerReceiver<T>
|
private class ChestNetNotifier<T extends IAEStack<T>> implements IMEMonitorHandlerReceiver<T>
|
||||||
{
|
{
|
||||||
|
|
||||||
private final IStorageChannel chan;
|
private final IStorageChannel<T> chan;
|
||||||
|
|
||||||
public ChestNetNotifier( final IStorageChannel chan )
|
public ChestNetNotifier( final IStorageChannel<T> chan )
|
||||||
{
|
{
|
||||||
this.chan = chan;
|
this.chan = chan;
|
||||||
}
|
}
|
||||||
@@ -847,7 +846,7 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
final IMEInventoryHandler<T> h = this.getHandler();
|
final IMEInventoryHandler<T> h = this.getHandler();
|
||||||
if( h instanceof MEInventoryHandler )
|
if( h instanceof MEInventoryHandler )
|
||||||
{
|
{
|
||||||
return (IMEInventoryHandler<T>) ( (MEInventoryHandler) h ).getInternal();
|
return (IMEInventoryHandler<T>) ( (MEInventoryHandler<T>) h ).getInternal();
|
||||||
}
|
}
|
||||||
return this.getHandler();
|
return this.getHandler();
|
||||||
}
|
}
|
||||||
@@ -962,11 +961,12 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler h = TileChest.this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
final IMEInventoryHandler<IAEFluidStack> h = TileChest.this
|
||||||
|
.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||||
|
|
||||||
TileChest.this.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
TileChest.this.extractAEPower( req, Actionable.MODULATE, PowerMultiplier.CONFIG );
|
||||||
|
|
||||||
final IAEStack results = h.injectItems( AEFluidStack.fromFluidStack( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE,
|
final IAEFluidStack results = h.injectItems( AEFluidStack.fromFluidStack( resource ), doFill ? Actionable.MODULATE : Actionable.SIMULATE,
|
||||||
TileChest.this.mySrc );
|
TileChest.this.mySrc );
|
||||||
|
|
||||||
if( results == null )
|
if( results == null )
|
||||||
@@ -1000,7 +1000,8 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final IMEInventoryHandler h = TileChest.this.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
final IMEInventoryHandler<IAEFluidStack> h = TileChest.this
|
||||||
|
.getHandler( AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
|
||||||
|
|
||||||
if( h.getChannel() == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
if( h.getChannel() == AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) )
|
||||||
{
|
{
|
||||||
@@ -1060,12 +1061,15 @@ public class TileChest extends AENetworkPowerTile implements IMEChest, ITerminal
|
|||||||
@Override
|
@Override
|
||||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
|
||||||
{
|
{
|
||||||
return AEApi.instance().registries().cell().getCellInventory( stack, TileChest.this,
|
return AEApi.instance()
|
||||||
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) != null || AEApi.instance()
|
.registries()
|
||||||
.registries()
|
.cell()
|
||||||
.cell()
|
.getCellInventory( stack, TileChest.this,
|
||||||
.getCellInventory( stack, TileChest.this,
|
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) != null || AEApi.instance()
|
||||||
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) != null;
|
.registries()
|
||||||
|
.cell()
|
||||||
|
.getCellInventory( stack, TileChest.this,
|
||||||
|
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) ) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user