Compare commits

...

11 Commits

Author SHA1 Message Date
yueh 483049f555 Fixes #3293: Only update light level if the panel-facing block changes. (#3302) 2017-12-31 13:11:26 +01:00
yueh a7a65ae39d Fixes #3296: Prevent invalid TileEntites from updating their block. (#3301)
Updating the blockstate of invalid TEs will cause Forge to restore the
block including the TE leading to invalid TEs sticking around after
being moved.
2017-12-31 13:06:18 +01:00
yueh 45878df17d Fixes #3286: Incorrectly inverted hasSkyLight causes crashes on spatial transfer. (#3299) 2017-12-31 13:06:08 +01:00
yueh 98142d8ade Fixes CraftTweaker deploying incomplete releases. (#3300)
Due to CraftTweaker not deploying necessary dependencies, we cannot
rely on building against the most recent compatible version. Instead we
have to build against a specific known release to avoid it but have to
risk incompatibilities should there be changes on later versions.
2017-12-30 11:12:04 +01:00
yueh 7956872d1d Reworked IO Port to handle StorageChannels better. (#3284)
* Reworked IO Port to handle custom StorageChannels in a better way.
* Added a transferFactor to `IStorageChannel` to allow addons to speedup the IO Port to transfer faster. E.g. 1000 mB fluid as fast as transfering 1 bucket (item) per operation, not just 1 mB. 
* Also some changes to avoid moving fluids being 1000x as energy expensive as items.
2017-12-21 19:12:45 +01:00
yueh e243c8e9a2 Adds a debug generator for ForgeEnergy. (#3259)
* Adds a debug generator for ForgeEnergy.

This adds a simple debug block to test external energy injection via
ForgeEnergy and not rely solely on creative cells.

The energy has two functions. The first is acting as an infinite
ForgEnergy battery, this is unused by AE2 itself as nothing pulls
energy.
The second one is injecting energy every tick into any adjacent block
accepting ForgeEnergy.
The base generation is 8 per tick, but this is increased by the power of
adjacent TileEnergyGenerators.
2017-12-21 17:29:39 +01:00
yueh 641d0d40cc Fixes #3265: Do not strip special chars when extracting recipes. (#3266) 2017-12-21 17:28:31 +01:00
yueh 50fad685b6 Fixes #3282: Stacksizes > 64 prevent applicator from cycling. (#3287) 2017-12-21 17:28:16 +01:00
yueh 1ad49edd76 Fixes #3260: Only match damaged items when selected and set to 99%. (#3261) 2017-12-01 21:14:29 +01:00
yueh 7ceaa4cc3e Fixes #3217: Allow caps to be used as P2P attunements. (#3257)
Adds a more abstract approach to map a cap to a certain type instead of
the hardcoded ForgeEnergy case.
Reorders the check from exact ItemStack > ModId > ForgeEnergy to
ItemStack > Cap > ModId. Thus the mod wildcard will be used last.
Support for ForgeEnergy and FluidHandlerItems by default.
Result for items supporting multiple capabilities is not defined.
2017-12-01 21:14:11 +01:00
yueh b70c86542b Fixes #3255: Cache invalid patterns instead computing them every frame. (#3256) 2017-12-01 21:13:23 +01:00
26 changed files with 366 additions and 127 deletions
+1
View File
@@ -24,6 +24,7 @@ tesla_version=1.0.61
ic2_version=2.8.19-ex112
top_version=1.12-1.4.18-10
cofhcore_version=1.12-4.+
crafttweaker_version=4.0.10.310
#########################################################
# Deployment #
+1 -1
View File
@@ -82,7 +82,7 @@ dependencies {
compileOnly "net.industrial-craft:industrialcraft-2:${ic2_version}:api"
compileOnly "mcjty.theoneprobe:TheOneProbe-1.12:${top_version}:api"
compileOnly "cofh:CoFHCore:${cofhcore_version}:deobf"
compileOnly "CraftTweaker2:CraftTweaker2-API:4.+"
compileOnly "CraftTweaker2:CraftTweaker2-API:${crafttweaker_version}"
// at runtime, use the full JEI jar
runtime "mezz.jei:jei_${minecraft_version}:${jei_version}"
@@ -28,6 +28,7 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.capabilities.Capability;
import appeng.api.config.TunnelType;
@@ -47,6 +48,7 @@ public interface IP2PTunnelRegistry
*/
void addNewAttunement( @Nonnull ItemStack trigger, @Nullable TunnelType type );
void addNewAttunement( @Nonnull String ModId, @Nullable TunnelType type );
void addNewAttunement( @Nonnull Capability<?> cap, @Nullable TunnelType type );
/**
* returns null if no attunement can be found.
@@ -43,6 +43,19 @@ import appeng.api.storage.data.IItemList;
public interface IStorageChannel<T extends IAEStack<T>>
{
/**
* Can be used as factor for transferring stacks of a channel.
*
* E.g. used by IO Ports to transfer 1000 mB, not 1 mB to match the
* item channel transferring a full bucket per operation.
*
* @return
*/
default int transferFactor()
{
return 1;
}
/**
* Create a new {@link IItemList} of the specific type.
*
@@ -160,6 +160,12 @@ public class ApiStorage implements IStorageHelper
private static final class FluidStorageChannel implements IFluidStorageChannel
{
@Override
public int transferFactor()
{
return 1000;
}
@Override
public IItemList<IAEFluidStack> createList()
{
@@ -195,7 +201,7 @@ public class ApiStorage implements IStorageHelper
Preconditions.checkNotNull( request );
Preconditions.checkNotNull( src );
return null;
return Platform.poweredExtraction( energy, cell, request, src );
}
@Override
@@ -206,7 +212,7 @@ public class ApiStorage implements IStorageHelper
Preconditions.checkNotNull( input );
Preconditions.checkNotNull( src );
return input;
return Platform.poweredInsert( energy, cell, input, src );
}
}
@@ -106,10 +106,12 @@ import appeng.core.features.BlockDefinition;
import appeng.core.features.registries.PartModels;
import appeng.debug.BlockChunkloader;
import appeng.debug.BlockCubeGenerator;
import appeng.debug.BlockEnergyGenerator;
import appeng.debug.BlockItemGen;
import appeng.debug.BlockPhantomNode;
import appeng.debug.TileChunkLoader;
import appeng.debug.TileCubeGenerator;
import appeng.debug.TileEnergyGenerator;
import appeng.debug.TileItemGen;
import appeng.debug.TilePhantomNode;
import appeng.decorative.slab.BlockSlabCommon;
@@ -236,6 +238,7 @@ public final class ApiBlocks implements IBlocks
private final IBlockDefinition chunkLoader;
private final IBlockDefinition phantomNode;
private final IBlockDefinition cubeGenerator;
private final IBlockDefinition energyGenerator;
public ApiBlocks( FeatureFactory registry, PartModels partModels )
{
@@ -526,6 +529,11 @@ public final class ApiBlocks implements IBlocks
.tileEntity( new TileEntityDefinition( TileCubeGenerator.class ) )
.useCustomItemModel()
.build();
this.energyGenerator = registry.block( "debug_energy_gen", BlockEnergyGenerator::new )
.features( AEFeature.UNSUPPORTED_DEVELOPER_TOOLS, AEFeature.CREATIVE )
.tileEntity( new TileEntityDefinition( TileEnergyGenerator.class ) )
.useCustomItemModel()
.build();
}
private static IBlockDefinition makeSlab( String slabId, String doubleSlabId, FeatureFactory registry, IBlockDefinition blockDef )
@@ -1014,4 +1022,9 @@ public final class ApiBlocks implements IBlocks
{
return this.cubeGenerator;
}
public IBlockDefinition energyGenerator()
{
return energyGenerator;
}
}
@@ -21,6 +21,7 @@ package appeng.core.features.registries;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
@@ -30,6 +31,8 @@ import net.minecraft.init.Items;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
@@ -49,6 +52,7 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
private final Map<ItemStack, TunnelType> tunnels = new HashMap<>( INITIAL_CAPACITY );
private final Map<String, TunnelType> modIdTunnels = new HashMap<>( INITIAL_CAPACITY );
private final Map<Capability<?>, TunnelType> capTunnels = new HashMap<>( INITIAL_CAPACITY );
public void configure()
{
@@ -159,6 +163,12 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
this.addNewAttunement( parts.cableDenseSmart().stack( c, 1 ), TunnelType.ME );
}
/**
* attune based caps
*/
this.addNewAttunement( Capabilities.FORGE_ENERGY, TunnelType.FE_POWER );
this.addNewAttunement( CapabilityFluidHandler.FLUID_HANDLER_ITEM_CAPABILITY, TunnelType.FLUID );
/**
* attune based on the ItemStack's modId
*/
@@ -186,6 +196,16 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
this.modIdTunnels.put( modId, type );
}
@Override
public void addNewAttunement( @Nonnull final Capability<?> cap, @Nullable final TunnelType type )
{
if( type == null || cap == null )
{
return;
}
this.capTunnels.put( cap, type );
}
@Override
public void addNewAttunement( @Nonnull final ItemStack trigger, @Nullable final TunnelType type )
{
@@ -203,39 +223,40 @@ public final class P2PTunnelRegistry implements IP2PTunnelRegistry
{
if( !trigger.isEmpty() )
{
// if( FluidRegistry.isContainer( trigger ) )
// {
// return TunnelType.FLUID;
// }
for( final ItemStack is : this.tunnels.keySet() )
// First match exact items
for( final Entry<ItemStack, TunnelType> entry : this.tunnels.entrySet() )
{
final ItemStack is = entry.getKey();
if( is.getItem() == trigger.getItem() && is.getItemDamage() == OreDictionary.WILDCARD_VALUE )
{
return this.tunnels.get( is );
return entry.getValue();
}
if( ItemStack.areItemsEqual( is, trigger ) )
{
return this.tunnels.get( is );
return entry.getValue();
}
}
// Try by ModId next
for( final String modId : this.modIdTunnels.keySet() )
{
if( trigger.getItem().getRegistryName() != null && trigger.getItem().getRegistryName().getResourceDomain().equals( modId ) )
{
return this.modIdTunnels.get( modId );
}
}
// Next, check if the Item you're holding supports Forge Energy
// Next, check if the Item you're holding supports any registered capability
for( EnumFacing face : EnumFacing.VALUES )
{
if( trigger.hasCapability( Capabilities.FORGE_ENERGY, face ) )
for( Entry<Capability<?>, TunnelType> entry : this.capTunnels.entrySet() )
{
return TunnelType.FE_POWER;
if( trigger.hasCapability( entry.getKey(), face ) )
{
return entry.getValue();
}
}
}
// Use the mod id as last option.
for( final Entry<String, TunnelType> entry : this.modIdTunnels.entrySet() )
{
if( trigger.getItem().getRegistryName() != null && trigger.getItem().getRegistryName().getResourceDomain().equals( entry.getKey() ) )
{
return entry.getValue();
}
}
}
@@ -0,0 +1,35 @@
/*
* 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.debug;
import net.minecraft.block.material.Material;
import appeng.block.AEBaseTileBlock;
public class BlockEnergyGenerator extends AEBaseTileBlock
{
public BlockEnergyGenerator()
{
super( Material.IRON );
}
}
@@ -0,0 +1,139 @@
/*
* 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.debug;
import java.util.EnumSet;
import javax.annotation.Nullable;
import com.google.common.math.IntMath;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage;
import appeng.tile.AEBaseTile;
public class TileEnergyGenerator extends AEBaseTile implements ITickable, IEnergyStorage
{
/**
* The base energy injected each tick.
* Adjacent TileEnergyGenerators will increase it to pow(base, #generators).
*/
private static final int BASE_ENERGY = 8;
@Override
public void update()
{
int tier = 1;
final EnumSet<EnumFacing> validEnergyReceivers = EnumSet.noneOf( EnumFacing.class );
for( EnumFacing facing : EnumFacing.values() )
{
final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) );
if( te instanceof TileEnergyGenerator )
{
tier++;
}
if( te != null && te.hasCapability( CapabilityEnergy.ENERGY, facing.getOpposite() ) )
{
validEnergyReceivers.add( facing );
}
}
final int energyToInsert = IntMath.pow( BASE_ENERGY, tier );
for( EnumFacing facing : validEnergyReceivers )
{
final TileEntity te = this.getWorld().getTileEntity( this.getPos().offset( facing ) );
final IEnergyStorage cap = te.getCapability( CapabilityEnergy.ENERGY, facing.getOpposite() );
if( cap.canReceive() )
{
cap.receiveEnergy( energyToInsert, false );
}
}
}
@Override
public boolean hasCapability( Capability<?> capability, @Nullable EnumFacing facing )
{
if( capability == CapabilityEnergy.ENERGY )
{
return true;
}
return super.hasCapability( capability, facing );
}
@Override
@Nullable
public <T> T getCapability( Capability<T> capability, @Nullable EnumFacing facing )
{
if( capability == CapabilityEnergy.ENERGY )
{
return (T) this;
}
return super.getCapability( capability, facing );
}
@Override
public int receiveEnergy( int maxReceive, boolean simulate )
{
return 0;
}
@Override
public int extractEnergy( int maxExtract, boolean simulate )
{
return maxExtract;
}
@Override
public int getEnergyStored()
{
return Integer.MAX_VALUE;
}
@Override
public int getMaxEnergyStored()
{
return Integer.MAX_VALUE;
}
@Override
public boolean canExtract()
{
return true;
}
@Override
public boolean canReceive()
{
return false;
}
}
@@ -211,6 +211,7 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
public ItemStack getOutput( final ItemStack item )
{
ItemStack out = SIMPLE_CACHE.get( item );
if( out != null )
{
return out;
@@ -224,12 +225,9 @@ public class ItemEncodedPattern extends AEBaseItem implements ICraftingPatternIt
final ICraftingPatternDetails details = this.getPatternForItem( item, w );
if( details == null )
{
return ItemStack.EMPTY;
}
out = details != null ? details.getOutputs()[0].createItemStack() : ItemStack.EMPTY;
SIMPLE_CACHE.put( item, out = details.getCondensedOutputs()[0].createItemStack() );
SIMPLE_CACHE.put( item, out );
return out;
}
}
@@ -277,7 +277,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
final IAEItemStack firstItem = itemList.getFirstItem();
if( firstItem != null )
{
newColor = firstItem.createItemStack();
newColor = firstItem.asItemStackRepresentation();
}
}
else
@@ -324,7 +324,7 @@ public class ToolColorApplicator extends AEBasePoweredItem implements IStorageCe
list.addFirst( list.removeLast() );
}
return list.get( 0 ).createItemStack();
return list.get( 0 ).asItemStackRepresentation();
}
}
+9 -5
View File
@@ -336,10 +336,7 @@ public class EnergyGridCache implements IEnergyGrid
@Override
public double injectProviderPower( double amt, final Actionable mode )
{
if( mode == Actionable.MODULATE )
{
this.tickInjectionPerTick += amt;
}
final double originalAmount = amt;
final Iterator<IAEPowerStorage> it = this.requesters.iterator();
@@ -354,7 +351,14 @@ public class EnergyGridCache implements IEnergyGrid
}
}
return Math.max( 0.0, amt );
final double overflow = Math.max( 0.0, amt );
if( mode == Actionable.MODULATE )
{
this.tickInjectionPerTick += originalAmount - overflow;
}
return overflow;
}
@Override
@@ -117,8 +117,11 @@ public abstract class AbstractPartReporting extends AEBasePart implements IPartM
@Override
public void onNeighborChanged( IBlockAccess w, BlockPos pos, BlockPos neighbor )
{
this.opacity = -1;
this.getHost().markForUpdate();
if( pos.offset( this.getSide().getFacing() ).equals( neighbor ) )
{
this.opacity = -1;
this.getHost().markForUpdate();
}
}
@Override
@@ -25,7 +25,6 @@ import java.io.InputStream;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
@@ -58,7 +57,6 @@ public class RecipeResourceCopier
private static final String FILE_PROTOCOL = "file";
private static final String CLASS_EXTENSION = ".class";
private static final String JAR_PROTOCOL = "jar";
private static final String UTF_8_ENCODING = "UTF-8";
/**
* copy source in the jar
@@ -225,9 +223,9 @@ public class RecipeResourceCopier
{
/* A JAR path */
final String dirPath = dirURL.getPath();
final String jarPath = dirPath.substring( 5, dirPath.indexOf( '!' ) ); // strip out only
final String jarPath = dirPath.substring( 0, dirPath.indexOf( '!' ) ); // strip out only
// the JAR file
final JarFile jar = new JarFile( URLDecoder.decode( jarPath, UTF_8_ENCODING ) );
final JarFile jar = new JarFile( new File( new URI( jarPath ) ) );
try
{
final Enumeration<JarEntry> entries = jar.entries(); // gives ALL entries in jar
@@ -418,7 +418,7 @@ public class CachedPlane
ExtendedBlockStorage extendedblockstorage = storage[by];
if( extendedblockstorage == null )
{
extendedblockstorage = storage[by] = new ExtendedBlockStorage( by << 4, !this.c.getWorld().provider.hasSkyLight() );
extendedblockstorage = storage[by] = new ExtendedBlockStorage( by << 4, this.c.getWorld().provider.hasSkyLight() );
}
}
}
@@ -74,7 +74,7 @@ public class TileCraftingStorageTile extends TileCraftingTile
@Override
public int getStorageBytes()
{
if( this.world == null || this.notLoaded() )
if( this.world == null || this.notLoaded() || this.isInvalid() )
{
return 0;
}
@@ -143,7 +143,7 @@ public class TileCraftingTile extends AENetworkTile implements IAEMultiBlock, IP
public void updateMeta( final boolean updateFormed )
{
if( this.world == null || this.notLoaded() )
if( this.world == null || this.notLoaded() || this.isInvalid() )
{
return;
}
@@ -84,7 +84,7 @@ public class TileEnergyCell extends AENetworkTile implements IAEPowerStorage
private void changePowerLevel()
{
if( this.notLoaded() )
if( this.notLoaded() || this.isInvalid() )
{
return;
}
@@ -19,7 +19,9 @@
package appeng.tile.storage;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import net.minecraft.block.Block;
import net.minecraft.item.ItemStack;
@@ -48,10 +50,6 @@ import appeng.api.networking.ticking.TickingRequest;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IFluidStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEFluidStack;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
import appeng.api.util.AECableType;
@@ -68,7 +66,6 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.ConfigManager;
import appeng.util.IConfigManagerHost;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.InvOperation;
@@ -79,10 +76,13 @@ import appeng.util.inv.filter.AEItemFilters;
public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IConfigManagerHost, IGridTickable
{
private static final int NUMBER_OF_CELL_SLOTS = 6;
private static final int NUMBER_OF_UPGRADE_SLOTS = 3;
private final ConfigManager manager;
private final AppEngInternalInventory inputCells = new AppEngInternalInventory( this, 6 );
private final AppEngInternalInventory outputCells = new AppEngInternalInventory( this, 6 );
private final AppEngInternalInventory inputCells = new AppEngInternalInventory( this, NUMBER_OF_CELL_SLOTS );
private final AppEngInternalInventory outputCells = new AppEngInternalInventory( this, NUMBER_OF_CELL_SLOTS );
private final IItemHandler combinedInventory = new WrapperChainedItemHandler( this.inputCells, this.outputCells );
private final IItemHandler inputCellsExt = new WrapperFilteredItemHandler( this.inputCells, AEItemFilters.INSERT_ONLY );
@@ -92,8 +92,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
private final IActionSource mySrc;
private YesNo lastRedstoneState;
private ItemStack currentCell;
private IMEInventory<IAEFluidStack> cachedFluid;
private IMEInventory<IAEItemStack> cachedItem;
private Map<IStorageChannel<?>, IMEInventory<?>> cachedInventories;
public TileIOPort()
{
@@ -106,7 +105,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
this.lastRedstoneState = YesNo.UNDECIDED;
final Block ioPortBlock = AEApi.instance().definitions().blocks().iOPort().maybeBlock().get();
this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, 3 );
this.upgrades = new BlockUpgradeInventory( ioPortBlock, this, NUMBER_OF_UPGRADE_SLOTS );
}
@Override
@@ -277,87 +276,84 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
return TickRateModulation.IDLE;
}
long ItemsToMove = 256;
TickRateModulation ret = TickRateModulation.SLEEP;
long itemsToMove = 256;
switch( this.getInstalledUpgrades( Upgrades.SPEED ) )
{
case 1:
ItemsToMove *= 2;
itemsToMove *= 2;
break;
case 2:
ItemsToMove *= 4;
itemsToMove *= 4;
break;
case 3:
ItemsToMove *= 8;
itemsToMove *= 8;
break;
}
try
{
final IMEInventory<IAEItemStack> itemNet = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventory<IAEFluidStack> fluidNet = this.getProxy().getStorage().getInventory(
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
final IEnergySource energy = this.getProxy().getEnergy();
for( int x = 0; x < 6; x++ )
for( int x = 0; x < NUMBER_OF_CELL_SLOTS; x++ )
{
final ItemStack is = this.inputCells.getStackInSlot( x );
if( !is.isEmpty() )
{
if( ItemsToMove > 0 )
boolean shouldMove = true;
for( IStorageChannel<? extends IAEStack<?>> c : AEApi.instance().storage().storageChannels() )
{
final IMEInventory<IAEItemStack> itemInv = this.getInv( is, AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IMEInventory<IAEFluidStack> fluidInv = this.getInv( is,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
if( itemsToMove > 0 )
{
if( itemInv != null )
final IMEMonitor<? extends IAEStack<?>> network = this.getProxy().getStorage().getInventory( c );
final IMEInventory<?> inv = this.getInv( is, c );
if( inv == null )
{
ItemsToMove = this.transferContents( energy, itemInv, itemNet, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
continue;
}
if( fluidInv != null )
if( this.manager.getSetting( Settings.OPERATION_MODE ) == OperationMode.EMPTY )
{
ItemsToMove = this.transferContents( energy, fluidInv, fluidNet, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
}
}
else
{
if( itemInv != null )
{
ItemsToMove = this.transferContents( energy, itemNet, itemInv, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
}
if( fluidInv != null )
{
ItemsToMove = this.transferContents( energy, fluidNet, fluidInv, ItemsToMove,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
itemsToMove = this.transferContents( energy, inv, network, itemsToMove, c );
}
else
{
itemsToMove = this.transferContents( energy, network, inv, itemsToMove, c );
}
shouldMove &= this.shouldMove( inv );
if( itemsToMove > 0 )
{
ret = TickRateModulation.IDLE;
}
else
{
ret = TickRateModulation.URGENT;
}
}
}
if( ItemsToMove > 0 && this.shouldMove( itemInv, fluidInv ) && !this.moveSlot( x ) )
{
return TickRateModulation.IDLE;
}
return TickRateModulation.URGENT;
if( itemsToMove > 0 && shouldMove && this.moveSlot( x ) )
{
ret = TickRateModulation.URGENT;
}
else
{
return TickRateModulation.URGENT;
ret = TickRateModulation.URGENT;
}
}
}
}
catch( final GridAccessException e )
{
return TickRateModulation.IDLE;
ret = TickRateModulation.IDLE;
}
// nothing left to do...
return TickRateModulation.SLEEP;
return ret;
}
@Override
@@ -366,23 +362,20 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
return this.upgrades.getInstalledUpgrades( u );
}
private IMEInventory getInv( final ItemStack is, final IStorageChannel chan )
private IMEInventory<?> getInv( final ItemStack is, final IStorageChannel<?> chan )
{
if( this.currentCell != is )
{
this.currentCell = is;
this.cachedFluid = AEApi.instance().registries().cell().getCellInventory( is, null,
AEApi.instance().storage().getStorageChannel( IFluidStorageChannel.class ) );
this.cachedItem = AEApi.instance().registries().cell().getCellInventory( is, null,
AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
this.cachedInventories = new IdentityHashMap<>();
for( IStorageChannel<? extends IAEStack<?>> c : AEApi.instance().storage().storageChannels() )
{
this.cachedInventories.put( c, AEApi.instance().registries().cell().getCellInventory( is, null, c ) );
}
}
if( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) == chan )
{
return this.cachedItem;
}
return this.cachedFluid;
return this.cachedInventories.get( chan );
}
private long transferContents( final IEnergySource energy, final IMEInventory src, final IMEInventory destination, long itemsToMove, final IStorageChannel chan )
@@ -397,6 +390,8 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
myList = src.getAvailableItems( src.getChannel().createList() );
}
itemsToMove *= chan.transferFactor();
boolean didStuff;
do
@@ -429,7 +424,7 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
if( extracted != null )
{
possible = extracted.getStackSize();
final IAEStack failed = Platform.poweredInsert( energy, destination, extracted, this.mySrc );
final IAEStack failed = chan.poweredInsert( energy, destination, extracted, this.mySrc );
if( failed != null )
{
@@ -451,24 +446,16 @@ public class TileIOPort extends AENetworkInvTile implements IUpgradeableHost, IC
}
while( itemsToMove > 0 && didStuff );
return itemsToMove;
return itemsToMove / chan.transferFactor();
}
private boolean shouldMove( final IMEInventory<IAEItemStack> itemInv, final IMEInventory<IAEFluidStack> fluidInv )
private boolean shouldMove( final IMEInventory<?> inv )
{
final FullnessMode fm = (FullnessMode) this.manager.getSetting( Settings.FULLNESS_MODE );
if( itemInv != null && fluidInv != null )
if( inv != null )
{
return this.matches( fm, itemInv ) && this.matches( fm, fluidInv );
}
else if( itemInv != null )
{
return this.matches( fm, itemInv );
}
else if( fluidInv != null )
{
return this.matches( fm, fluidInv );
return this.matches( fm, inv );
}
return true;
+3 -3
View File
@@ -1174,13 +1174,13 @@ public class Platform
stored -= possible.getStackSize();
}
final double availablePower = energy.extractAEPower( stored, Actionable.SIMULATE, PowerMultiplier.CONFIG );
final int energyFactor = Math.min( 1, input.getChannel().transferFactor() );
final double availablePower = energy.extractAEPower( stored / energyFactor, Actionable.SIMULATE, PowerMultiplier.CONFIG );
final long itemToAdd = Math.min( (long) ( availablePower + 0.9 ), stored );
if( itemToAdd > 0 )
{
energy.extractAEPower( stored, Actionable.MODULATE, PowerMultiplier.CONFIG );
energy.extractAEPower( stored / energyFactor, Actionable.MODULATE, PowerMultiplier.CONFIG );
if( itemToAdd < input.getStackSize() )
{
@@ -164,7 +164,7 @@ final class AESharedItemStack implements Comparable<AESharedItemStack>
}
else
{
newDef.setItemDamage( 0 );
newDef.setItemDamage( 1 );
}
}
else
@@ -0,0 +1,7 @@
{
"variants": {
"normal": {
"model": "appliedenergistics2:debug/energy_gen"
}
}
}
@@ -0,0 +1,6 @@
{
"parent": "block/cube_all",
"textures": {
"all": "appliedenergistics2:blocks/debug/energy_gen"
}
}
@@ -0,0 +1,6 @@
{
"parent": "item/generated",
"textures": {
"layer0": "appliedenergistics2:items/debug/energy_gen"
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B