Use IItemHandler instead of IInventory internally (#2971)
* Use IItemHandler instead of IInventory internally
This commit is contained in:
@@ -34,7 +34,6 @@ import net.minecraft.crash.CrashReportCategory;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -45,6 +44,7 @@ import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.relauncher.Side;
|
||||
import net.minecraftforge.fml.relauncher.SideOnly;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.Upgrades;
|
||||
@@ -344,7 +344,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -372,15 +372,15 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
pHost.setPriority( compound.getInteger( "priority" ) );
|
||||
}
|
||||
|
||||
final IInventory inv = this.getInventoryByName( "config" );
|
||||
final IItemHandler inv = this.getInventoryByName( "config" );
|
||||
if( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
final AppEngInternalAEInventory target = (AppEngInternalAEInventory) inv;
|
||||
final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSizeInventory() );
|
||||
final AppEngInternalAEInventory tmp = new AppEngInternalAEInventory( null, target.getSlots() );
|
||||
tmp.readFromNBT( compound, "config" );
|
||||
for( int x = 0; x < tmp.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < tmp.getSlots(); x++ )
|
||||
{
|
||||
target.setInventorySlotContents( x, tmp.getStackInSlot( x ) );
|
||||
target.setStackInSlot( x, tmp.getStackInSlot( x ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -408,7 +408,7 @@ public abstract class AEBasePart implements IPart, IGridProxyable, IActionHost,
|
||||
output.setInteger( "priority", pHost.getPriority() );
|
||||
}
|
||||
|
||||
final IInventory inv = this.getInventoryByName( "config" );
|
||||
final IItemHandler inv = this.getInventoryByName( "config" );
|
||||
if( inv instanceof AppEngInternalAEInventory )
|
||||
{
|
||||
( (AppEngInternalAEInventory) inv ).writeToNBT( output, "config" );
|
||||
|
||||
@@ -25,7 +25,7 @@ import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
|
||||
|
||||
public class BlockUpgradeInventory extends UpgradeInventory
|
||||
|
||||
@@ -23,7 +23,7 @@ import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.definitions.IItemDefinition;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
|
||||
|
||||
public final class DefinitionUpgradeInventory extends UpgradeInventory
|
||||
|
||||
@@ -26,7 +26,6 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemBlock;
|
||||
import net.minecraft.item.ItemFirework;
|
||||
@@ -43,6 +42,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraft.world.chunk.Chunk;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.config.AccessRestriction;
|
||||
@@ -78,8 +78,8 @@ import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.storage.MEInventoryHandler;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.prioritylist.FuzzyPriorityList;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
@@ -119,7 +119,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
for( int x = 0; x < this.Config.getSlots() && x < slotsToUse; x++ )
|
||||
{
|
||||
final IAEItemStack is = this.Config.getAEStackInSlot( x );
|
||||
if( is != null )
|
||||
@@ -161,7 +161,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
@@ -195,7 +195,7 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
@@ -456,7 +456,6 @@ public class PartFormationPlane extends PartUpgradeable implements ICellContaine
|
||||
EnumHand hand = player.getActiveHand();
|
||||
player.setHeldItem( hand, is );
|
||||
|
||||
|
||||
// TODO: LIMIT FIREWORKS
|
||||
/*
|
||||
* if( i instanceof ItemFirework )
|
||||
|
||||
@@ -23,7 +23,6 @@ import java.util.Collection;
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -34,6 +33,7 @@ import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.FuzzyMode;
|
||||
import appeng.api.config.LevelType;
|
||||
@@ -76,8 +76,8 @@ import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
|
||||
public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherHost, IStackWatcherHost, ICraftingWatcherHost, IMEMonitorHandlerReceiver<IAEItemStack>, ICraftingProvider
|
||||
@@ -479,7 +479,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
if( inv == this.config )
|
||||
{
|
||||
@@ -522,7 +522,7 @@ public class PartLevelEmitter extends PartUpgradeable implements IEnergyWatcherH
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
|
||||
@@ -19,11 +19,11 @@
|
||||
package appeng.parts.automation;
|
||||
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
@@ -69,7 +69,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
@@ -125,7 +125,7 @@ public abstract class PartSharedItemBus extends PartUpgradeable implements IGrid
|
||||
|
||||
protected int availableSlots()
|
||||
{
|
||||
return Math.min( 1 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 4, this.getConfig().getSizeInventory() );
|
||||
return Math.min( 1 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 4, this.getConfig().getSlots() );
|
||||
}
|
||||
|
||||
protected int calculateItemsToSend()
|
||||
|
||||
@@ -21,17 +21,17 @@ package appeng.parts.automation;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.RedstoneMode;
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.util.IConfigManager;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
|
||||
public abstract class PartUpgradeable extends PartBasicState implements IAEAppEngInventory, IConfigManagerHost
|
||||
@@ -59,7 +59,7 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
if( inv == this.upgrades )
|
||||
{
|
||||
@@ -155,7 +155,7 @@ public abstract class PartUpgradeable extends PartBasicState implements IAEAppEn
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "upgrades" ) )
|
||||
{
|
||||
|
||||
@@ -22,8 +22,8 @@ package appeng.parts.automation;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
|
||||
|
||||
public class StackUpgradeInventory extends UpgradeInventory
|
||||
|
||||
@@ -20,17 +20,18 @@ package appeng.parts.automation;
|
||||
|
||||
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Upgrades;
|
||||
import appeng.api.implementations.items.IUpgradeModule;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.inv.filter.IAEItemFilter;
|
||||
|
||||
|
||||
public abstract class UpgradeInventory extends AppEngInternalInventory implements IAEAppEngInventory
|
||||
@@ -47,9 +48,10 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
|
||||
public UpgradeInventory( final IAEAppEngInventory parent, final int s )
|
||||
{
|
||||
super( null, s );
|
||||
super( null, s, 1 );
|
||||
this.setTileEntity( this );
|
||||
this.parent = parent;
|
||||
this.setFilter( new UpgradeInvFilter() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -58,31 +60,6 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
|
||||
{
|
||||
if( itemstack.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final Item it = itemstack.getItem();
|
||||
if( it instanceof IUpgradeModule )
|
||||
{
|
||||
final Upgrades u = ( (IUpgradeModule) it ).getType( itemstack );
|
||||
if( u != null )
|
||||
{
|
||||
return this.getInstalledUpgrades( u ) < this.getMaxInstalled( u );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getInstalledUpgrades( final Upgrades u )
|
||||
{
|
||||
if( !this.cached )
|
||||
@@ -171,7 +148,7 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
this.cached = false;
|
||||
if( this.parent != null && Platform.isServer() )
|
||||
@@ -179,4 +156,33 @@ public abstract class UpgradeInventory extends AppEngInternalInventory implement
|
||||
this.parent.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
}
|
||||
|
||||
private class UpgradeInvFilter implements IAEItemFilter
|
||||
{
|
||||
|
||||
@Override
|
||||
public boolean allowExtract( IItemHandler inv, int slot, int amount )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean allowInsert( IItemHandler inv, int slot, ItemStack itemstack )
|
||||
{
|
||||
if( itemstack.isEmpty() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final Item it = itemstack.getItem();
|
||||
if( it instanceof IUpgradeModule )
|
||||
{
|
||||
final Upgrades u = ( (IUpgradeModule) it ).getType( itemstack );
|
||||
if( u != null )
|
||||
{
|
||||
return getInstalledUpgrades( u ) < getMaxInstalled( u );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,8 +25,6 @@ import java.util.List;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.inventory.InventoryCrafting;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
@@ -35,8 +33,8 @@ import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Actionable;
|
||||
import appeng.api.config.Upgrades;
|
||||
@@ -67,13 +65,13 @@ import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartBasicState;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.IInventoryDestination;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
|
||||
public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, ISidedInventory, IAEAppEngInventory, IPriorityHost
|
||||
public class PartInterface extends PartBasicState implements IGridTickable, IStorageMonitorable, IInventoryDestination, IInterfaceHost, IAEAppEngInventory, IPriorityHost
|
||||
{
|
||||
|
||||
public static final ResourceLocation MODEL_BASE = new ResourceLocation( AppEng.MOD_ID, "part/interface_base" );
|
||||
@@ -166,7 +164,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
return this.duality.getInventoryByName( name );
|
||||
}
|
||||
@@ -218,103 +216,7 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.duality.getStorage().getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( final int i )
|
||||
{
|
||||
return this.duality.getStorage().getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int i, final int j )
|
||||
{
|
||||
return this.duality.getStorage().decrStackSize( i, j );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot( final int i )
|
||||
{
|
||||
return this.duality.getStorage().removeStackFromSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents( final int i, final ItemStack itemstack )
|
||||
{
|
||||
this.duality.getStorage().setInventorySlotContents( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return this.duality.getStorage().getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return this.duality.getStorage().hasCustomName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return this.duality.getStorage().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
this.duality.getStorage().markDirty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer( final EntityPlayer entityplayer )
|
||||
{
|
||||
return this.duality.getStorage().isUsableByPlayer( entityplayer );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory( final EntityPlayer player )
|
||||
{
|
||||
this.duality.getStorage().openInventory( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory( final EntityPlayer player )
|
||||
{
|
||||
this.duality.getStorage().closeInventory( player );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
|
||||
{
|
||||
return this.duality.getStorage().isItemValidForSlot( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace( final EnumFacing side )
|
||||
{
|
||||
return this.duality.getSlotsForFace( side );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( final int i, final ItemStack itemstack, final EnumFacing j )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( final int i, final ItemStack itemstack, final EnumFacing j )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
this.duality.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
}
|
||||
@@ -385,36 +287,6 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
this.duality.setPriority( newValue );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField( final int id )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setField( final int id, final int value )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
@@ -443,12 +315,4 @@ public class PartInterface extends PartBasicState implements IGridTickable, ISto
|
||||
{
|
||||
return this.duality.getCapability( capabilityClass, this.getSide().getFacing() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
@@ -85,8 +84,8 @@ import appeng.me.storage.MEMonitorIInventory;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.parts.automation.PartUpgradeable;
|
||||
import appeng.tile.inventory.AppEngInternalAEInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.InvOperation;
|
||||
import appeng.util.prioritylist.FuzzyPriorityList;
|
||||
import appeng.util.prioritylist.PrecisePriorityList;
|
||||
|
||||
@@ -170,7 +169,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
super.onChangeInventory( inv, slot, mc, removedStack, newStack );
|
||||
|
||||
@@ -204,7 +203,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "config" ) )
|
||||
{
|
||||
@@ -449,7 +448,7 @@ public class PartStorageBus extends PartUpgradeable implements IGridTickable, IC
|
||||
final IItemList<IAEItemStack> priorityList = AEApi.instance().storage().createItemList();
|
||||
|
||||
final int slotsToUse = 18 + this.getInstalledUpgrades( Upgrades.CAPACITY ) * 9;
|
||||
for( int x = 0; x < this.Config.getSizeInventory() && x < slotsToUse; x++ )
|
||||
for( int x = 0; x < this.Config.getSlots() && x < slotsToUse; x++ )
|
||||
{
|
||||
final IAEItemStack is = this.Config.getAEStackInSlot( x );
|
||||
if( is != null )
|
||||
|
||||
@@ -1,21 +1,19 @@
|
||||
/*
|
||||
* This file is part of Applied Energistics 2.
|
||||
* Copyright (c) 2013 - 2017, AlgorithmX2, All rights reserved.
|
||||
*
|
||||
* * This file is part of Applied Energistics 2.
|
||||
* * Copyright (c) 2013 - 2017, 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>.
|
||||
* 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.parts.p2p;
|
||||
@@ -30,7 +28,6 @@ import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.energy.CapabilityEnergy;
|
||||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
|
||||
import appeng.api.config.PowerUnits;
|
||||
|
||||
@@ -19,22 +19,16 @@
|
||||
package appeng.parts.p2p;
|
||||
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.ISidedInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.tileentity.TileEntityChest;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.text.ITextComponent;
|
||||
import net.minecraftforge.common.capabilities.Capability;
|
||||
import net.minecraftforge.items.CapabilityItemHandler;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
import net.minecraftforge.items.wrapper.EmptyHandler;
|
||||
|
||||
import appeng.api.networking.IGridNode;
|
||||
import appeng.api.networking.events.MENetworkBootingStatusChange;
|
||||
@@ -49,19 +43,15 @@ import appeng.core.settings.TickRates;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.me.cache.helpers.TunnelCollection;
|
||||
import appeng.tile.inventory.AppEngNullInventory;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.AdaptorIInventory;
|
||||
import appeng.util.inv.WrapperChainedInventory;
|
||||
import appeng.util.inv.WrapperMCISidedInventory;
|
||||
import appeng.util.inv.WrapperChainedItemHandler;
|
||||
|
||||
|
||||
// TODO: BC Integration
|
||||
//@Interface( iface = "buildcraft.api.transport.IPipeConnection", iname = IntegrationType.BuildCraftTransport )
|
||||
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPipeConnection, */ISidedInventory, IGridTickable, IItemHandler
|
||||
public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements IItemHandler, IGridTickable
|
||||
{
|
||||
|
||||
private static final float POWER_DRAIN = 2.0f;
|
||||
private static final P2PModels MODELS = new P2PModels( "part/p2p/p2p_tunnel_items" );
|
||||
private boolean partVisited = false;
|
||||
|
||||
@PartModels
|
||||
public static List<IPartModel> getModels()
|
||||
@@ -69,10 +59,9 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
return MODELS.getModels();
|
||||
}
|
||||
|
||||
private final LinkedList<IInventory> which = new LinkedList<>();
|
||||
private int oldSize = 0;
|
||||
private boolean requested;
|
||||
private IInventory cachedInv;
|
||||
private IItemHandler cachedInv;
|
||||
|
||||
public PartP2PItems( final ItemStack is )
|
||||
{
|
||||
@@ -90,7 +79,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
}
|
||||
}
|
||||
|
||||
private IInventory getDestination()
|
||||
private IItemHandler getDestination()
|
||||
{
|
||||
this.requested = true;
|
||||
|
||||
@@ -99,7 +88,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
return this.cachedInv;
|
||||
}
|
||||
|
||||
final List<IInventory> outs = new LinkedList<>();
|
||||
final List<IItemHandler> outs = new ArrayList<IItemHandler>();
|
||||
final TunnelCollection<PartP2PItems> itemTunnels;
|
||||
|
||||
try
|
||||
@@ -108,13 +97,13 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
}
|
||||
catch( final GridAccessException e )
|
||||
{
|
||||
return new AppEngNullInventory();
|
||||
return EmptyHandler.INSTANCE;
|
||||
}
|
||||
|
||||
for( final PartP2PItems t : itemTunnels )
|
||||
{
|
||||
final IInventory inv = t.getOutputInv();
|
||||
if( inv != null )
|
||||
final IItemHandler inv = t.getOutputInv();
|
||||
if( inv != null && inv != this )
|
||||
{
|
||||
if( Platform.getRandomInt() % 2 == 0 )
|
||||
{
|
||||
@@ -127,44 +116,28 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
}
|
||||
}
|
||||
|
||||
return this.cachedInv = new WrapperChainedInventory( outs );
|
||||
return this.cachedInv = new WrapperChainedItemHandler( outs.toArray( new IItemHandler[outs.size()] ) );
|
||||
}
|
||||
|
||||
private IInventory getOutputInv()
|
||||
private IItemHandler getOutputInv()
|
||||
{
|
||||
IInventory output = null;
|
||||
|
||||
if( this.getProxy().isActive() )
|
||||
IItemHandler ret = null;
|
||||
if( !partVisited )
|
||||
{
|
||||
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( this.getSide().getFacing() ) );
|
||||
|
||||
if( this.which.contains( this ) )
|
||||
partVisited = true;
|
||||
if( this.getProxy().isActive() )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
final EnumFacing facing = this.getSide().getFacing();
|
||||
final TileEntity te = this.getTile().getWorld().getTileEntity( this.getTile().getPos().offset( facing ) );
|
||||
|
||||
this.which.add( this );
|
||||
|
||||
if( output == null )
|
||||
{
|
||||
if( te instanceof TileEntityChest )
|
||||
if( te != null && te.hasCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite() ) )
|
||||
{
|
||||
output = Platform.GetChestInv( te );
|
||||
}
|
||||
else if( te instanceof ISidedInventory )
|
||||
{
|
||||
output = new WrapperMCISidedInventory( (ISidedInventory) te, this.getSide().getFacing().getOpposite() );
|
||||
}
|
||||
else if( te instanceof IInventory )
|
||||
{
|
||||
output = (IInventory) te;
|
||||
ret = te.getCapability( CapabilityItemHandler.ITEM_HANDLER_CAPABILITY, facing.getOpposite() );
|
||||
}
|
||||
}
|
||||
|
||||
this.which.pop();
|
||||
partVisited = false;
|
||||
}
|
||||
|
||||
return output;
|
||||
return ret;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -180,7 +153,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
|
||||
if( this.requested && this.cachedInv != null )
|
||||
{
|
||||
( (WrapperChainedInventory) this.cachedInv ).cycleOrder();
|
||||
( (WrapperChainedItemHandler) this.cachedInv ).cycleOrder();
|
||||
}
|
||||
|
||||
this.requested = false;
|
||||
@@ -194,7 +167,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
this.oldSize = this.getDestination().getSlots();
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
@@ -209,7 +182,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
this.oldSize = this.getDestination().getSlots();
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
@@ -224,7 +197,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
this.oldSize = this.getDestination().getSlots();
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
@@ -239,7 +212,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
{
|
||||
this.cachedInv = null;
|
||||
final int olderSize = this.oldSize;
|
||||
this.oldSize = this.getDestination().getSizeInventory();
|
||||
this.oldSize = this.getDestination().getSlots();
|
||||
if( olderSize != this.oldSize )
|
||||
{
|
||||
this.getHost().notifyNeighbors();
|
||||
@@ -255,164 +228,6 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getSlotsForFace( final EnumFacing side )
|
||||
{
|
||||
final int[] slots = new int[this.getSizeInventory()];
|
||||
for( int x = 0; x < this.getSizeInventory(); x++ )
|
||||
{
|
||||
slots[x] = x;
|
||||
}
|
||||
return slots;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory()
|
||||
{
|
||||
return this.getDestination().getSizeInventory();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the number of slots available
|
||||
*
|
||||
* @return The number of slots available
|
||||
**/
|
||||
@Override
|
||||
public int getSlots()
|
||||
{
|
||||
return this.getSizeInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot( final int i )
|
||||
{
|
||||
return this.getDestination().getStackInSlot( i );
|
||||
}
|
||||
|
||||
/**
|
||||
* Inserts an ItemStack into the given slot and return the remainder.
|
||||
* The ItemStack should not be modified in this function!
|
||||
* Note: This behaviour is subtly different from IFluidHandlers.fill()
|
||||
*
|
||||
* @param slot Slot to insert into.
|
||||
* @param stack ItemStack to insert.
|
||||
* @param simulate If true, the insertion is only simulated
|
||||
* @return The remaining ItemStack that was not inserted (if the entire stack is accepted, then return
|
||||
* ItemStack.EMPTY).
|
||||
* May be the same as the input ItemStack if unchanged, otherwise a new ItemStack.
|
||||
**/
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack insertItem( int slot, @Nonnull ItemStack stack, boolean simulate )
|
||||
{
|
||||
|
||||
if( this.isItemValidForSlot( slot, stack ) )
|
||||
{
|
||||
AdaptorIInventory adaptor = new AdaptorIInventory( this.getDestination() );
|
||||
|
||||
if( simulate )
|
||||
{
|
||||
return adaptor.simulateAdd( stack );
|
||||
}
|
||||
else
|
||||
{
|
||||
return adaptor.addItems( stack );
|
||||
}
|
||||
}
|
||||
return stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts an ItemStack from the given slot. The returned value must be null
|
||||
* if nothing is extracted, otherwise it's stack size must not be greater than amount or the
|
||||
* itemstacks getMaxStackSize().
|
||||
*
|
||||
* @param slot Slot to extract from.
|
||||
* @param amount Amount to extract (may be greater than the current stacks max limit)
|
||||
* @param simulate If true, the extraction is only simulated
|
||||
* @return ItemStack extracted from the slot, must be ItemStack.EMPTY, if nothing can be extracted
|
||||
**/
|
||||
@Nonnull
|
||||
@Override
|
||||
public ItemStack extractItem( int slot, int amount, boolean simulate )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the maximum stack size allowed to exist in the given slot.
|
||||
*
|
||||
* @param slot Slot to query.
|
||||
* @return The maximum stack size allowed in the slot.
|
||||
*/
|
||||
@Override
|
||||
public int getSlotLimit( int slot )
|
||||
{
|
||||
if( slot >= 0 && slot < this.getDestination().getSizeInventory() )
|
||||
{
|
||||
return this.getDestination().getInventoryStackLimit();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize( final int i, final int j )
|
||||
{
|
||||
return this.getDestination().decrStackSize( i, j );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack removeStackFromSlot( final int i )
|
||||
{
|
||||
return ItemStack.EMPTY;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents( final int i, final ItemStack itemstack )
|
||||
{
|
||||
this.getDestination().setInventorySlotContents( i, itemstack );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomName()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit()
|
||||
{
|
||||
return this.getDestination().getInventoryStackLimit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty()
|
||||
{
|
||||
// eh?
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUsableByPlayer( final EntityPlayer entityplayer )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory( final EntityPlayer p )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory( final EntityPlayer p )
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCapability( Capability<?> capabilityClass )
|
||||
{
|
||||
@@ -424,6 +239,7 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
return super.hasCapability( capabilityClass );
|
||||
}
|
||||
|
||||
@SuppressWarnings( "unchecked" )
|
||||
@Override
|
||||
public <T> T getCapability( Capability<T> capabilityClass )
|
||||
{
|
||||
@@ -436,76 +252,43 @@ public class PartP2PItems extends PartP2PTunnel<PartP2PItems> implements /* IPip
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot( final int i, final net.minecraft.item.ItemStack itemstack )
|
||||
public int getSlots()
|
||||
{
|
||||
return this.getDestination().isItemValidForSlot( i, itemstack );
|
||||
return this.getDestination().getSlots();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canInsertItem( final int i, final ItemStack itemstack, final EnumFacing j )
|
||||
public ItemStack getStackInSlot( final int i )
|
||||
{
|
||||
return this.getDestination().isItemValidForSlot( i, itemstack );
|
||||
return this.getDestination().getStackInSlot( i );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canExtractItem( final int i, final ItemStack itemstack, final EnumFacing j )
|
||||
public ItemStack insertItem( final int slot, final ItemStack stack, boolean simulate )
|
||||
{
|
||||
return false;
|
||||
return this.getDestination().insertItem( slot, stack, simulate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack extractItem( final int slot, final int amount, boolean simulate )
|
||||
{
|
||||
return this.getDestination().extractItem( slot, amount, simulate );
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlotLimit( int slot )
|
||||
{
|
||||
return this.getDestination().getSlotLimit( slot );
|
||||
}
|
||||
|
||||
public float getPowerDrainPerTick()
|
||||
{
|
||||
return 2.0f;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getField( final int id )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// @Method( iname = IntegrationType.BuildCraftTransport )
|
||||
// public ConnectOverride overridePipeConnection( PipeType type, ForgeDirection with )
|
||||
// {
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void setField( final int id, final int value )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFieldCount()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear()
|
||||
{
|
||||
// probably not...
|
||||
}
|
||||
|
||||
@Override
|
||||
public ITextComponent getDisplayName()
|
||||
{
|
||||
return null;
|
||||
return POWER_DRAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPartModel getStaticModels()
|
||||
{
|
||||
return MODELS.getModel( this.isPowered(), this.isActive() );
|
||||
return MODELS.getModel( isPowered(), isActive() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,11 +22,11 @@ package appeng.parts.reporting;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.config.Settings;
|
||||
import appeng.api.config.SortDir;
|
||||
@@ -41,11 +41,11 @@ import appeng.api.util.IConfigManager;
|
||||
import appeng.core.sync.GuiBridge;
|
||||
import appeng.me.GridAccessException;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.IAEAppEngInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.ConfigManager;
|
||||
import appeng.util.IConfigManagerHost;
|
||||
import appeng.util.Platform;
|
||||
import appeng.util.inv.IAEAppEngInventory;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
|
||||
/**
|
||||
@@ -170,13 +170,13 @@ public abstract class AbstractPartTerminal extends AbstractPartDisplay implement
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getViewCellStorage()
|
||||
public IItemHandler getViewCellStorage()
|
||||
{
|
||||
return this.viewCell;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
this.getHost().markForSave();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import java.util.List;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.Vec3d;
|
||||
@@ -162,7 +161,7 @@ public class PartConversionMonitor extends AbstractPartMonitor
|
||||
if( retrieved != null )
|
||||
{
|
||||
ItemStack newItems = retrieved.getItemStack();
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
|
||||
final InventoryAdaptor adaptor = InventoryAdaptor.getAdaptor( player );
|
||||
newItems = adaptor.addItems( newItems );
|
||||
if( !newItems.isEmpty() )
|
||||
{
|
||||
|
||||
@@ -22,10 +22,10 @@ package appeng.parts.reporting;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.parts.IPartModel;
|
||||
import appeng.core.AppEng;
|
||||
@@ -105,7 +105,7 @@ public class PartCraftingTerminal extends AbstractPartTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "crafting" ) )
|
||||
{
|
||||
|
||||
@@ -22,10 +22,10 @@ package appeng.parts.reporting;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.items.IItemHandler;
|
||||
|
||||
import appeng.api.implementations.ICraftingPatternItem;
|
||||
import appeng.api.networking.crafting.ICraftingPatternDetails;
|
||||
@@ -37,7 +37,7 @@ import appeng.helpers.Reflected;
|
||||
import appeng.items.parts.PartModels;
|
||||
import appeng.parts.PartModel;
|
||||
import appeng.tile.inventory.AppEngInternalInventory;
|
||||
import appeng.tile.inventory.InvOperation;
|
||||
import appeng.util.inv.InvOperation;
|
||||
|
||||
|
||||
public class PartPatternTerminal extends AbstractPartTerminal
|
||||
@@ -120,7 +120,7 @@ public class PartPatternTerminal extends AbstractPartTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
public void onChangeInventory( final IItemHandler inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
|
||||
{
|
||||
if( inv == this.pattern && slot == 1 )
|
||||
{
|
||||
@@ -134,16 +134,16 @@ public class PartPatternTerminal extends AbstractPartTerminal
|
||||
this.setCraftingRecipe( details.isCraftable() );
|
||||
this.setSubstitution( details.canSubstitute() );
|
||||
|
||||
for( int x = 0; x < this.crafting.getSizeInventory() && x < details.getInputs().length; x++ )
|
||||
for( int x = 0; x < this.crafting.getSlots() && x < details.getInputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getInputs()[x];
|
||||
this.crafting.setInventorySlotContents( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
|
||||
this.crafting.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
|
||||
}
|
||||
|
||||
for( int x = 0; x < this.output.getSizeInventory() && x < details.getOutputs().length; x++ )
|
||||
for( int x = 0; x < this.output.getSlots() && x < details.getOutputs().length; x++ )
|
||||
{
|
||||
final IAEItemStack item = details.getOutputs()[x];
|
||||
this.output.setInventorySlotContents( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
|
||||
this.output.setStackInSlot( x, item == null ? ItemStack.EMPTY : item.getItemStack() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -160,7 +160,7 @@ public class PartPatternTerminal extends AbstractPartTerminal
|
||||
{
|
||||
if( this.craftingMode )
|
||||
{
|
||||
for( int x = 0; x < this.crafting.getSizeInventory(); x++ )
|
||||
for( int x = 0; x < this.crafting.getSlots(); x++ )
|
||||
{
|
||||
final ItemStack is = this.crafting.getStackInSlot( x );
|
||||
if( !is.isEmpty() )
|
||||
@@ -193,7 +193,7 @@ public class PartPatternTerminal extends AbstractPartTerminal
|
||||
}
|
||||
|
||||
@Override
|
||||
public IInventory getInventoryByName( final String name )
|
||||
public IItemHandler getInventoryByName( final String name )
|
||||
{
|
||||
if( name.equals( "crafting" ) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user