Refactored StorageChannel enum into an interface (#3138)
This replaces the static enum with a more dynamic interface providing factory methods for handling network storage.
This commit is contained in:
@@ -20,20 +20,14 @@ package appeng.core;
|
||||
|
||||
|
||||
import appeng.api.IAppEngApi;
|
||||
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.IGridHelper;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.api.ApiGrid;
|
||||
import appeng.core.api.ApiPart;
|
||||
import appeng.core.api.ApiStorage;
|
||||
import appeng.core.features.registries.PartModels;
|
||||
import appeng.core.features.registries.RegistryContainer;
|
||||
import appeng.me.GridConnection;
|
||||
import appeng.me.GridNode;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class Api implements IAppEngApi
|
||||
@@ -45,11 +39,13 @@ public final class Api implements IAppEngApi
|
||||
// private MovableTileRegistry MovableRegistry = new MovableTileRegistry();
|
||||
private final IRegistryContainer registryContainer;
|
||||
private final IStorageHelper storageHelper;
|
||||
private final IGridHelper networkHelper;
|
||||
private final ApiDefinitions definitions;
|
||||
|
||||
private Api()
|
||||
{
|
||||
this.storageHelper = new ApiStorage();
|
||||
this.networkHelper = new ApiGrid();
|
||||
this.registryContainer = new RegistryContainer();
|
||||
this.partHelper = new ApiPart();
|
||||
this.definitions = new ApiDefinitions( (PartModels) this.registryContainer.partModels() );
|
||||
@@ -72,6 +68,12 @@ public final class Api implements IAppEngApi
|
||||
return this.storageHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridHelper grid()
|
||||
{
|
||||
return this.networkHelper;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApiPart partHelper()
|
||||
{
|
||||
@@ -83,21 +85,4 @@ public final class Api implements IAppEngApi
|
||||
{
|
||||
return this.definitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridNode createGridNode( final IGridBlock blk )
|
||||
{
|
||||
if( Platform.isClient() )
|
||||
{
|
||||
throw new IllegalStateException( "Grid features for " + blk + " are server side only." );
|
||||
}
|
||||
|
||||
return new GridNode( blk );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IGridConnection createGridConnection( final IGridNode a, final IGridNode b ) throws FailedConnection
|
||||
{
|
||||
return new GridConnection( a, b, AEPartLocation.INTERNAL );
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user