Refactored StorageChannel enum into an interface (#3138)

This replaces the static enum with a more dynamic interface providing
factory methods for handling network storage.
This commit is contained in:
yueh
2017-10-08 17:59:30 +02:00
committed by GitHub
parent 8ad8ce68b5
commit 6e81f698c0
115 changed files with 1255 additions and 943 deletions
@@ -53,7 +53,7 @@ public class PacketAssemblerAnimation extends AppEngPacket
this.y = stream.readInt();
this.z = stream.readInt();
this.rate = stream.readByte();
this.is = AEItemStack.loadItemStackFromPacket( stream );
this.is = AEItemStack.fromPacket( stream );
}
// api
@@ -59,7 +59,7 @@ public class PacketInventoryAction extends AppEngPacket
final boolean hasItem = stream.readBoolean();
if( hasItem )
{
this.slotItem = AEItemStack.loadItemStackFromPacket( stream );
this.slotItem = AEItemStack.fromPacket( stream );
}
else
{
@@ -36,6 +36,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.config.SecurityPermissions;
import appeng.api.networking.IGrid;
@@ -44,6 +45,7 @@ import appeng.api.networking.energy.IEnergyGrid;
import appeng.api.networking.security.ISecurityGrid;
import appeng.api.networking.storage.IStorageGrid;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.core.sync.AppEngPacket;
import appeng.core.sync.network.INetworkInfo;
@@ -135,7 +137,7 @@ public class PacketJEIRecipe extends AppEngPacket
if( inv != null && this.recipe != null && security != null )
{
final IMEMonitor<IAEItemStack> storage = inv.getItemInventory();
final IMEMonitor<IAEItemStack> storage = inv.getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) );
final IPartitionList<IAEItemStack> filter = ItemViewCell.createFilter( cct.getViewCells() );
for( int x = 0; x < craftMatrix.getSlots(); x++ )
@@ -151,7 +153,7 @@ public class PacketJEIRecipe extends AppEngPacket
// put away old item
if( newItem != currentItem && security.hasPermission( player, SecurityPermissions.INJECT ) )
{
final IAEItemStack in = AEItemStack.create( currentItem );
final IAEItemStack in = AEItemStack.fromItemStack( currentItem );
final IAEItemStack out = cct.useRealItems() ? Platform.poweredInsert( energy, storage, in, cct.getActionSource() ) : null;
if( out != null )
{
@@ -169,7 +171,7 @@ public class PacketJEIRecipe extends AppEngPacket
// for each variant
for( int y = 0; y < this.recipe[x].length && currentItem.isEmpty(); y++ )
{
final IAEItemStack request = AEItemStack.create( this.recipe[x][y] );
final IAEItemStack request = AEItemStack.fromItemStack( this.recipe[x][y] );
if( request != null )
{
// try ae
@@ -113,7 +113,7 @@ public class PacketMEInventoryUpdate extends AppEngPacket
while( uncompressed.readableBytes() > 0 )
{
this.list.add( AEItemStack.loadItemStackFromPacket( uncompressed ) );
this.list.add( AEItemStack.fromPacket( uncompressed ) );
}
this.empty = this.list.isEmpty();
@@ -29,6 +29,7 @@ import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.container.implementations.ContainerPatternTerm;
import appeng.core.sync.AppEngPacket;
@@ -65,7 +66,7 @@ public class PacketPatternSlot extends AppEngPacket
if( hasItem )
{
return AEItemStack.loadItemStackFromPacket( stream );
return AEItemStack.fromPacket( stream );
}
return null;
@@ -87,7 +88,7 @@ public class PacketPatternSlot extends AppEngPacket
this.writeItem( slotItem, data );
for( int x = 0; x < 9; x++ )
{
this.pattern[x] = AEApi.instance().storage().createItemStack( pat.getStackInSlot( x ) );
this.pattern[x] = AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ).createStack( pat.getStackInSlot( x ) );
this.writeItem( this.pattern[x], data );
}