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
@@ -35,13 +35,15 @@ import net.minecraft.util.math.Vec3d;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import appeng.api.AEApi;
import appeng.api.implementations.parts.IPartStorageMonitor;
import appeng.api.networking.security.IActionSource;
import appeng.api.networking.storage.IStackWatcher;
import appeng.api.networking.storage.IStackWatcherHost;
import appeng.api.parts.IPartModel;
import appeng.api.storage.IMEMonitor;
import appeng.api.storage.StorageChannel;
import appeng.api.storage.IStorageChannel;
import appeng.api.storage.channels.IItemStorageChannel;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.storage.data.IAEStack;
import appeng.api.storage.data.IItemList;
@@ -88,7 +90,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
this.isLocked = data.getBoolean( "isLocked" );
final NBTTagCompound myItem = data.getCompoundTag( "configuredItem" );
this.configuredItem = AEItemStack.loadItemStackFromNBT( myItem );
this.configuredItem = AEItemStack.fromNBT( myItem );
}
@Override
@@ -133,7 +135,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
final boolean val = data.readBoolean();
if( val )
{
this.configuredItem = AEItemStack.loadItemStackFromPacket( data );
this.configuredItem = AEItemStack.fromPacket( data );
}
else
{
@@ -172,7 +174,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
}
else if( !this.isLocked )
{
this.configuredItem = AEItemStack.create( eq );
this.configuredItem = AEItemStack.fromItemStack( eq );
this.configureWatchers();
this.getHost().markForUpdate();
}
@@ -201,7 +203,8 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
this.myWatcher.add( this.configuredItem );
}
this.updateReportingValue( this.getProxy().getStorage().getItemInventory() );
this.updateReportingValue(
this.getProxy().getStorage().getInventory( AEApi.instance().storage().getStorageChannel( IItemStorageChannel.class ) ) );
}
}
catch( final GridAccessException e )
@@ -287,7 +290,7 @@ public abstract class AbstractPartMonitor extends AbstractPartDisplay implements
}
@Override
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final StorageChannel chan )
public void onStackChange( final IItemList o, final IAEStack fullStack, final IAEStack diffStack, final IActionSource src, final IStorageChannel chan )
{
if( this.configuredItem != null )
{