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
+18 -2
View File
@@ -91,7 +91,7 @@ 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.BasicCellHandler;
import appeng.core.features.registries.cell.BasicItemCellHandler;
import appeng.core.features.registries.cell.CreativeCellHandler;
import appeng.core.localization.GuiText;
import appeng.core.localization.PlayerMessages;
@@ -99,6 +99,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.hooks.TickHandler;
import appeng.items.materials.ItemMaterial;
import appeng.items.parts.ItemFacade;
@@ -286,8 +287,9 @@ final class Registration
gcr.registerGridCache( ISecurityGrid.class, SecurityCache.class );
gcr.registerGridCache( ICraftingGrid.class, CraftingGridCache.class );
registries.cell().addCellHandler( new BasicCellHandler() );
registries.cell().addCellHandler( new BasicItemCellHandler() );
registries.cell().addCellHandler( new CreativeCellHandler() );
registries.cell().addCellHandler( new BasicFluidCellHandler() );
api.definitions().materials().matterBall().maybeStack( 1 ).ifPresent( ammoStack ->
{
@@ -423,6 +425,11 @@ final class Registration
Upgrades.CAPACITY.registerItem( parts.importBus(), 2 );
Upgrades.SPEED.registerItem( parts.importBus(), 4 );
// Fluid Import Bus
Upgrades.CAPACITY.registerItem( parts.fluidImportBus(), 2 );
Upgrades.REDSTONE.registerItem( parts.fluidImportBus(), 1 );
Upgrades.SPEED.registerItem( parts.fluidImportBus(), 4 );
// Export Bus
Upgrades.FUZZY.registerItem( parts.exportBus(), 1 );
Upgrades.REDSTONE.registerItem( parts.exportBus(), 1 );
@@ -430,6 +437,11 @@ final class Registration
Upgrades.SPEED.registerItem( parts.exportBus(), 4 );
Upgrades.CRAFTING.registerItem( parts.exportBus(), 1 );
// Fluid Export Bus
Upgrades.CAPACITY.registerItem( parts.fluidExportBus(), 2 );
Upgrades.REDSTONE.registerItem( parts.fluidExportBus(), 1 );
Upgrades.SPEED.registerItem( parts.fluidExportBus(), 4 );
// Storage Cells
Upgrades.FUZZY.registerItem( items.cell1k(), 1 );
Upgrades.INVERTER.registerItem( items.cell1k(), 1 );
@@ -454,6 +466,10 @@ final class Registration
Upgrades.INVERTER.registerItem( parts.storageBus(), 1 );
Upgrades.CAPACITY.registerItem( parts.storageBus(), 5 );
// Storage Bus Fluids
Upgrades.INVERTER.registerItem( parts.fluidStorageBus(), 1 );
Upgrades.CAPACITY.registerItem( parts.fluidStorageBus(), 5 );
// Formation Plane
Upgrades.FUZZY.registerItem( parts.formationPlane(), 1 );
Upgrades.INVERTER.registerItem( parts.formationPlane(), 1 );
@@ -163,7 +163,7 @@ public class ApiStorage implements IStorageHelper
@Override
public int transferFactor()
{
return 1000;
return 125;
}
@Override
@@ -30,6 +30,9 @@ import appeng.debug.ToolDebugCard;
import appeng.debug.ToolEraser;
import appeng.debug.ToolMeteoritePlacer;
import appeng.debug.ToolReplicatorCard;
import appeng.fluids.items.BasicFluidStorageCell;
import appeng.fluids.items.FluidDummyItem;
import appeng.fluids.items.FluidDummyItemRendering;
import appeng.hooks.DispenserBlockTool;
import appeng.hooks.DispenserMatterCannon;
import appeng.items.materials.MaterialType;
@@ -40,7 +43,7 @@ import appeng.items.misc.ItemPaintBall;
import appeng.items.misc.ItemPaintBallRendering;
import appeng.items.parts.FacadeRendering;
import appeng.items.parts.ItemFacade;
import appeng.items.storage.ItemBasicStorageCell;
import appeng.items.storage.BasicItemStorageCell;
import appeng.items.storage.ItemCreativeStorageCell;
import appeng.items.storage.ItemSpatialStorageCell;
import appeng.items.storage.ItemViewCell;
@@ -102,6 +105,11 @@ public final class ApiItems implements IItems
private final IItemDefinition cell16k;
private final IItemDefinition cell64k;
private final IItemDefinition fluidCell1k;
private final IItemDefinition fluidCell4k;
private final IItemDefinition fluidCell16k;
private final IItemDefinition fluidCell64k;
private final IItemDefinition spatialCell2;
private final IItemDefinition spatialCell16;
private final IItemDefinition spatialCell128;
@@ -123,6 +131,8 @@ public final class ApiItems implements IItems
private final IItemDefinition toolDebugCard;
private final IItemDefinition toolReplicatorCard;
private final IItemDefinition dummyFluidItem;
public ApiItems( FeatureFactory registry )
{
FeatureFactory certusTools = registry.features( AEFeature.CERTUS_QUARTZ_TOOLS );
@@ -198,10 +208,15 @@ public final class ApiItems implements IItems
this.viewCell = registry.item( "view_cell", ItemViewCell::new ).features( AEFeature.VIEW_CELL ).build();
FeatureFactory storageCells = registry.features( AEFeature.STORAGE_CELLS );
this.cell1k = storageCells.item( "storage_cell_1k", () -> new ItemBasicStorageCell( MaterialType.CELL1K_PART, 1 ) ).build();
this.cell4k = storageCells.item( "storage_cell_4k", () -> new ItemBasicStorageCell( MaterialType.CELL4K_PART, 4 ) ).build();
this.cell16k = storageCells.item( "storage_cell_16k", () -> new ItemBasicStorageCell( MaterialType.CELL16K_PART, 16 ) ).build();
this.cell64k = storageCells.item( "storage_cell_64k", () -> new ItemBasicStorageCell( MaterialType.CELL64K_PART, 64 ) ).build();
this.cell1k = storageCells.item( "storage_cell_1k", () -> new BasicItemStorageCell( MaterialType.CELL1K_PART, 1 ) ).build();
this.cell4k = storageCells.item( "storage_cell_4k", () -> new BasicItemStorageCell( MaterialType.CELL4K_PART, 4 ) ).build();
this.cell16k = storageCells.item( "storage_cell_16k", () -> new BasicItemStorageCell( MaterialType.CELL16K_PART, 16 ) ).build();
this.cell64k = storageCells.item( "storage_cell_64k", () -> new BasicItemStorageCell( MaterialType.CELL64K_PART, 64 ) ).build();
this.fluidCell1k = storageCells.item( "fluid_storage_cell_1k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL1K_PART, 1 ) ).build();
this.fluidCell4k = storageCells.item( "fluid_storage_cell_4k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL4K_PART, 4 ) ).build();
this.fluidCell16k = storageCells.item( "fluid_storage_cell_16k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL16K_PART, 16 ) ).build();
this.fluidCell64k = storageCells.item( "fluid_storage_cell_64k", () -> new BasicFluidStorageCell( MaterialType.FLUID_CELL64K_PART, 64 ) ).build();
FeatureFactory spatialCells = registry.features( AEFeature.SPATIAL_IO );
this.spatialCell2 = spatialCells.item( "spatial_storage_cell_2_cubed", () -> new ItemSpatialStorageCell( 2 ) ).build();
@@ -236,6 +251,8 @@ public final class ApiItems implements IItems
this.toolMeteoritePlacer = debugTools.item( "debug_meteorite_placer", ToolMeteoritePlacer::new ).build();
this.toolDebugCard = debugTools.item( "debug_card", ToolDebugCard::new ).build();
this.toolReplicatorCard = debugTools.item( "debug_replicator_card", ToolReplicatorCard::new ).build();
this.dummyFluidItem = registry.item( "dummy_fluid_item", FluidDummyItem::new ).rendering( new FluidDummyItemRendering() ).build();
}
@Override
@@ -406,6 +423,30 @@ public final class ApiItems implements IItems
return this.cell64k;
}
@Override
public IItemDefinition fluidCell1k()
{
return this.fluidCell1k;
}
@Override
public IItemDefinition fluidCell4k()
{
return this.fluidCell4k;
}
@Override
public IItemDefinition fluidCell16k()
{
return this.fluidCell16k;
}
@Override
public IItemDefinition fluidCell64k()
{
return this.fluidCell64k;
}
@Override
public IItemDefinition spatialCell2()
{
@@ -484,4 +525,9 @@ public final class ApiItems implements IItems
{
return this.toolReplicatorCard;
}
public IItemDefinition dummyFluidItem()
{
return this.dummyFluidItem;
}
}
@@ -111,6 +111,11 @@ public final class ApiMaterials implements IMaterials
private final IItemDefinition qESingularity;
private final IItemDefinition blankPattern;
private final IItemDefinition fluidCell1kPart;
private final IItemDefinition fluidCell4kPart;
private final IItemDefinition fluidCell16kPart;
private final IItemDefinition fluidCell64kPart;
public ApiMaterials( FeatureFactory registry )
{
final ItemMaterial materials = new ItemMaterial();
@@ -210,6 +215,11 @@ public final class ApiMaterials implements IMaterials
this.qESingularity = new DamagedItemDefinition( "material.singularity.entangled.quantum", materials
.createMaterial( MaterialType.QUANTUM_ENTANGLED_SINGULARITY ) );
this.blankPattern = new DamagedItemDefinition( "material.pattern.blank", materials.createMaterial( MaterialType.BLANK_PATTERN ) );
this.fluidCell1kPart = new DamagedItemDefinition( "material.cell.storage.1k", materials.createMaterial( MaterialType.FLUID_CELL1K_PART ) );
this.fluidCell4kPart = new DamagedItemDefinition( "material.cell.storage.4k", materials.createMaterial( MaterialType.FLUID_CELL4K_PART ) );
this.fluidCell16kPart = new DamagedItemDefinition( "material.cell.storage.16k", materials.createMaterial( MaterialType.FLUID_CELL16K_PART ) );
this.fluidCell64kPart = new DamagedItemDefinition( "material.cell.storage.64k", materials.createMaterial( MaterialType.FLUID_CELL64K_PART ) );
}
@Override
@@ -529,4 +539,28 @@ public final class ApiMaterials implements IMaterials
{
return this.blankPattern;
}
@Override
public IItemDefinition fluidCell1kPart()
{
return this.fluidCell1kPart;
}
@Override
public IItemDefinition fluidCell4kPart()
{
return this.fluidCell4kPart;
}
@Override
public IItemDefinition fluidCell16kPart()
{
return this.fluidCell16kPart;
}
@Override
public IItemDefinition fluidCell64kPart()
{
return this.fluidCell64kPart;
}
}
@@ -77,6 +77,10 @@ public final class ApiParts implements IParts
private final IItemDefinition terminal;
private final IItemDefinition storageMonitor;
private final IItemDefinition conversionMonitor;
private final IItemDefinition fluidImportBus;
private final IItemDefinition fluidExportBus;
private final IItemDefinition fluidTerminal;
private final IItemDefinition fluidStorageBus;
public ApiParts( FeatureFactory registry, PartModels partModels )
{
@@ -109,8 +113,8 @@ public final class ApiParts implements IParts
this.iface = new DamagedItemDefinition( "part.interface", itemPart.createPart( PartType.INTERFACE ) );
this.levelEmitter = new DamagedItemDefinition( "part.level_emitter", itemPart.createPart( PartType.LEVEL_EMITTER ) );
this.annihilationPlane = new DamagedItemDefinition( "part.plane.annihilation", itemPart.createPart( PartType.ANNIHILATION_PLANE ) );
this.identityAnnihilationPlane = new DamagedItemDefinition( "part.plane.annihiliation.identity", itemPart
.createPart( PartType.IDENTITY_ANNIHILATION_PLANE ) );
this.identityAnnihilationPlane = new DamagedItemDefinition( "part.plane.annihiliation.identity",
itemPart.createPart( PartType.IDENTITY_ANNIHILATION_PLANE ) );
this.formationPlane = new DamagedItemDefinition( "part.plane.formation", itemPart.createPart( PartType.FORMATION_PLANE ) );
this.p2PTunnelME = new DamagedItemDefinition( "part.tunnel.me", itemPart.createPart( PartType.P2P_TUNNEL_ME ) );
this.p2PTunnelRedstone = new DamagedItemDefinition( "part.tunnel.redstone", itemPart.createPart( PartType.P2P_TUNNEL_REDSTONE ) );
@@ -131,6 +135,10 @@ public final class ApiParts implements IParts
this.terminal = new DamagedItemDefinition( "part.terminal", itemPart.createPart( PartType.TERMINAL ) );
this.storageMonitor = new DamagedItemDefinition( "part.monitor.storage", itemPart.createPart( PartType.STORAGE_MONITOR ) );
this.conversionMonitor = new DamagedItemDefinition( "part.monitor.conversion", itemPart.createPart( PartType.CONVERSION_MONITOR ) );
this.fluidImportBus = new DamagedItemDefinition( "part.bus.import.fluid", itemPart.createPart( PartType.FLUID_IMPORT_BUS ) );
this.fluidExportBus = new DamagedItemDefinition( "part.bus.export.fluid", itemPart.createPart( PartType.FLUID_EXPORT_BUS ) );
this.fluidTerminal = new DamagedItemDefinition( "part.terminal.fluid", itemPart.createPart( PartType.FLUID_TERMINAL ) );
this.fluidStorageBus = new DamagedItemDefinition( "part.bus.storage.fluid", itemPart.createPart( PartType.FLUID_STORAGE_BUS ) );
}
private static AEColoredItemDefinition constructColoredDefinition( final ItemPart target, final PartType type )
@@ -380,4 +388,28 @@ public final class ApiParts implements IParts
{
return this.conversionMonitor;
}
@Override
public IItemDefinition fluidTerminal()
{
return this.fluidTerminal;
}
@Override
public IItemDefinition fluidImportBus()
{
return this.fluidImportBus;
}
@Override
public IItemDefinition fluidExportBus()
{
return this.fluidExportBus;
}
@Override
public IItemDefinition fluidStorageBus()
{
return this.fluidStorageBus;
}
}
@@ -1,6 +1,6 @@
/*
* This file is part of Applied Energistics 2.
* Copyright (c) 2013 - 2015, 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
@@ -76,6 +76,7 @@ public enum AEFeature
INTERFACE( "Interface", Constants.CATEGORY_NETWORK_BUSES ),
LEVEL_EMITTER( "LevelEmitter", Constants.CATEGORY_NETWORK_BUSES ),
FLUID_TERMINAL( "FluidTerminal", Constants.CATEGORY_NETWORK_BUSES ),
CRAFTING_TERMINAL( "CraftingTerminal", Constants.CATEGORY_NETWORK_BUSES ),
TERMINAL( "Terminal", Constants.CATEGORY_NETWORK_BUSES ),
STORAGE_MONITOR( "StorageMonitor", Constants.CATEGORY_NETWORK_BUSES ),
@@ -84,8 +85,11 @@ public enum AEFeature
ANNIHILATION_PLANE( "AnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ),
IDENTITY_ANNIHILATION_PLANE( "IdentityAnnihilationPlane", Constants.CATEGORY_NETWORK_BUSES ),
IMPORT_BUS( "ImportBus", Constants.CATEGORY_NETWORK_BUSES ),
FLUID_IMPORT_BUS( "FluidImportBus", Constants.CATEGORY_NETWORK_BUSES ),
EXPORT_BUS( "ExportBus", Constants.CATEGORY_NETWORK_BUSES ),
FLUID_EXPORT_BUS( "FluidExportBus", Constants.CATEGORY_NETWORK_BUSES ),
STORAGE_BUS( "StorageBus", Constants.CATEGORY_NETWORK_BUSES ),
FLUID_STORAGE_BUS( "FluidStorageBus", Constants.CATEGORY_NETWORK_BUSES ),
PART_CONVERSION_MONITOR( "PartConversionMonitor", Constants.CATEGORY_NETWORK_BUSES ),
TOGGLE_BUS( "ToggleBus", Constants.CATEGORY_NETWORK_BUSES ),
PANELS( "Panels", Constants.CATEGORY_NETWORK_BUSES ),
@@ -36,18 +36,18 @@ 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.CellInventory;
import appeng.me.storage.CellInventoryHandler;
import appeng.me.storage.ItemCellInventory;
import appeng.me.storage.ItemCellInventoryHandler;
import appeng.util.Platform;
public final class BasicCellHandler implements ICellHandler
public class BasicItemCellHandler implements ICellHandler
{
@Override
public boolean isCell( final ItemStack is )
{
return CellInventory.isCell( is );
return ItemCellInventory.isCell( is );
}
@Override
@@ -55,23 +55,27 @@ public final class BasicCellHandler implements ICellHandler
{
if( channel == AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) )
{
return CellInventory.getCell( is, container );
return 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 )
{
Platform.openGUI( player, (TileEntity) chest, AEPartLocation.fromFacing( chest.getUp() ), GuiBridge.GUI_ME );
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 CellInventoryHandler )
if( handler instanceof ItemCellInventoryHandler )
{
final CellInventoryHandler ci = (CellInventoryHandler) handler;
final ItemCellInventoryHandler ci = (ItemCellInventoryHandler) handler;
return ci.getStatusForCell();
}
return 0;
@@ -54,7 +54,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 BasicCellHandler );
Verify.verify( this.handlers.get( 0 ) instanceof BasicItemCellHandler );
}
@Override
@@ -129,6 +129,9 @@ public enum ButtonToolTips
ReportInaccessibleItems,
ReportInaccessibleItemsYes,
ReportInaccessibleItemsNo,
ReportInaccessibleFluids,
ReportInaccessibleFluidsYes,
ReportInaccessibleFluidsNo,
BlockPlacement,
BlockPlacementYes,
@@ -44,12 +44,15 @@ public enum GuiText
StoredItems,
Patterns,
ImportBus,
ImportBusFluids,
ExportBus,
ExportBusFluids,
CellWorkbench,
NetworkDetails,
StorageCells,
IOBuses,
IOBusesFluids,
IOPort,
BytesUsed,
@@ -64,6 +67,7 @@ public enum GuiText
EnergyDrain,
StorageBus,
StorageBusFluids,
Priority,
Security,
Encoded,
@@ -29,8 +29,12 @@ public enum TickRates
ImportBus( 5, 40 ),
FluidImportBus( 5, 40 ),
ExportBus( 5, 60 ),
FluidExportBus( 5, 60 ),
AnnihilationPlane( 2, 120 ),
METunnel( 5, 20 ),
@@ -45,6 +49,8 @@ public enum TickRates
StorageBus( 5, 60 ),
FluidStorageBus( 5, 60 ),
ItemTunnel( 5, 60 ),
LightTunnel( 5, 60 ),
@@ -36,6 +36,7 @@ import appeng.core.sync.packets.PacketCraftRequest;
import appeng.core.sync.packets.PacketInventoryAction;
import appeng.core.sync.packets.PacketJEIRecipe;
import appeng.core.sync.packets.PacketLightning;
import appeng.core.sync.packets.PacketMEFluidInventoryUpdate;
import appeng.core.sync.packets.PacketMEInventoryUpdate;
import appeng.core.sync.packets.PacketMatterCannon;
import appeng.core.sync.packets.PacketMockExplosion;
@@ -45,6 +46,7 @@ import appeng.core.sync.packets.PacketPatternSlot;
import appeng.core.sync.packets.PacketProgressBar;
import appeng.core.sync.packets.PacketSwapSlots;
import appeng.core.sync.packets.PacketSwitchGuis;
import appeng.core.sync.packets.PacketTargetFluidStack;
import appeng.core.sync.packets.PacketTargetItemStack;
import appeng.core.sync.packets.PacketTransitionEffect;
import appeng.core.sync.packets.PacketValueConfig;
@@ -64,6 +66,8 @@ public class AppEngPacketHandlerBase
PACKET_ME_INVENTORY_UPDATE( PacketMEInventoryUpdate.class ),
PACKET_ME_FLUID_INVENTORY_UPDATE( PacketMEFluidInventoryUpdate.class ),
PACKET_CONFIG_BUTTON( PacketConfigButton.class ),
PACKET_PART_PLACEMENT( PacketPartPlacement.class ),
@@ -92,6 +96,8 @@ public class AppEngPacketHandlerBase
PACKET_TARGET_ITEM( PacketTargetItemStack.class ),
PACKET_TARGET_FLUID( PacketTargetFluidStack.class ),
PACKET_CRAFTING_REQUEST( PacketCraftRequest.class ),
PACKET_ASSEMBLER_ANIMATION( PacketAssemblerAnimation.class ),
@@ -62,6 +62,9 @@ import appeng.container.implementations.ContainerCraftingCPU;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.container.implementations.ContainerCraftingTerm;
import appeng.container.implementations.ContainerDrive;
import appeng.container.implementations.ContainerFluidIO;
import appeng.container.implementations.ContainerFluidStorageBus;
import appeng.container.implementations.ContainerFluidTerminal;
import appeng.container.implementations.ContainerFormationPlane;
import appeng.container.implementations.ContainerGrinder;
import appeng.container.implementations.ContainerIOPort;
@@ -86,6 +89,8 @@ import appeng.container.implementations.ContainerUpgradeable;
import appeng.container.implementations.ContainerVibrationChamber;
import appeng.container.implementations.ContainerWireless;
import appeng.container.implementations.ContainerWirelessTerm;
import appeng.fluids.parts.PartFluidStorageBus;
import appeng.fluids.parts.PartSharedFluidBus;
import appeng.helpers.IInterfaceHost;
import appeng.helpers.IPriorityHost;
import appeng.helpers.WirelessTerminalGuiObject;
@@ -94,6 +99,7 @@ import appeng.parts.automation.PartFormationPlane;
import appeng.parts.automation.PartLevelEmitter;
import appeng.parts.misc.PartStorageBus;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.parts.reporting.PartFluidTerminal;
import appeng.parts.reporting.PartInterfaceTerminal;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.crafting.TileCraftingTile;
@@ -152,10 +158,14 @@ public enum GuiBridge implements IGuiHandler
GUI_BUS( ContainerUpgradeable.class, IUpgradeableHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_BUS_FLUID( ContainerFluidIO.class, PartSharedFluidBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_IOPORT( ContainerIOPort.class, TileIOPort.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_STORAGEBUS( ContainerStorageBus.class, PartStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_STORAGEBUS_FLUID( ContainerFluidStorageBus.class, PartFluidStorageBus.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_FORMATION_PLANE( ContainerFormationPlane.class, PartFormationPlane.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
GUI_PRIORITY( ContainerPriority.class, IPriorityHost.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
@@ -166,6 +176,8 @@ public enum GuiBridge implements IGuiHandler
GUI_PATTERN_TERMINAL( ContainerPatternTerm.class, PartPatternTerminal.class, GuiHostType.WORLD, SecurityPermissions.CRAFT ),
GUI_FLUID_TERMINAL( ContainerFluidTerminal.class, PartFluidTerminal.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
// extends (Container/Gui) + Bus
GUI_LEVEL_EMITTER( ContainerLevelEmitter.class, PartLevelEmitter.class, GuiHostType.WORLD, SecurityPermissions.BUILD ),
@@ -0,0 +1,207 @@
/*
* This file is part of Applied Energistics 2.
* 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
* 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.sync.packets;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.BufferOverflowException;
import java.util.LinkedList;
import java.util.List;
import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
import javax.annotation.Nullable;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiScreen;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraftforge.fml.common.network.internal.FMLProxyPacket;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.storage.data.IAEFluidStack;
import appeng.client.gui.implementations.GuiFluidTerminal;
import appeng.core.AELog;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEFluidStack;
/**
* @author BrockWS
* @version rv6 - 22/05/2018
* @since rv6 22/05/2018
*/
public class PacketMEFluidInventoryUpdate extends AppEngPacket
{
private static final int UNCOMPRESSED_PACKET_BYTE_LIMIT = 16 * 1024 * 1024;
private static final int OPERATION_BYTE_LIMIT = 2 * 1024;
private static final int TEMP_BUFFER_SIZE = 1024;
private static final int STREAM_MASK = 0xff;
// input.
@Nullable
private final List<IAEFluidStack> list;
// output...
private final byte ref;
@Nullable
private final ByteBuf data;
@Nullable
private final GZIPOutputStream compressFrame;
private int writtenBytes = 0;
private boolean empty = true;
// automatic.
public PacketMEFluidInventoryUpdate( final ByteBuf stream ) throws IOException
{
this.data = null;
this.compressFrame = null;
this.list = new LinkedList<>();
this.ref = stream.readByte();
// int originalBytes = stream.readableBytes();
final GZIPInputStream gzReader = new GZIPInputStream( new InputStream()
{
@Override
public int read() throws IOException
{
if( stream.readableBytes() <= 0 )
{
return -1;
}
return stream.readByte() & STREAM_MASK;
}
} );
final ByteBuf uncompressed = Unpooled.buffer( stream.readableBytes() );
final byte[] tmp = new byte[TEMP_BUFFER_SIZE];
while( gzReader.available() != 0 )
{
final int bytes = gzReader.read( tmp );
if( bytes > 0 )
{
uncompressed.writeBytes( tmp, 0, bytes );
}
}
gzReader.close();
// int uncompressedBytes = uncompressed.readableBytes();
// AELog.info( "Receiver: " + originalBytes + " -> " + uncompressedBytes );
while( uncompressed.readableBytes() > 0 )
{
this.list.add( AEFluidStack.fromPacket( uncompressed ) );
}
this.empty = this.list.isEmpty();
}
// api
public PacketMEFluidInventoryUpdate() throws IOException
{
this( (byte) 0 );
}
// api
public PacketMEFluidInventoryUpdate( final byte ref ) throws IOException
{
this.ref = ref;
this.data = Unpooled.buffer( OPERATION_BYTE_LIMIT );
this.data.writeInt( this.getPacketID() );
this.data.writeByte( this.ref );
this.compressFrame = new GZIPOutputStream( new OutputStream()
{
@Override
public void write( final int value ) throws IOException
{
PacketMEFluidInventoryUpdate.this.data.writeByte( value );
}
} );
this.list = null;
}
@Override
@SideOnly( Side.CLIENT )
public void clientPacketData( final INetworkInfo network, final AppEngPacket packet, final EntityPlayer player )
{
final GuiScreen gs = Minecraft.getMinecraft().currentScreen;
if( gs instanceof GuiFluidTerminal )
{
( (GuiFluidTerminal) gs ).postUpdate( this.list );
}
}
@Nullable
@Override
public FMLProxyPacket getProxy()
{
try
{
this.compressFrame.close();
this.configureWrite( this.data );
return super.getProxy();
}
catch( final IOException e )
{
AELog.debug( e );
}
return null;
}
public void appendFluid( final IAEFluidStack fs ) throws IOException, BufferOverflowException
{
final ByteBuf tmp = Unpooled.buffer( OPERATION_BYTE_LIMIT );
fs.writeToPacket( tmp );
this.compressFrame.flush();
if( this.writtenBytes + tmp.readableBytes() > UNCOMPRESSED_PACKET_BYTE_LIMIT )
{
throw new BufferOverflowException();
}
else
{
this.writtenBytes += tmp.readableBytes();
this.compressFrame.write( tmp.array(), 0, tmp.readableBytes() );
this.empty = false;
}
}
public int getLength()
{
return this.data.readableBytes();
}
public boolean isEmpty()
{
return this.empty;
}
}
@@ -0,0 +1,94 @@
/*
* This file is part of Applied Energistics 2.
* 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
* 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.sync.packets;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import net.minecraft.entity.player.EntityPlayer;
import appeng.container.implementations.ContainerFluidTerminal;
import appeng.core.AELog;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
import appeng.util.item.AEFluidStack;
/**
* @author BrockWS
* @version rv6 - 23/05/2018
* @since rv6 23/05/2018
*/
public class PacketTargetFluidStack extends AppEngPacket
{
private AEFluidStack stack;
// automatic.
public PacketTargetFluidStack( final ByteBuf stream )
{
try
{
if( stream.readableBytes() > 0 )
{
this.stack = (AEFluidStack) AEFluidStack.fromPacket( stream );
}
else
{
this.stack = null;
}
}
catch( Exception ex )
{
AELog.debug( ex );
this.stack = null;
}
}
// api
public PacketTargetFluidStack( AEFluidStack stack )
{
this.stack = stack;
final ByteBuf data = Unpooled.buffer();
data.writeInt( this.getPacketID() );
if( stack != null )
{
try
{
stack.writeToPacket( data );
}
catch( Exception ex )
{
AELog.debug( ex );
}
}
this.configureWrite( data );
}
@Override
public void serverPacketData( final INetworkInfo manager, final AppEngPacket packet, final EntityPlayer player )
{
if( player.openContainer instanceof ContainerFluidTerminal )
{
( (ContainerFluidTerminal) player.openContainer ).setTargetStack( this.stack );
}
}
}
@@ -44,6 +44,7 @@ import appeng.container.implementations.ContainerCellWorkbench;
import appeng.container.implementations.ContainerCraftConfirm;
import appeng.container.implementations.ContainerCraftingCPU;
import appeng.container.implementations.ContainerCraftingStatus;
import appeng.container.implementations.ContainerFluidStorageBus;
import appeng.container.implementations.ContainerLevelEmitter;
import appeng.container.implementations.ContainerNetworkTool;
import appeng.container.implementations.ContainerPatternTerm;
@@ -179,18 +180,31 @@ public class PacketValueConfig extends AppEngPacket
cpt.getPatternTerminal().setSubstitution( this.Value.equals( "1" ) );
}
}
else if( this.Name.startsWith( "StorageBus." ) && c instanceof ContainerStorageBus )
else if( this.Name.startsWith( "StorageBus." ) )
{
final ContainerStorageBus ccw = (ContainerStorageBus) c;
if( this.Name.equals( "StorageBus.Action" ) )
{
if( this.Value.equals( "Partition" ) )
{
ccw.partition();
if( c instanceof ContainerStorageBus )
{
( (ContainerStorageBus) c ).partition();
}
else if( c instanceof ContainerFluidStorageBus )
{
( (ContainerFluidStorageBus) c ).partition();
}
}
else if( this.Value.equals( "Clear" ) )
{
ccw.clear();
if( c instanceof ContainerStorageBus )
{
( (ContainerStorageBus) c ).clear();
}
else if( c instanceof ContainerFluidStorageBus )
{
( (ContainerFluidStorageBus) c ).clear();
}
}
}
}