Remove External Storage Handler (#2417) (#2508)

* Implemented an adapter for IItemHandler so it can be used by the Storage Bus.
* Added update hook for inject/extract to ItemHandlerAdapter.
* Implemented ItemHandler and FluidHandler capabilities for the condenser, as replacement for the Void Inventories.
* Removed external storage handler, added capability-based way of accessing a monitorable ME network via the storage bus. Removed special case inventories for the matter condenser.
* Implemented InventoryAdaptor for IItemHandler. This also now fixes molecular assemblers interaction with part interfaces.
This commit is contained in:
shartte
2016-10-26 22:58:23 +02:00
committed by yueh
parent 057754c851
commit b977ee89ee
34 changed files with 1203 additions and 1065 deletions
@@ -1,70 +0,0 @@
/*
* 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>.
*/
package appeng.core.features.registries;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IExternalStorageRegistry;
import appeng.api.storage.StorageChannel;
import appeng.core.features.registries.entries.ExternalIInv;
public class ExternalStorageRegistry implements IExternalStorageRegistry
{
private final List<IExternalStorageHandler> Handlers;
private final ExternalIInv lastHandler = new ExternalIInv();
public ExternalStorageRegistry()
{
this.Handlers = new ArrayList<IExternalStorageHandler>();
}
@Override
public void addExternalStorageInterface( final IExternalStorageHandler ei )
{
this.Handlers.add( ei );
}
@Override
public IExternalStorageHandler getHandler( final TileEntity te, final EnumFacing d, final StorageChannel chan, final BaseActionSource mySrc )
{
for( final IExternalStorageHandler x : this.Handlers )
{
if( x.canHandle( te, d, chan, mySrc ) )
{
return x;
}
}
if( this.lastHandler.canHandle( te, d, chan, mySrc ) )
{
return this.lastHandler;
}
return null;
}
}
@@ -34,7 +34,6 @@ import appeng.api.movable.IMovableRegistry;
import appeng.api.networking.IGridCacheRegistry;
import appeng.api.parts.IPartModels;
import appeng.api.storage.ICellRegistry;
import appeng.api.storage.IExternalStorageRegistry;
/**
@@ -49,7 +48,6 @@ public class RegistryContainer implements IRegistryContainer
{
private final IGrinderRegistry grinder = new GrinderRecipeManager();
private final IInscriberRegistry inscriber = new InscriberRegistry();
private final IExternalStorageRegistry storage = new ExternalStorageRegistry();
private final ICellRegistry cell = new CellRegistry();
private final ILocatableRegistry locatable = new LocatableRegistry();
private final ISpecialComparisonRegistry comparison = new SpecialComparisonRegistry();
@@ -74,12 +72,6 @@ public class RegistryContainer implements IRegistryContainer
return this.gridCache;
}
@Override
public IExternalStorageRegistry externalStorage()
{
return this.storage;
}
@Override
public ISpecialComparisonRegistry specialComparison()
{
@@ -1,55 +0,0 @@
/*
* 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>.
*/
package appeng.core.features.registries.entries;
import net.minecraft.inventory.IInventory;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import appeng.api.networking.security.BaseActionSource;
import appeng.api.storage.IExternalStorageHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.StorageChannel;
import appeng.me.storage.MEMonitorIInventory;
import appeng.util.InventoryAdaptor;
public class ExternalIInv implements IExternalStorageHandler
{
@Override
public boolean canHandle( final TileEntity te, final EnumFacing d, final StorageChannel channel, final BaseActionSource mySrc )
{
return channel == StorageChannel.ITEMS && te instanceof IInventory;
}
@Override
public IMEInventory getInventory( final TileEntity te, final EnumFacing d, final StorageChannel channel, final BaseActionSource src )
{
final InventoryAdaptor ad = InventoryAdaptor.getAdaptor( te, d );
if( channel == StorageChannel.ITEMS && ad != null )
{
return new MEMonitorIInventory( ad );
}
return null;
}
}