Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactored StorageChannel enum into an interface #3138

Merged
merged 7 commits into from Oct 8, 2017
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
32 changes: 9 additions & 23 deletions src/api/java/appeng/api/IAppEngApi.java
Expand Up @@ -25,14 +25,13 @@


import appeng.api.definitions.IDefinitions;
import appeng.api.exceptions.FailedConnection;
import appeng.api.features.IRegistryContainer;
import appeng.api.networking.IGridBlock;
import appeng.api.networking.IGridConnection;
import appeng.api.networking.IGridNode;
import appeng.api.networking.INetworkHelper;
import appeng.api.parts.IPartHelper;
import appeng.api.storage.IStorageHelper;


@AEInjectable
public interface IAppEngApi
{
Expand All @@ -42,36 +41,23 @@ public interface IAppEngApi
IRegistryContainer registries();

/**
* @return helper for working with storage data types.
* @return A helper for working with storage data types.
*/
IStorageHelper storage();

/**
* @return helper for working with grids, and buses.
* @return A helper to create {@link IGridNode} and other network related objects.
*/
IPartHelper partHelper();
INetworkHelper network();

/**
* @return an accessible list of all AE definitions
* @return A helper for working with grids, and buses.
*/
IDefinitions definitions();
IPartHelper partHelper();

/**
* create a grid node for your {@link appeng.api.networking.IGridHost}
*
* @param block grid block
*
* @return grid node of block
* @return An accessible list of all AE definitions
*/
IGridNode createGridNode( IGridBlock block );
IDefinitions definitions();

/**
* create a connection between two {@link appeng.api.networking.IGridNode}
*
* @param a to be connected gridnode
* @param b to be connected gridnode
*
* @throws appeng.api.exceptions.FailedConnection
*/
IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnection;
}
30 changes: 30 additions & 0 deletions src/api/java/appeng/api/networking/INetworkHelper.java
@@ -0,0 +1,30 @@

package appeng.api.networking;


import appeng.api.exceptions.FailedConnection;


public interface INetworkHelper
{

/**
* create a grid node for your {@link appeng.api.networking.IGridHost}
*
* @param block grid block
*
* @return grid node of block
*/
IGridNode createGridNode( IGridBlock block );

/**
* create a connection between two {@link appeng.api.networking.IGridNode}
*
* @param a to be connected gridnode
* @param b to be connected gridnode
*
* @throws appeng.api.exceptions.FailedConnection
*/
IGridConnection createGridConnection( IGridNode a, IGridNode b ) throws FailedConnection;

}
Expand Up @@ -25,7 +25,7 @@


import appeng.api.storage.IMEMonitor;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.IStorageChannel;


/**
Expand All @@ -40,9 +40,9 @@ public class MENetworkStorageEvent extends MENetworkEvent
{

public final IMEMonitor monitor;
public final StorageChannel channel;
public final IStorageChannel channel;

public MENetworkStorageEvent( final IMEMonitor o, final StorageChannel chan )
public MENetworkStorageEvent( final IMEMonitor o, final IStorageChannel chan )
{
this.monitor = o;
this.channel = chan;
Expand Down
Expand Up @@ -25,7 +25,7 @@


import appeng.api.networking.security.IActionSource;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;

Expand All @@ -50,5 +50,5 @@ public interface IStackWatcherHost
* @param src action source
* @param chan storage channel
*/
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, StorageChannel chan );
void onStackChange( IItemList o, IAEStack fullStack, IAEStack diffStack, IActionSource src, IStorageChannel chan );
}
4 changes: 2 additions & 2 deletions src/api/java/appeng/api/networking/storage/IStorageGrid.java
Expand Up @@ -30,7 +30,7 @@
import appeng.api.storage.ICellContainer;
import appeng.api.storage.ICellProvider;
import appeng.api.storage.IStorageMonitorable;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.data.IAEStack;


Expand All @@ -50,7 +50,7 @@ public interface IStorageGrid extends IGridCache, IStorageMonitorable
*
* @param input injected items
*/
void postAlterationOfStoredItems( StorageChannel chan, Iterable<? extends IAEStack> input, IActionSource src );
void postAlterationOfStoredItems( IStorageChannel chan, Iterable<? extends IAEStack> input, IActionSource src );

/**
* Used to add a cell provider to the storage system
Expand Down
9 changes: 5 additions & 4 deletions src/api/java/appeng/api/storage/ICellHandler.java
Expand Up @@ -28,6 +28,7 @@
import net.minecraft.item.ItemStack;

import appeng.api.implementations.tiles.IChestOrDrive;
import appeng.api.storage.data.IAEStack;


/**
Expand Down Expand Up @@ -56,7 +57,7 @@ public interface ICellHandler
*
* @return a new IMEHandler for the provided item
*/
IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider host, StorageChannel channel );
<T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> channel );

/**
* Called when the storage cell is planed in an ME Chest and the user tries to open the terminal side, if your item
Expand All @@ -70,7 +71,7 @@ public interface ICellHandler
* @param is item
* @param chan storage channel
*/
void openChestGui( EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler inv, ItemStack is, StorageChannel chan );
<T extends IAEStack<T>> void openChestGui( EntityPlayer player, IChestOrDrive chest, ICellHandler cellHandler, IMEInventoryHandler<T> inv, ItemStack is, IStorageChannel<T> chan );

