Generic ICellInventoryHandler (#3624)
Allows addons who register a custom IStorageChannel to use the IStorageCell interface without registering a cell handler. Also adds some helpers (poweredInsert/poweredExtract). This breaks API!
This commit is contained in:
@@ -23,6 +23,8 @@ import appeng.api.IAppEngApi;
|
||||
import appeng.api.features.IRegistryContainer;
|
||||
import appeng.api.networking.IGridHelper;
|
||||
import appeng.api.storage.IStorageHelper;
|
||||
import appeng.api.util.IClientHelper;
|
||||
import appeng.core.api.ApiClientHelper;
|
||||
import appeng.core.api.ApiGrid;
|
||||
import appeng.core.api.ApiPart;
|
||||
import appeng.core.api.ApiStorage;
|
||||
@@ -41,6 +43,7 @@ public final class Api implements IAppEngApi
|
||||
private final IStorageHelper storageHelper;
|
||||
private final IGridHelper networkHelper;
|
||||
private final ApiDefinitions definitions;
|
||||
private final IClientHelper client;
|
||||
|
||||
private Api()
|
||||
{
|
||||
@@ -49,6 +52,7 @@ public final class Api implements IAppEngApi
|
||||
this.registryContainer = new RegistryContainer();
|
||||
this.partHelper = new ApiPart();
|
||||
this.definitions = new ApiDefinitions( (PartModels) this.registryContainer.partModels() );
|
||||
this.client = new ApiClientHelper();
|
||||
}
|
||||
|
||||
public PartModels getPartModels()
|
||||
@@ -85,4 +89,10 @@ public final class Api implements IAppEngApi
|
||||
{
|
||||
return this.definitions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IClientHelper client()
|
||||
{
|
||||
return this.client;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -91,7 +91,8 @@ import appeng.bootstrap.components.IRecipeRegistrationComponent;
|
||||
import appeng.capabilities.Capabilities;
|
||||
import appeng.core.features.AEFeature;
|
||||
import appeng.core.features.registries.P2PTunnelRegistry;
|
||||
import appeng.core.features.registries.cell.BasicItemCellHandler;
|
||||
import appeng.core.features.registries.cell.BasicCellHandler;
|
||||
import appeng.core.features.registries.cell.BasicItemCellGuiHandler;
|
||||
import appeng.core.features.registries.cell.CreativeCellHandler;
|
||||
import appeng.core.localization.GuiText;
|
||||
import appeng.core.localization.PlayerMessages;
|
||||
@@ -99,7 +100,7 @@ import appeng.core.stats.AdvancementTriggers;
|
||||
import appeng.core.stats.PartItemPredicate;
|
||||
import appeng.core.stats.Stats;
|
||||
import appeng.core.worlddata.SpatialDimensionManager;
|
||||
import appeng.fluids.registries.BasicFluidCellHandler;
|
||||
import appeng.fluids.registries.BasicFluidCellGuiHandler;
|
||||
import appeng.hooks.TickHandler;
|
||||
import appeng.items.materials.ItemMaterial;
|
||||
import appeng.items.parts.ItemFacade;
|
||||
@@ -236,9 +237,10 @@ final class Registration
|
||||
gcr.registerGridCache( ISecurityGrid.class, SecurityCache.class );
|
||||
gcr.registerGridCache( ICraftingGrid.class, CraftingGridCache.class );
|
||||
|
||||
registries.cell().addCellHandler( new BasicItemCellHandler() );
|
||||
registries.cell().addCellHandler( new BasicCellHandler() );
|
||||
registries.cell().addCellHandler( new CreativeCellHandler() );
|
||||
registries.cell().addCellHandler( new BasicFluidCellHandler() );
|
||||
registries.cell().addCellGuiHandler( new BasicItemCellGuiHandler() );
|
||||
registries.cell().addCellGuiHandler( new BasicFluidCellGuiHandler() );
|
||||
|
||||
api.definitions().materials().matterBall().maybeStack( 1 ).ifPresent( ammoStack ->
|
||||
{
|
||||
@@ -286,7 +288,7 @@ final class Registration
|
||||
final Side side = FMLCommonHandler.instance().getEffectiveSide();
|
||||
definitions.getRegistry().getBootstrapComponents( IItemRegistrationComponent.class ).forEachRemaining( b -> b.itemRegistration( side, registry ) );
|
||||
// register oredicts
|
||||
definitions.getRegistry().getBootstrapComponents( IOreDictComponent.class ).forEachRemaining( b -> b.oreRegistration( side ) );
|
||||
definitions.getRegistry().getBootstrapComponents( IOreDictComponent.class ).forEachRemaining( b -> b.oreRegistration( side ) );
|
||||
ItemMaterial.instance.registerOredicts();
|
||||
ItemPart.instance.registerOreDicts();
|
||||
}
|
||||
@@ -320,15 +322,15 @@ final class Registration
|
||||
final AERecipeLoader ldr = new AERecipeLoader();
|
||||
ldr.loadProcessingRecipes();
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void registerEntities( RegistryEvent.Register<EntityEntry> event)
|
||||
public void registerEntities( RegistryEvent.Register<EntityEntry> event )
|
||||
{
|
||||
final IForgeRegistry<EntityEntry> registry = event.getRegistry();
|
||||
final ApiDefinitions definitions = Api.INSTANCE.definitions();
|
||||
definitions.getRegistry().getBootstrapComponents( IEntityRegistrationComponent.class ).forEachRemaining( b -> b.entityRegistration( registry ) );
|
||||
}
|
||||
|
||||
|
||||
@SubscribeEvent
|
||||
public void attachSpatialDimensionManager( AttachCapabilitiesEvent<World> event )
|
||||
{
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
|
||||
package appeng.core.api;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import appeng.api.config.IncludeExclude;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.IClientHelper;
|
||||
import appeng.core.localization.GuiText;
|
||||
|
||||
|
||||
public class ApiClientHelper implements IClientHelper
|
||||
{
|
||||
@Override
|
||||
public <T extends IAEStack<T>> void addCellInformation( ICellInventoryHandler<T> handler, List<String> lines )
|
||||
{
|
||||
if( handler == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final ICellInventory<?> cellInventory = handler.getCellInv();
|
||||
|
||||
if( cellInventory != null )
|
||||
{
|
||||
lines.add( cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal() );
|
||||
|
||||
lines.add( cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalItemTypes() + ' ' + GuiText.Types
|
||||
.getLocal() );
|
||||
}
|
||||
|
||||
if( handler.isPreformatted() )
|
||||
{
|
||||
final String list = ( handler.getIncludeExcludeMode() == IncludeExclude.WHITELIST ? GuiText.Included : GuiText.Excluded ).getLocal();
|
||||
|
||||
if( handler.isFuzzy() )
|
||||
{
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Fuzzy.getLocal() );
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add( GuiText.Partitioned.getLocal() + " - " + list + ' ' + GuiText.Precise.getLocal() );
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -32,7 +32,9 @@ import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidUtil;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.networking.crafting.ICraftingLink;
|
||||
import appeng.api.networking.crafting.ICraftingRequester;
|
||||
import appeng.api.networking.energy.IEnergySource;
|
||||
@@ -47,6 +49,7 @@ import appeng.api.storage.data.IAEItemStack;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.storage.data.IItemList;
|
||||
import appeng.crafting.CraftingLink;
|
||||
import appeng.fluids.items.FluidDummyItem;
|
||||
import appeng.fluids.util.AEFluidStack;
|
||||
import appeng.fluids.util.FluidList;
|
||||
import appeng.util.Platform;
|
||||
@@ -104,6 +107,18 @@ public class ApiStorage implements IStorageHelper
|
||||
return new CraftingLink( data, req );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> T poweredInsert( IEnergySource energy, IMEInventory<T> inv, T input, IActionSource src, Actionable mode )
|
||||
{
|
||||
return Platform.poweredInsert( energy, inv, input, src, mode );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> T poweredExtraction( IEnergySource energy, IMEInventory<T> inv, T request, IActionSource src, Actionable mode )
|
||||
{
|
||||
return Platform.poweredExtraction( energy, inv, request, src, mode );
|
||||
}
|
||||
|
||||
private static final class ItemStorageChannel implements IItemStorageChannel
|
||||
{
|
||||
|
||||
@@ -126,6 +141,13 @@ public class ApiStorage implements IStorageHelper
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack createFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
Preconditions.checkNotNull( nbt );
|
||||
return AEItemStack.fromNBT( nbt );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack readFromPacket( ByteBuf input ) throws IOException
|
||||
{
|
||||
@@ -133,28 +155,6 @@ public class ApiStorage implements IStorageHelper
|
||||
|
||||
return AEItemStack.fromPacket( input );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredExtraction( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack request, IActionSource src )
|
||||
{
|
||||
Preconditions.checkNotNull( energy );
|
||||
Preconditions.checkNotNull( cell );
|
||||
Preconditions.checkNotNull( request );
|
||||
Preconditions.checkNotNull( src );
|
||||
|
||||
return Platform.poweredExtraction( energy, cell, request, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEItemStack poweredInsert( IEnergySource energy, IMEInventory<IAEItemStack> cell, IAEItemStack input, IActionSource src )
|
||||
{
|
||||
Preconditions.checkNotNull( energy );
|
||||
Preconditions.checkNotNull( cell );
|
||||
Preconditions.checkNotNull( input );
|
||||
Preconditions.checkNotNull( src );
|
||||
|
||||
return Platform.poweredInsert( energy, cell, input, src );
|
||||
}
|
||||
}
|
||||
|
||||
private static final class FluidStorageChannel implements IFluidStorageChannel
|
||||
@@ -166,6 +166,12 @@ public class ApiStorage implements IStorageHelper
|
||||
return 125;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUnitsPerByte()
|
||||
{
|
||||
return 8000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IItemList<IAEFluidStack> createList()
|
||||
{
|
||||
@@ -181,6 +187,18 @@ public class ApiStorage implements IStorageHelper
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( (FluidStack) input );
|
||||
}
|
||||
if( input instanceof ItemStack )
|
||||
{
|
||||
final ItemStack is = (ItemStack) input;
|
||||
if( is.getItem() instanceof FluidDummyItem )
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( ( (FluidDummyItem) is.getItem() ).getFluidStack( is ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
return AEFluidStack.fromFluidStack( FluidUtil.getFluidContained( is ) );
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
@@ -194,25 +212,10 @@ public class ApiStorage implements IStorageHelper
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack poweredExtraction( IEnergySource energy, IMEInventory<IAEFluidStack> cell, IAEFluidStack request, IActionSource src )
|
||||
public IAEFluidStack createFromNBT( NBTTagCompound nbt )
|
||||
{
|
||||
Preconditions.checkNotNull( energy );
|
||||
Preconditions.checkNotNull( cell );
|
||||
Preconditions.checkNotNull( request );
|
||||
Preconditions.checkNotNull( src );
|
||||
|
||||
return Platform.poweredExtraction( energy, cell, request, src );
|
||||
}
|
||||
|
||||
@Override
|
||||
public IAEFluidStack poweredInsert( IEnergySource energy, IMEInventory<IAEFluidStack> cell, IAEFluidStack input, IActionSource src )
|
||||
{
|
||||
Preconditions.checkNotNull( energy );
|
||||
Preconditions.checkNotNull( cell );
|
||||
Preconditions.checkNotNull( input );
|
||||
Preconditions.checkNotNull( src );
|
||||
|
||||
return Platform.poweredInsert( energy, cell, input, src );
|
||||
Preconditions.checkNotNull( nbt );
|
||||
return AEFluidStack.fromNBT( nbt );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, 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.cell;
|
||||
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.me.storage.BasicCellInventory;
|
||||
import appeng.me.storage.BasicCellInventoryHandler;
|
||||
|
||||
|
||||
public class BasicCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell( final ItemStack is )
|
||||
{
|
||||
return BasicCellInventory.isCell( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
|
||||
{
|
||||
final ICellInventory<T> inv = BasicCellInventory.createInventory( is, container );
|
||||
if( inv == null || inv.getChannel() != channel )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new BasicCellInventoryHandler<>( inv, channel );
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
|
||||
package appeng.core.features.registries.cell;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellGuiHandler;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BasicItemCellGuiHandler implements ICellGuiHandler
|
||||
{
|
||||
@Override
|
||||
public <T extends IAEStack<T>> boolean isHandlerFor( final IStorageChannel<T> channel )
|
||||
{
|
||||
return channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui( final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan )
|
||||
{
|
||||
Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_ME );
|
||||
}
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2015, 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.cell;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventory;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.storage.data.IAEStack;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.storage.ItemCellInventory;
|
||||
import appeng.me.storage.ItemCellInventoryHandler;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public class BasicItemCellHandler implements ICellHandler
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean isCell( final ItemStack is )
|
||||
{
|
||||
return ItemCellInventory.isCell( is );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellInventoryHandler<T> getCellInventory( final ItemStack is, final ISaveProvider container, final IStorageChannel<T> channel )
|
||||
{
|
||||
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
return (ICellInventoryHandler<T>) ItemCellInventory.getCell( is, container );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui( final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan )
|
||||
{
|
||||
if( chan == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
|
||||
{
|
||||
Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_ME );
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell( final ItemStack is, final IMEInventory handler )
|
||||
{
|
||||
if( handler instanceof ItemCellInventoryHandler )
|
||||
{
|
||||
final ItemCellInventoryHandler ci = (ItemCellInventoryHandler) handler;
|
||||
return ci.getStatusForCell();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain( final ItemStack is, final IMEInventory handler )
|
||||
{
|
||||
final ICellInventory inv = ( (ICellInventoryHandler) handler ).getCellInv();
|
||||
return inv.getIdleDrain();
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.google.common.base.Verify;
|
||||
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.storage.ICellGuiHandler;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.ICellRegistry;
|
||||
@@ -39,10 +40,12 @@ public class CellRegistry implements ICellRegistry
|
||||
{
|
||||
|
||||
private final List<ICellHandler> handlers;
|
||||
private final List<ICellGuiHandler> guiHandlers;
|
||||
|
||||
public CellRegistry()
|
||||
{
|
||||
this.handlers = new ArrayList<>();
|
||||
this.guiHandlers = new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -54,7 +57,7 @@ public class CellRegistry implements ICellRegistry
|
||||
this.handlers.add( handler );
|
||||
|
||||
// Verify that the first entry is always our own handler.
|
||||
Verify.verify( this.handlers.get( 0 ) instanceof BasicItemCellHandler );
|
||||
Verify.verify( this.handlers.get( 0 ) instanceof BasicCellHandler );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,4 +110,33 @@ public class CellRegistry implements ICellRegistry
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addCellGuiHandler( ICellGuiHandler handler )
|
||||
{
|
||||
this.guiHandlers.add( handler );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends IAEStack<T>> ICellGuiHandler getGuiHandler( final IStorageChannel<T> channel, final ItemStack is )
|
||||
{
|
||||
ICellGuiHandler fallBack = null;
|
||||
|
||||
for( final ICellGuiHandler ch : this.guiHandlers )
|
||||
{
|
||||
if( ch.isHandlerFor( channel ) )
|
||||
{
|
||||
if( ch.isSpecializedFor( is ) )
|
||||
{
|
||||
return ch;
|
||||
}
|
||||
|
||||
if( fallBack == null )
|
||||
{
|
||||
fallBack = ch;
|
||||
}
|
||||
}
|
||||
}
|
||||
return fallBack;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,24 +19,16 @@
|
||||
package appeng.core.features.registries.cell;
|
||||
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.implementations.tiles.IChestOrDrive;
|
||||
import appeng.api.storage.ICellHandler;
|
||||
import appeng.api.storage.ICellInventoryHandler;
|
||||
import appeng.api.storage.IMEInventory;
|
||||
import appeng.api.storage.IMEInventoryHandler;
|
||||
import appeng.api.storage.ISaveProvider;
|
||||
import appeng.api.storage.IStorageChannel;
|
||||
import appeng.api.storage.channels.IItemStorageChannel;
|
||||
import appeng.api.util.AEPartLocation;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.items.storage.ItemCreativeStorageCell;
|
||||
import appeng.me.storage.CreativeCellInventory;
|
||||
import appeng.util.Platform;
|
||||
|
||||
|
||||
public final class CreativeCellHandler implements ICellHandler
|
||||
@@ -60,19 +52,13 @@ public final class CreativeCellHandler implements ICellHandler
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openChestGui( final EntityPlayer player, final IChestOrDrive chest, final ICellHandler cellHandler, final IMEInventoryHandler inv, final ItemStack is, final IStorageChannel chan )
|
||||
{
|
||||
Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_ME );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStatusForCell( final ItemStack is, final IMEInventory handler )
|
||||
public int getStatusForCell( final ItemStack is, final ICellInventoryHandler handler )
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double cellIdleDrain( final ItemStack is, final IMEInventory handler )
|
||||
public double cellIdleDrain( final ItemStack is, final ICellInventoryHandler handler )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user