Initial Fluid Integration (#3510)

* Added Fluid Storage Cells

* Added Fluid Import Bus

* Added Fluid Export Bus

* Added Fluid Storage Bus

* Added Fluid Terminal.
While holding a item with the FLUID_HANDLER_ITEM_CAPABILITY, such as a tank
Left click on a fluid to extract the fluid
Right click to insert the fluid
This commit is contained in:
Brock
2018-06-12 03:55:33 +10:00
committed by yueh
parent 89bebc4385
commit d16677224a
126 changed files with 8031 additions and 778 deletions
@@ -39,7 +39,7 @@ import appeng.api.storage.data.IAEStack;
import appeng.api.util.IConfigManager;
import appeng.container.interfaces.IInventorySlotAware;
import appeng.me.helpers.MEMonitorHandler;
import appeng.me.storage.CellInventory;
import appeng.me.storage.ItemCellInventory;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.Platform;
@@ -54,7 +54,7 @@ public class PortableCellViewer extends MEMonitorHandler<IAEItemStack> implement
public PortableCellViewer( final ItemStack is, final int slot )
{
super( CellInventory.getCell( is, null ) );
super( ItemCellInventory.getCell( is, null ) );
this.ips = (IAEItemPowerStorage) is.getItem();
this.target = is;
this.inventorySlot = slot;
@@ -114,7 +114,12 @@ public enum MaterialType
QUANTUM_ENTANGLED_SINGULARITY( 48, "material_quantum_entangled_singularity", EnumSet.of( AEFeature.QUANTUM_NETWORK_BRIDGE ), EntitySingularity.class ),
BLANK_PATTERN( 52, "material_blank_pattern", EnumSet.of( AEFeature.PATTERNS ) ),
CARD_CRAFTING( 53, "material_card_crafting", EnumSet.of( AEFeature.ADVANCED_CARDS, AEFeature.CRAFTING_CPU ) );
CARD_CRAFTING( 53, "material_card_crafting", EnumSet.of( AEFeature.ADVANCED_CARDS, AEFeature.CRAFTING_CPU ) ),
FLUID_CELL1K_PART( 54, "material_fluid_cell1k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
FLUID_CELL4K_PART( 55, "material_fluid_cell4k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
FLUID_CELL16K_PART( 56, "material_fluid_cell16k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) ),
FLUID_CELL64K_PART( 57, "material_fluid_cell64k_part", EnumSet.of( AEFeature.STORAGE_CELLS ) );
private final Set<AEFeature> features;
private final ModelResourceLocation model;
+21 -1
View File
@@ -278,7 +278,9 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
{
boolean importBus = false;
boolean importBusFluids = false;
boolean exportBus = false;
boolean exportBusFluids = false;
boolean group = false;
final PartType u = this.getTypeByStack( is );
@@ -297,6 +299,13 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
group = true;
}
break;
case FLUID_IMPORT_BUS:
importBusFluids = true;
if( u == pt )
{
group = true;
}
break;
case EXPORT_BUS:
exportBus = true;
if( u == pt )
@@ -304,15 +313,26 @@ public final class ItemPart extends AEBaseItem implements IPartItem, IItemGroup
group = true;
}
break;
case FLUID_EXPORT_BUS:
exportBusFluids = true;
if( u == pt )
{
group = true;
}
break;
default:
}
}
}
if( group && importBus && exportBus )
if( group && importBus && exportBus && ( u == PartType.IMPORT_BUS || u == PartType.EXPORT_BUS ) )
{
return GuiText.IOBuses.getUnlocalized();
}
if( group && importBusFluids && exportBusFluids && ( u == PartType.FLUID_IMPORT_BUS || u == PartType.FLUID_EXPORT_BUS ) )
{
return GuiText.IOBusesFluids.getUnlocalized();
}
return null;
}
+12 -1
View File
@@ -41,6 +41,9 @@ import appeng.core.AEConfig;
import appeng.core.AppEng;
import appeng.core.features.AEFeature;
import appeng.core.localization.GuiText;
import appeng.fluids.parts.PartFluidExportBus;
import appeng.fluids.parts.PartFluidImportBus;
import appeng.fluids.parts.PartFluidStorageBus;
import appeng.integration.IntegrationRegistry;
import appeng.integration.IntegrationType;
import appeng.parts.automation.PartAnnihilationPlane;
@@ -70,6 +73,7 @@ import appeng.parts.p2p.PartP2PTunnelME;
import appeng.parts.reporting.PartConversionMonitor;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartDarkPanel;
import appeng.parts.reporting.PartFluidTerminal;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.parts.reporting.PartPanel;
import appeng.parts.reporting.PartPatternTerminal;
@@ -190,11 +194,16 @@ public enum PartType
DARK_MONITOR( 200, "dark_monitor", EnumSet.of( AEFeature.PANELS ), EnumSet.noneOf( IntegrationType.class ), PartDarkPanel.class ),
STORAGE_BUS( 220, "storage_bus", EnumSet.of( AEFeature.STORAGE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartStorageBus.class ),
FLUID_STORAGE_BUS( 221, "fluid_storage_bus", EnumSet.of( AEFeature.FLUID_STORAGE_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidStorageBus.class ),
IMPORT_BUS( 240, "import_bus", EnumSet.of( AEFeature.IMPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartImportBus.class ),
FLUID_IMPORT_BUS( 241, "fluid_import_bus", EnumSet.of( AEFeature.FLUID_IMPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidImportBus.class ),
EXPORT_BUS( 260, "export_bus", EnumSet.of( AEFeature.EXPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartExportBus.class ),
FLUID_EXPORT_BUS( 261, "fluid_export_bus", EnumSet.of( AEFeature.FLUID_EXPORT_BUS ), EnumSet.noneOf( IntegrationType.class ), PartFluidExportBus.class ),
LEVEL_EMITTER( 280, "level_emitter", EnumSet.of( AEFeature.LEVEL_EMITTER ), EnumSet.noneOf( IntegrationType.class ), PartLevelEmitter.class ),
ANNIHILATION_PLANE( 300, "annihilation_plane", EnumSet.of( AEFeature.ANNIHILATION_PLANE ), EnumSet
@@ -293,7 +302,9 @@ public enum PartType
// IntegrationType.OpenComputers ), PartP2POpenComputers.class, GuiText.OCTunnel ),
INTERFACE_TERMINAL( 480, "interface_terminal", EnumSet.of( AEFeature.INTERFACE_TERMINAL ), EnumSet
.noneOf( IntegrationType.class ), PartInterfaceTerminal.class );
.noneOf( IntegrationType.class ), PartInterfaceTerminal.class ),
FLUID_TERMINAL( 520, "fluid_terminal", EnumSet.of( AEFeature.FLUID_TERMINAL ), EnumSet.noneOf( IntegrationType.class ), PartFluidTerminal.class );
private final int baseDamage;
private final Set<AEFeature> features;
@@ -1,6 +1,6 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2014, AlgorithmX2, All rights reserved.
* Copyright (c) 2013 - 2018, 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
@@ -46,8 +46,8 @@ import appeng.api.implementations.items.IUpgradeModule;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventoryHandler;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.core.AEConfig;
import appeng.core.features.AEFeature;
@@ -60,49 +60,28 @@ import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCell, IItemGroup
/**
* @author DrummerMC
* @version rv6 - 2018-01-17
* @since rv6 2018-01-17
*/
public abstract class AbstractStorageCell<T extends IAEStack<T>> extends AEBaseItem implements IStorageCell<T>, IItemGroup
{
private final MaterialType component;
private final int totalBytes;
private final int perType;
private final double idleDrain;
protected final MaterialType component;
protected final int totalBytes;
public ItemBasicStorageCell( final MaterialType whichCell, final int kilobytes )
public AbstractStorageCell( final MaterialType whichCell, final int kilobytes )
{
this.setMaxStackSize( 1 );
this.totalBytes = kilobytes * 1024;
this.component = whichCell;
switch( this.component )
{
case CELL1K_PART:
this.idleDrain = 0.5;
this.perType = 8;
break;
case CELL4K_PART:
this.idleDrain = 1.0;
this.perType = 32;
break;
case CELL16K_PART:
this.idleDrain = 1.5;
this.perType = 128;
break;
case CELL64K_PART:
this.idleDrain = 2.0;
this.perType = 512;
break;
default:
this.idleDrain = 0.0;
this.perType = 8;
}
}
@SideOnly( Side.CLIENT )
@Override
public void addCheckedInformation( final ItemStack stack, final World world, final List<String> lines, final ITooltipFlag advancedTooltips )
{
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventoryHandler<?> inventory = AEApi.instance().registries().cell().getCellInventory( stack, null, getChannel() );
if( inventory instanceof ICellInventoryHandler )
{
@@ -111,11 +90,9 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
if( cellInventory != null )
{
lines.add(
cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal() );
lines.add( cellInventory.getUsedBytes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalBytes() + ' ' + GuiText.BytesUsed.getLocal() );
lines.add( cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalItemTypes() + ' ' + GuiText.Types
.getLocal() );
lines.add( cellInventory.getStoredItemTypes() + " " + GuiText.Of.getLocal() + ' ' + cellInventory.getTotalItemTypes() + ' ' + GuiText.Types.getLocal() );
if( handler.isPreformatted() )
{
@@ -140,12 +117,6 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
return this.totalBytes;
}
@Override
public int getBytesPerType( final ItemStack cellItem )
{
return this.perType;
}
@Override
public int getTotalTypes( final ItemStack cellItem )
{
@@ -153,7 +124,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
}
@Override
public boolean isBlackListed( final ItemStack cellItem, final IAEItemStack requestedAddition )
public boolean isBlackListed( final ItemStack cellItem, final T requestedAddition )
{
return false;
}
@@ -170,12 +141,6 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
return true;
}
@Override
public double getIdleDrain()
{
return this.idleDrain;
}
@Override
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
{
@@ -237,13 +202,11 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
}
final InventoryPlayer playerInventory = player.inventory;
final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventoryHandler inv = AEApi.instance().registries().cell().getCellInventory( stack, null, getChannel() );
if( inv != null && playerInventory.getCurrentItem() == stack )
{
final InventoryAdaptor ia = InventoryAdaptor.getAdaptor( player );
final IItemList<IAEItemStack> list = inv
.getAvailableItems( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createList() );
final IItemList<IAEItemStack> list = inv.getAvailableItems( getChannel().createList() );
if( list.isEmpty() && ia != null )
{
playerInventory.setInventorySlotContents( playerInventory.currentItem, ItemStack.EMPTY );
@@ -268,14 +231,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
}
// drop empty storage cell case
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is ->
{
final ItemStack extraA = ia.addItems( is );
if( !extraA.isEmpty() )
{
player.dropItem( extraA, false );
}
} );
dropEmptyStorageCellCase( ia, player );
if( player.inventoryContainer != null )
{
@@ -289,6 +245,8 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
return false;
}
protected abstract void dropEmptyStorageCellCase( final InventoryAdaptor ia, final EntityPlayer player );
@Override
public EnumActionResult onItemUseFirst( final EntityPlayer player, final World world, final BlockPos pos, final EnumFacing side, final float hitX, final float hitY, final float hitZ, final EnumHand hand )
{
@@ -298,12 +256,7 @@ public final class ItemBasicStorageCell extends AEBaseItem implements IStorageCe
@Override
public ItemStack getContainerItem( final ItemStack itemStack )
{
return AEApi.instance()
.definitions()
.materials()
.emptyStorageCell()
.maybeStack( 1 )
.orElseThrow( () -> new MissingDefinitionException( "Tried to use empty storage cells while basic storage cells are defined." ) );
return AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).orElseThrow( () -> new MissingDefinitionException( "Tried to use empty storage cells while basic storage cells are defined." ) );
}
@Override
@@ -0,0 +1,96 @@
/*
* 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.items.storage;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import appeng.api.AEApi;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.items.materials.MaterialType;
import appeng.util.InventoryAdaptor;
public final class BasicItemStorageCell extends AbstractStorageCell<IAEItemStack>
{
protected final int perType;
protected final double idleDrain;
public BasicItemStorageCell( final MaterialType whichCell, final int kilobytes )
{
super(whichCell, kilobytes);
switch( whichCell )
{
case CELL1K_PART:
this.idleDrain = 0.5;
this.perType = 8;
break;
case CELL4K_PART:
this.idleDrain = 1.0;
this.perType = 32;
break;
case CELL16K_PART:
this.idleDrain = 1.5;
this.perType = 128;
break;
case CELL64K_PART:
this.idleDrain = 2.0;
this.perType = 512;
break;
default:
this.idleDrain = 0.0;
this.perType = 8;
}
}
@Override
public int getBytesPerType( ItemStack cellItem )
{
return this.perType;
}
@Override
public double getIdleDrain()
{
return this.idleDrain;
}
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
protected void dropEmptyStorageCellCase( final InventoryAdaptor ia, final EntityPlayer player )
{
AEApi.instance().definitions().materials().emptyStorageCell().maybeStack( 1 ).ifPresent( is -> {
final ItemStack extraA = ia.addItems( is );
if( !extraA.isEmpty() )
{
player.dropItem( extraA, false );
}
} );
}
}
@@ -61,6 +61,7 @@ import appeng.api.implementations.tiles.IColorableTile;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IItemList;
@@ -77,13 +78,13 @@ import appeng.items.contents.CellUpgrades;
import appeng.items.misc.ItemPaintBall;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.helpers.BaseActionSource;
import appeng.me.storage.CellInventoryHandler;
import appeng.me.storage.ItemCellInventoryHandler;
import appeng.tile.misc.TilePaint;
import appeng.util.Platform;
import appeng.util.item.AEItemStack;
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell, IItemGroup, IBlockTool, IMouseWheelItem
public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IItemGroup, IBlockTool, IMouseWheelItem
{
private static final Map<Integer, AEColor> ORE_TO_COLOR = new HashMap<>();
@@ -434,7 +435,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
final IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( cdi instanceof CellInventoryHandler )
if( cdi instanceof ItemCellInventoryHandler )
{
final ICellInventory cd = ( (ICellInventoryHandler) cdi ).getCellInv();
if( cd != null )
@@ -506,6 +507,12 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
return 0.5;
}
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
{
@@ -55,6 +55,7 @@ import appeng.api.implementations.items.IStorageCell;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
@@ -76,13 +77,13 @@ import appeng.items.contents.CellUpgrades;
import appeng.items.misc.ItemPaintBall;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.helpers.PlayerSource;
import appeng.me.storage.CellInventoryHandler;
import appeng.me.storage.ItemCellInventoryHandler;
import appeng.tile.misc.TilePaint;
import appeng.util.LookDirection;
import appeng.util.Platform;
public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell<IAEItemStack>
{
public ToolMatterCannon()
@@ -99,7 +100,7 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
final IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( cdi instanceof CellInventoryHandler )
if( cdi instanceof ItemCellInventoryHandler )
{
final ICellInventory cd = ( (ICellInventoryHandler) cdi ).getCellInv();
if( cd != null )
@@ -529,4 +530,10 @@ public class ToolMatterCannon extends AEBasePoweredItem implements IStorageCell
{
return 0.5;
}
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
}
@@ -43,6 +43,7 @@ import appeng.api.implementations.items.IStorageCell;
import appeng.api.storage.ICellInventory;
import appeng.api.storage.ICellInventoryHandler;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.AEPartLocation;
@@ -53,11 +54,11 @@ import appeng.items.contents.CellConfig;
import appeng.items.contents.CellUpgrades;
import appeng.items.contents.PortableCellViewer;
import appeng.items.tools.powered.powersink.AEBasePoweredItem;
import appeng.me.storage.CellInventoryHandler;
import appeng.me.storage.ItemCellInventoryHandler;
import appeng.util.Platform;
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell, IGuiItem, IItemGroup
public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell<IAEItemStack>, IGuiItem, IItemGroup
{
public ToolPortableCell()
{
@@ -87,7 +88,7 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
final IMEInventory<IAEItemStack> cdi = AEApi.instance().registries().cell().getCellInventory( stack, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
if( cdi instanceof CellInventoryHandler )
if( cdi instanceof ItemCellInventoryHandler )
{
final ICellInventory cd = ( (ICellInventoryHandler) cdi ).getCellInv();
if( cd != null )
@@ -140,6 +141,12 @@ public class ToolPortableCell extends AEBasePoweredItem implements IStorageCell,
return 0.5;
}
@Override
public IStorageChannel<IAEItemStack> getChannel()
{
return AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class );
}
@Override
public String getUnlocalizedGroupName( final Set<ItemStack> others, final ItemStack is )
{