/**
* 0 - cell is missing.
Expand All @@ -86,10 +87,10 @@ public interface ICellHandler
*
* @return get the status of the cell based on its contents.
*/
int getStatusForCell( ItemStack is, IMEInventory handler );
<T extends IAEStack<T>> int getStatusForCell( ItemStack is, IMEInventory<T> handler );

/**
* @return the ae/t to drain for this storage cell inside a chest/drive.
*/
double cellIdleDrain( ItemStack is, IMEInventory handler );
<T extends IAEStack<T>> double cellIdleDrain( ItemStack is, IMEInventory<T> handler );
}
2 changes: 1 addition & 1 deletion src/api/java/appeng/api/storage/ICellProvider.java
Expand Up @@ -42,7 +42,7 @@ public interface ICellProvider
*
* @return a valid list of handlers, NEVER NULL
*/
List<IMEInventoryHandler> getCellArray( StorageChannel channel );
List<IMEInventoryHandler> getCellArray( IStorageChannel channel );

/**
* the storage's priority.
Expand Down
3 changes: 2 additions & 1 deletion src/api/java/appeng/api/storage/ICellRegistry.java
Expand Up @@ -27,6 +27,7 @@
import net.minecraft.item.ItemStack;

import appeng.api.IAppEngApi;
import appeng.api.storage.data.IAEStack;


/**
Expand Down Expand Up @@ -73,5 +74,5 @@ public interface ICellRegistry
*
* @return new IMEInventoryHandler, or null if there isn't one.
*/
IMEInventoryHandler getCellInventory( ItemStack is, ISaveProvider host, StorageChannel chan );
<T extends IAEStack<T>> IMEInventoryHandler<T> getCellInventory( ItemStack is, ISaveProvider host, IStorageChannel<T> chan );
}
10 changes: 5 additions & 5 deletions src/api/java/appeng/api/storage/IMEInventory.java
Expand Up @@ -40,7 +40,7 @@
* If you want to request a stack of an item, you should should determine that prior to requesting the stack from the
* inventory.
*/
public interface IMEInventory<StackType extends IAEStack>
public interface IMEInventory<T extends IAEStack<T>>
{

/**
Expand All @@ -52,7 +52,7 @@ public interface IMEInventory<StackType extends IAEStack>
*
* @return returns the number of items not added.
*/
StackType injectItems( StackType input, Actionable type, IActionSource src );
T injectItems( T input, Actionable type, IActionSource src );

/**
* Extract the specified item from the ME Inventory
Expand All @@ -62,7 +62,7 @@ public interface IMEInventory<StackType extends IAEStack>
*
* @return returns the number of items extracted, null
*/
StackType extractItems( StackType request, Actionable mode, IActionSource src );
T extractItems( T request, Actionable mode, IActionSource src );

/**
* request a full report of all available items, storage.
Expand All @@ -71,10 +71,10 @@ public interface IMEInventory<StackType extends IAEStack>
*
* @return returns same list that was passed in, is passed out
*/
IItemList<StackType> getAvailableItems( IItemList<StackType> out );
IItemList<T> getAvailableItems( IItemList<T> out );

/**
* @return the type of channel your handler should be part of
*/
StorageChannel getChannel();
IStorageChannel<T> getChannel();
}
8 changes: 4 additions & 4 deletions src/api/java/appeng/api/storage/IMEInventoryHandler.java
Expand Up @@ -32,9 +32,9 @@
* Thin logic layer that can be swapped with different IMEInventory implementations, used to handle features related to
* storage, that are Separate from the storage medium itself.
*
* @param <StackType>
* @param <T>
*/
public interface IMEInventoryHandler<StackType extends IAEStack> extends IMEInventory<StackType>
public interface IMEInventoryHandler<T extends IAEStack<T>> extends IMEInventory<T>
{

/**
Expand All @@ -52,7 +52,7 @@ public interface IMEInventoryHandler<StackType extends IAEStack> extends IMEInve
*
* @return if its prioritized
*/
boolean isPrioritized( StackType input );
boolean isPrioritized( T input );

/**
* determine if an item can be accepted and stored.
Expand All @@ -61,7 +61,7 @@ public interface IMEInventoryHandler<StackType extends IAEStack> extends IMEInve
*
* @return if the item can be added
*/
boolean canAccept( StackType input );
boolean canAccept( T input );

/**
* determine what the priority of the inventory is.
Expand Down
4 changes: 2 additions & 2 deletions src/api/java/appeng/api/storage/IMEMonitor.java
Expand Up @@ -29,15 +29,15 @@
import appeng.api.storage.data.IItemList;


public interface IMEMonitor<T extends IAEStack> extends IMEInventoryHandler<T>, IBaseMonitor<T>
public interface IMEMonitor<T extends IAEStack<T>> extends IMEInventoryHandler<T>, IBaseMonitor<T>
{

/**
* This method is discouraged when accessing data via a IMEMonitor
*/
@Override
@Deprecated
IItemList<T> getAvailableItems( IItemList out );
IItemList<T> getAvailableItems( IItemList<T> out );

/**
* Get access to the full item list of the network, preferred over {@link IMEInventory} .getAvailableItems(...)
Expand Down