2014-11-14 12:02:52 +01:00
|
|
|
/*
|
|
|
|
* This file is part of Applied Energistics 2.
|
|
|
|
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* Applied Energistics 2 is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public License
|
|
|
|
* along with Applied Energistics 2. If not, see <http://www.gnu.org/licenses/lgpl>.
|
|
|
|
*/
|
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
package appeng.core;
|
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
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.storage.IStorageHelper;
|
2015-06-16 02:44:59 +02:00
|
|
|
import appeng.api.util.AEPartLocation;
|
2014-09-24 02:26:27 +02:00
|
|
|
import appeng.core.api.ApiPart;
|
|
|
|
import appeng.core.api.ApiStorage;
|
2016-08-29 09:47:17 +02:00
|
|
|
import appeng.core.features.registries.PartModels;
|
2014-09-24 02:26:27 +02:00
|
|
|
import appeng.core.features.registries.RegistryContainer;
|
|
|
|
import appeng.me.GridConnection;
|
|
|
|
import appeng.me.GridNode;
|
|
|
|
import appeng.util.Platform;
|
|
|
|
|
2015-04-03 08:54:31 +02:00
|
|
|
|
2015-03-26 12:25:44 +01:00
|
|
|
public final class Api implements IAppEngApi
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-01 22:13:10 +01:00
|
|
|
public static final Api INSTANCE = new Api();
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
private final ApiPart partHelper;
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
// private MovableTileRegistry MovableRegistry = new MovableTileRegistry();
|
2015-01-03 02:53:14 +01:00
|
|
|
private final IRegistryContainer registryContainer;
|
|
|
|
private final IStorageHelper storageHelper;
|
|
|
|
private final ApiDefinitions definitions;
|
|
|
|
|
|
|
|
private Api()
|
|
|
|
{
|
|
|
|
this.storageHelper = new ApiStorage();
|
|
|
|
this.registryContainer = new RegistryContainer();
|
|
|
|
this.partHelper = new ApiPart();
|
2016-08-29 09:47:17 +02:00
|
|
|
this.definitions = new ApiDefinitions( (PartModels) this.registryContainer.partModels() );
|
2015-01-03 02:53:14 +01:00
|
|
|
}
|
2015-02-03 12:04:13 +01:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Override
|
|
|
|
public IRegistryContainer registries()
|
|
|
|
{
|
|
|
|
return this.registryContainer;
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
2015-01-03 02:53:14 +01:00
|
|
|
@Override
|
|
|
|
public IStorageHelper storage()
|
|
|
|
{
|
|
|
|
return this.storageHelper;
|
|
|
|
}
|
2014-09-24 02:26:27 +02:00
|
|
|
|
|
|
|
@Override
|
2015-04-20 21:12:03 +02:00
|
|
|
public ApiPart partHelper()
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.partHelper;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-01-03 02:53:14 +01:00
|
|
|
public ApiDefinitions definitions()
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-01-03 02:53:14 +01:00
|
|
|
return this.definitions;
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public IGridNode createGridNode( final IGridBlock blk )
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-12-24 02:03:16 +01:00
|
|
|
if( Platform.isClient() )
|
2015-04-29 02:30:53 +02:00
|
|
|
{
|
2015-03-23 10:14:35 +01:00
|
|
|
throw new IllegalStateException( "Grid features for " + blk + " are server side only." );
|
2015-04-29 02:30:53 +02:00
|
|
|
}
|
2015-03-23 10:14:35 +01:00
|
|
|
|
2014-09-24 02:26:27 +02:00
|
|
|
return new GridNode( blk );
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-09-30 14:24:40 +02:00
|
|
|
public IGridConnection createGridConnection( final IGridNode a, final IGridNode b ) throws FailedConnection
|
2014-09-24 02:26:27 +02:00
|
|
|
{
|
2015-06-16 02:44:59 +02:00
|
|
|
return new GridConnection( a, b, AEPartLocation.INTERNAL );
|
2014-09-24 02:26:27 +02:00
|
|
|
}
|
|
|
|
}
|