Use IItemHandler instead of IInventory internally (#2971)

* Use IItemHandler instead of IInventory internally
This commit is contained in:
fscan
2017-07-28 22:04:32 +02:00
committed by yueh
parent c077840988
commit 52d28fabe3
156 changed files with 2410 additions and 4604 deletions
@@ -40,7 +40,8 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.CompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -78,13 +79,13 @@ import appeng.helpers.ICustomNameObject;
import appeng.helpers.InventoryAction;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack;
public abstract class AEBaseContainer extends Container
{
private final InventoryPlayer invPlayer;
private final BaseActionSource mySrc;
private final HashSet<Integer> locked = new HashSet<>();
@@ -386,6 +387,8 @@ public abstract class AEBaseContainer extends Container
protected void bindPlayerInventory( final InventoryPlayer inventoryPlayer, final int offsetX, final int offsetY )
{
IItemHandler ih = new PlayerInvWrapper( inventoryPlayer );
// bind player inventory
for( int i = 0; i < 3; i++ )
{
@@ -393,11 +396,11 @@ public abstract class AEBaseContainer extends Container
{
if( this.locked.contains( j + i * 9 + 9 ) )
{
this.addSlotToContainer( new SlotDisabled( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18 ) );
this.addSlotToContainer( new SlotDisabled( ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18 ) );
}
else
{
this.addSlotToContainer( new SlotPlayerInv( inventoryPlayer, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18 ) );
this.addSlotToContainer( new SlotPlayerInv( ih, j + i * 9 + 9, 8 + j * 18 + offsetX, offsetY + i * 18 ) );
}
}
}
@@ -407,11 +410,11 @@ public abstract class AEBaseContainer extends Container
{
if( this.locked.contains( i ) )
{
this.addSlotToContainer( new SlotDisabled( inventoryPlayer, i, 8 + i * 18 + offsetX, 58 + offsetY ) );
this.addSlotToContainer( new SlotDisabled( ih, i, 8 + i * 18 + offsetX, 58 + offsetY ) );
}
else
{
this.addSlotToContainer( new SlotPlayerHotBar( inventoryPlayer, i, 8 + i * 18 + offsetX, 58 + offsetY ) );
this.addSlotToContainer( new SlotPlayerHotBar( ih, i, 8 + i * 18 + offsetX, 58 + offsetY ) );
}
}
}
@@ -862,7 +865,7 @@ public abstract class AEBaseContainer extends Container
ais.setStackSize( myItem.getMaxStackSize() );
final InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
final InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player );
myItem.setCount( (int) ais.getStackSize() );
myItem = adp.simulateAdd( myItem );
@@ -896,7 +899,7 @@ public abstract class AEBaseContainer extends Container
ais = Platform.poweredInsert( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
if( ais == null )
{
final InventoryAdaptor ia = new AdaptorPlayerHand( player );
final InventoryAdaptor ia = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) );
final ItemStack fail = ia.removeItems( 1, extracted.getItemStack(), null );
if( fail.isEmpty() )
@@ -940,7 +943,7 @@ public abstract class AEBaseContainer extends Container
ais = Platform.poweredExtraction( this.getPowerSource(), this.getCellInventory(), ais, this.getActionSource() );
if( ais != null )
{
final InventoryAdaptor ia = new AdaptorPlayerHand( player );
final InventoryAdaptor ia = new AdaptorItemHandler( new WrapperCursorItemHandler( player.inventory ) );
final ItemStack fail = ia.addItems( ais.getItemStack() );
if( !fail.isEmpty() )
@@ -1070,7 +1073,7 @@ public abstract class AEBaseContainer extends Container
ais.setStackSize( myItem.getMaxStackSize() );
final InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
final InventoryAdaptor adp = InventoryAdaptor.getAdaptor( player );
myItem.setCount( (int) ais.getStackSize() );
myItem = adp.simulateAdd( myItem );
@@ -21,14 +21,13 @@ package appeng.container.implementations;
import java.util.Iterator;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.EmptyHandler;
import appeng.api.AEApi;
import appeng.api.config.CopyMode;
@@ -43,16 +42,16 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.OptionalSlotRestrictedInput;
import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngNullInventory;
import appeng.tile.misc.TileCellWorkbench;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.WrapperLazyItemHandler;
import appeng.util.iterators.NullIterator;
public class ContainerCellWorkbench extends ContainerUpgradeable
{
private final TileCellWorkbench workBench;
private final AppEngNullInventory nullInventory = new AppEngNullInventory();
@GuiSync( 2 )
public CopyMode copyMode = CopyMode.CLEAR_ON_REMOVE;
private ItemStack prevStack = ItemStack.EMPTY;
@@ -92,11 +91,11 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
@Override
protected void setupConfig()
{
final IInventory cell = this.getUpgradeable().getInventoryByName( "cell" );
final IItemHandler cell = this.getUpgradeable().getInventoryByName( "cell" );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.WORKBENCH_CELL, cell, 0, 152, 8, this.getPlayerInv() ) );
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
final IInventory upgradeInventory = new Upgrades();
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
final WrapperLazyItemHandler upgradeInventory = new WrapperLazyItemHandler( this::getCellUpgradeInventory );
// null, 3 * 8 );
int offset = 0;
@@ -138,7 +137,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
if( this.prevStack != is )
{
this.prevStack = is;
this.lastUpgrades = this.getCellUpgradeInventory().getSizeInventory();
this.lastUpgrades = this.getCellUpgradeInventory().getSlots();
}
return this.lastUpgrades;
}
@@ -189,11 +188,11 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
return idx < this.availableUpgrades();
}
public IInventory getCellUpgradeInventory()
public IItemHandler getCellUpgradeInventory()
{
final IInventory upgradeInventory = this.workBench.getCellUpgradeInventory();
final IItemHandler upgradeInventory = this.workBench.getCellUpgradeInventory();
return upgradeInventory == null ? this.nullInventory : upgradeInventory;
return upgradeInventory == null ? EmptyHandler.INSTANCE : upgradeInventory;
}
@Override
@@ -209,11 +208,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
public void clear()
{
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
inv.setInventorySlotContents( x, ItemStack.EMPTY );
}
ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) );
this.detectAndSendChanges();
}
@@ -229,7 +224,7 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
public void partition()
{
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
final IMEInventory<IAEItemStack> cellInv = AEApi.instance().registries().cell().getCellInventory(
this.getUpgradeable().getInventoryByName( "cell" ).getStackInSlot( 0 ), null, StorageChannel.ITEMS );
@@ -241,17 +236,17 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
i = list.iterator();
}
for( int x = 0; x < inv.getSizeInventory(); x++ )
for( int x = 0; x < inv.getSlots(); x++ )
{
if( i.hasNext() )
{
final ItemStack g = i.next().getItemStack();
g.setCount( 1 );
inv.setInventorySlotContents( x, g );
ItemHandlerUtil.setStackInSlot( inv, x, g );
}
else
{
inv.setInventorySlotContents( x, ItemStack.EMPTY );
ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY );
}
}
@@ -267,131 +262,4 @@ public class ContainerCellWorkbench extends ContainerUpgradeable
{
this.copyMode = copyMode;
}
private class Upgrades implements IInventory
{
@Override
public int getSizeInventory()
{
return ContainerCellWorkbench.this.getCellUpgradeInventory().getSizeInventory();
}
@Override
public ItemStack getStackInSlot( final int i )
{
return ContainerCellWorkbench.this.getCellUpgradeInventory().getStackInSlot( i );
}
@Override
public ItemStack decrStackSize( final int i, final int j )
{
final IInventory inv = ContainerCellWorkbench.this.getCellUpgradeInventory();
final ItemStack is = inv.decrStackSize( i, j );
inv.markDirty();
return is;
}
@Override
public ItemStack removeStackFromSlot( final int i )
{
final IInventory inv = ContainerCellWorkbench.this.getCellUpgradeInventory();
final ItemStack is = inv.removeStackFromSlot( i );
inv.markDirty();
return is;
}
@Override
public void setInventorySlotContents( final int i, final ItemStack itemstack )
{
final IInventory inv = ContainerCellWorkbench.this.getCellUpgradeInventory();
inv.setInventorySlotContents( i, itemstack );
inv.markDirty();
}
@Override
public String getName()
{
return "Upgrades";
}
@Override
public boolean hasCustomName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public void markDirty()
{
}
@Override
public boolean isUsableByPlayer( EntityPlayer player )
{
return false;
}
@Override
public void openInventory( final EntityPlayer player )
{
}
@Override
public void closeInventory( final EntityPlayer player )
{
}
@Override
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
{
return ContainerCellWorkbench.this.getCellUpgradeInventory().isItemValidForSlot( i, itemstack );
}
@Override
public ITextComponent getDisplayName()
{
return null;
}
@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()
{
ContainerCellWorkbench.this.getCellUpgradeInventory().clear();
}
@Override
public boolean isEmpty()
{
// TODO Auto-generated method stub
return false;
}
}
}
}
@@ -36,8 +36,8 @@ public class ContainerChest extends AEBaseContainer
super( ip, chest, null );
this.chest = chest;
this.addSlotToContainer(
new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, this.chest, 1, 80, 37, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, this.chest.getInternalInventory(), 1, 80, 37, this
.getInventoryPlayer() ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
@@ -20,6 +20,7 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.CondenserOutput;
import appeng.api.config.Settings;
@@ -48,11 +49,12 @@ public class ContainerCondenser extends AEBaseContainer implements IProgressProv
super( ip, condenser, null );
this.condenser = condenser;
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.TRASH, condenser, 0, 51, 52, ip ) );
this.addSlotToContainer( new SlotOutput( condenser, 1, 105, 52, -1 ) );
IItemHandler inv = condenser.getInternalInventory();
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.TRASH, inv, 0, 51, 52, ip ) );
this.addSlotToContainer( new SlotOutput( inv, 1, 105, 52, -1 ) );
this.addSlotToContainer(
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, condenser.getInternalInventory(), 2, 101, 26, ip ) )
.setStackLimit( 1 ) );
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_COMPONENT, inv, 2, 101, 26, ip ) ).setStackLimit( 1 ) );
this.bindPlayerInventory( ip, 0, 197 - /* height of player inventory */82 );
}
@@ -24,6 +24,8 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import appeng.api.storage.ITerminalHost;
import appeng.container.ContainerNull;
@@ -32,8 +34,9 @@ import appeng.container.slot.SlotCraftingTerm;
import appeng.helpers.IContainerCraftingPacket;
import appeng.parts.reporting.PartCraftingTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperInvItemHandler;
public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAEAppEngInventory, IContainerCraftingPacket
@@ -49,7 +52,7 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
super( ip, monitorable, false );
this.ct = (PartCraftingTerminal) monitorable;
final IInventory crafting = this.ct.getInventoryByName( "crafting" );
final IItemHandler crafting = this.ct.getInventoryByName( "crafting" );
for( int y = 0; y < 3; y++ )
{
@@ -64,14 +67,15 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
this.bindPlayerInventory( ip, 0, 0 );
this.onCraftMatrixChanged( crafting );
this.onCraftMatrixChanged( new WrapperInvItemHandler( crafting ) );
}
/**
* Callback for when the crafting matrix is changed.
*/
@Override
public void onCraftMatrixChanged( final IInventory par1IInventory )
public void onCraftMatrixChanged( IInventory inventory )
{
final ContainerNull cn = new ContainerNull();
final InventoryCrafting ic = new InventoryCrafting( cn, 3, 3 );
@@ -82,6 +86,7 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
}
this.outputSlot.putStack( CraftingManager.findMatchingResult( ic, this.getPlayerInv().player.world ) );
super.onCraftMatrixChanged( inventory );
}
@Override
@@ -91,17 +96,17 @@ public class ContainerCraftingTerm extends ContainerMEMonitorable implements IAE
}
@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 )
{
}
@Override
public IInventory getInventoryByName( final String name )
public IItemHandler getInventoryByName( final String name )
{
if( name.equals( "player" ) )
{
return this.getInventoryPlayer();
return new PlayerInvWrapper( this.getInventoryPlayer() );
}
return this.ct.getInventoryByName( name );
}
@@ -37,9 +37,8 @@ public class ContainerDrive extends AEBaseContainer
{
for( int x = 0; x < 2; x++ )
{
this.addSlotToContainer(
new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, drive, x + y * 2, 71 + x * 18, 14 + y * 18, this
.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.STORAGE_CELLS, drive
.getInternalInventory(), x + y * 2, 71 + x * 18, 14 + y * 18, this.getInventoryPlayer() ) );
}
}
@@ -20,7 +20,7 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.FuzzyMode;
import appeng.api.config.SecurityPermissions;
@@ -58,7 +58,7 @@ public class ContainerFormationPlane extends ContainerUpgradeable
final int xo = 8;
final int yo = 23 + 6;
final IInventory config = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" );
for( int y = 0; y < 7; y++ )
{
for( int x = 0; x < 9; x++ )
@@ -74,7 +74,7 @@ public class ContainerFormationPlane extends ContainerUpgradeable
}
}
final IInventory upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) )
.setNotDraggable() );
this.addSlotToContainer(
@@ -20,6 +20,7 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraftforge.items.IItemHandler;
import appeng.container.AEBaseContainer;
import appeng.container.slot.SlotInaccessible;
@@ -35,15 +36,17 @@ public class ContainerGrinder extends AEBaseContainer
{
super( ip, grinder, null );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, grinder, 0, 12, 17, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, grinder, 1, 12 + 18, 17, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, grinder, 2, 12 + 36, 17, this.getInventoryPlayer() ) );
IItemHandler inv = grinder.getInternalInventory();
this.addSlotToContainer( new SlotInaccessible( grinder, 6, 80, 40 ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 0, 12, 17, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 1, 12 + 18, 17, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.ORE, inv, 2, 12 + 36, 17, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotOutput( grinder, 3, 112, 63, 2 * 16 + 15 ) );
this.addSlotToContainer( new SlotOutput( grinder, 4, 112 + 18, 63, 2 * 16 + 15 ) );
this.addSlotToContainer( new SlotOutput( grinder, 5, 112 + 36, 63, 2 * 16 + 15 ) );
this.addSlotToContainer( new SlotInaccessible( inv, 6, 80, 40 ) );
this.addSlotToContainer( new SlotOutput( inv, 3, 112, 63, 2 * 16 + 15 ) );
this.addSlotToContainer( new SlotOutput( inv, 4, 112 + 18, 63, 2 * 16 + 15 ) );
this.addSlotToContainer( new SlotOutput( inv, 5, 112 + 36, 63, 2 * 16 + 15 ) );
this.bindPlayerInventory( ip, 0, 176 - /* height of player inventory */82 );
}
@@ -20,7 +20,7 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.FullnessMode;
import appeng.api.config.OperationMode;
@@ -59,7 +59,7 @@ public class ContainerIOPort extends ContainerUpgradeable
int offX = 19;
int offY = 17;
final IInventory cells = this.getUpgradeable().getInventoryByName( "cells" );
final IItemHandler cells = this.getUpgradeable().getInventoryByName( "cells" );
for( int y = 0; y < 3; y++ )
{
@@ -82,7 +82,7 @@ public class ContainerIOPort extends ContainerUpgradeable
}
}
final IInventory upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) )
.setNotDraggable() );
this.addSlotToContainer(
@@ -22,6 +22,7 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.definitions.IItemDefinition;
@@ -60,14 +61,16 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
super( ip, te );
this.ti = te;
this.addSlotToContainer(
this.top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, this.ti, 0, 45, 16, this.getInventoryPlayer() ) );
this.addSlotToContainer(
this.bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, this.ti, 1, 45, 62, this.getInventoryPlayer() ) );
this.addSlotToContainer(
this.middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, this.ti, 2, 63, 39, this.getInventoryPlayer() ) );
IItemHandler inv = te.getInternalInventory();
this.addSlotToContainer( new SlotOutput( this.ti, 3, 113, 40, -1 ) );
this.addSlotToContainer(
this.top = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 0, 45, 16, this.getInventoryPlayer() ) );
this.addSlotToContainer(
this.bottom = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_PLATE, inv, 1, 45, 62, this.getInventoryPlayer() ) );
this.addSlotToContainer(
this.middle = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.INSCRIBER_INPUT, inv, 2, 63, 39, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotOutput( inv, 3, 113, 40, -1 ) );
}
@Override
@@ -112,8 +115,8 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
@Override
public boolean isValidForSlot( final Slot s, final ItemStack is )
{
final ItemStack top = this.ti.getStackInSlot( 0 );
final ItemStack bot = this.ti.getStackInSlot( 1 );
final ItemStack top = this.ti.getInternalInventory().getStackInSlot( 0 );
final ItemStack bot = this.ti.getInternalInventory().getStackInSlot( 1 );
if( s == this.middle )
{
@@ -132,12 +135,12 @@ public class ContainerInscriber extends ContainerUpgradeable implements IProgres
{
final boolean matchA = ( top.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( bot,
( bot.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
final boolean matchB = ( bot.isEmpty() && !recipe.getTopOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( bot,
recipe.getTopOptional().orElse( ItemStack.EMPTY ) ) ) && // and...
( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) | ( Platform.itemComparisons().isSameItem( top,
( top.isEmpty() && !recipe.getBottomOptional().isPresent() ) || ( Platform.itemComparisons().isSameItem( top,
recipe.getBottomOptional().orElse( ItemStack.EMPTY ) ) );
if( matchA || matchB )
@@ -26,10 +26,9 @@ import java.util.Map.Entry;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Settings;
import appeng.api.config.YesNo;
@@ -49,9 +48,11 @@ import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.misc.TileInterface;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorIInventory;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.WrapperInvSlot;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.WrapperFilteredItemHandler;
import appeng.util.inv.WrapperRangeItemHandler;
import appeng.util.inv.filter.IAEItemFilter;
public final class ContainerInterfaceTerminal extends AEBaseContainer
@@ -172,7 +173,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
for( final Entry<IInterfaceHost, InvTracker> en : this.diList.entrySet() )
{
final InvTracker inv = en.getValue();
for( int x = 0; x < inv.server.getSizeInventory(); x++ )
for( int x = 0; x < inv.server.getSlots(); x++ )
{
if( this.isDifferent( inv.server.getStackInSlot( x ), inv.client.getStackInSlot( x ) ) )
{
@@ -206,12 +207,10 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
final ItemStack is = inv.server.getStackInSlot( slot );
final boolean hasItemInHand = !player.inventory.getItemStack().isEmpty();
final InventoryAdaptor playerHand = new AdaptorPlayerHand( player );
final InventoryAdaptor playerHand = InventoryAdaptor.getAdaptor( player );
final WrapperInvSlot slotInv = new PatternInvSlot( inv.server );
final IInventory theSlot = slotInv.getWrapper( slot );
final InventoryAdaptor interfaceSlot = new AdaptorIInventory( theSlot );
final IItemHandler theSlot = new WrapperFilteredItemHandler( new WrapperRangeItemHandler( inv.server, slot, slot + 1 ), new PatternSlotFilter() );
final InventoryAdaptor interfaceSlot = new AdaptorItemHandler( theSlot );
switch( action )
{
@@ -229,7 +228,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
inSlot = inSlot.copy();
final ItemStack inHand = player.inventory.getItemStack().copy();
theSlot.setInventorySlotContents( 0, ItemStack.EMPTY );
ItemHandlerUtil.setStackInSlot( theSlot, 0, ItemStack.EMPTY );
player.inventory.setItemStack( ItemStack.EMPTY );
player.inventory.setItemStack( interfaceSlot.addItems( inHand.copy() ) );
@@ -241,14 +240,13 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
else
{
player.inventory.setItemStack( inHand );
theSlot.setInventorySlotContents( 0, inSlot );
ItemHandlerUtil.setStackInSlot( theSlot, 0, inSlot );
}
}
}
else
{
final IInventory mySlot = slotInv.getWrapper( slot );
mySlot.setInventorySlotContents( 0, playerHand.addItems( mySlot.getStackInSlot( 0 ) ) );
ItemHandlerUtil.setStackInSlot( theSlot, 0, playerHand.addItems( theSlot.getStackInSlot( 0 ) ) );
}
break;
@@ -282,17 +280,17 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
break;
case SHIFT_CLICK:
final IInventory mySlot = slotInv.getWrapper( slot );
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
mySlot.setInventorySlotContents( 0, playerInv.addItems( mySlot.getStackInSlot( 0 ) ) );
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( player );
ItemHandlerUtil.setStackInSlot( theSlot, 0, playerInv.addItems( theSlot.getStackInSlot( 0 ) ) );
break;
case MOVE_REGION:
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor( player, EnumFacing.UP );
for( int x = 0; x < inv.server.getSizeInventory(); x++ )
final InventoryAdaptor playerInvAd = InventoryAdaptor.getAdaptor( player );
for( int x = 0; x < inv.server.getSlots(); x++ )
{
inv.server.setInventorySlotContents( x, playerInvAd.addItems( inv.server.getStackInSlot( x ) ) );
ItemHandlerUtil.setStackInSlot( inv.server, x, playerInvAd.addItems( inv.server.getStackInSlot( x ) ) );
}
break;
@@ -351,7 +349,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
{
final InvTracker inv = en.getValue();
this.byId.put( inv.which, inv );
this.addItems( data, inv, 0, inv.server.getSizeInventory() );
this.addItems( data, inv, 0, inv.server.getSlots() );
}
}
@@ -388,7 +386,7 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
final ItemStack is = inv.server.getStackInSlot( x + offset );
// "update" client side.
inv.client.setInventorySlotContents( x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy() );
ItemHandlerUtil.setStackInSlot( inv.client, x + offset, is.isEmpty() ? ItemStack.EMPTY : is.copy() );
if( !is.isEmpty() )
{
@@ -407,30 +405,30 @@ public final class ContainerInterfaceTerminal extends AEBaseContainer
private final long sortBy;
private final long which = autoBase++;
private final String unlocalizedName;
private final IInventory client;
private final IInventory server;
private final IItemHandler client;
private final IItemHandler server;
public InvTracker( final DualityInterface dual, final IInventory patterns, final String unlocalizedName )
public InvTracker( final DualityInterface dual, final IItemHandler patterns, final String unlocalizedName )
{
this.server = patterns;
this.client = new AppEngInternalInventory( null, this.server.getSizeInventory() );
this.client = new AppEngInternalInventory( null, this.server.getSlots() );
this.unlocalizedName = unlocalizedName;
this.sortBy = dual.getSortValue();
}
}
private static class PatternInvSlot extends WrapperInvSlot
private static class PatternSlotFilter implements IAEItemFilter
{
public PatternInvSlot( final IInventory inv )
@Override
public boolean allowExtract( IItemHandler inv, int slot, int amount )
{
super( inv );
return true;
}
@Override
public boolean isItemValid( final ItemStack itemstack )
public boolean allowInsert( IItemHandler inv, int slot, ItemStack stack )
{
return !itemstack.isEmpty() && itemstack.getItem() instanceof ItemEncodedPattern;
return !stack.isEmpty() && stack.getItem() instanceof ItemEncodedPattern;
}
}
}
@@ -22,9 +22,9 @@ package appeng.container.implementations;
import net.minecraft.client.gui.GuiTextField;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.FuzzyMode;
import appeng.api.config.LevelType;
@@ -75,7 +75,7 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
@Override
protected void setupConfig()
{
final IInventory upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
if( this.availableUpgrades() > 0 )
{
this.addSlotToContainer(
@@ -101,7 +101,7 @@ public class ContainerLevelEmitter extends ContainerUpgradeable
.setNotDraggable() );
}
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
final int y = 40;
final int x = 80 + 44;
this.addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
@@ -20,9 +20,9 @@ package appeng.container.implementations;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.RedstoneMode;
import appeng.api.config.SecurityPermissions;
@@ -54,7 +54,7 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
public boolean isValidItemForSlot( final int slotIndex, final ItemStack i )
{
final IInventory mac = this.getUpgradeable().getInventoryByName( "mac" );
final IItemHandler mac = this.getUpgradeable().getInventoryByName( "mac" );
final ItemStack is = mac.getStackInSlot( 10 );
if( is.isEmpty() )
@@ -88,7 +88,7 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
int offX = 29;
int offY = 30;
final IInventory mac = this.getUpgradeable().getInventoryByName( "mac" );
final IItemHandler mac = this.getUpgradeable().getInventoryByName( "mac" );
for( int y = 0; y < 3; y++ )
{
@@ -109,7 +109,7 @@ public class ContainerMAC extends ContainerUpgradeable implements IProgressProvi
offX = 122;
offY = 17;
final IInventory upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) )
.setNotDraggable() );
this.addSlotToContainer(
@@ -49,9 +49,8 @@ public class ContainerNetworkTool extends AEBaseContainer
{
for( int x = 0; x < 3; x++ )
{
this.addSlotToContainer(
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, te, y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this
.getInventoryPlayer() ) ) );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, te
.getInventory(), y * 3 + x, 80 - 18 + x * 18, 37 - 18 + y * 18, this.getInventoryPlayer() ) ) );
}
}
@@ -27,7 +27,6 @@ import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCraftResult;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.inventory.Slot;
@@ -38,7 +37,8 @@ import net.minecraft.item.crafting.IRecipe;
import net.minecraft.nbt.NBTBase;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.EnumFacing;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.items.wrapper.PlayerInvWrapper;
import appeng.api.AEApi;
import appeng.api.config.Actionable;
@@ -61,11 +61,12 @@ import appeng.helpers.IContainerCraftingPacket;
import appeng.items.storage.ItemViewCell;
import appeng.parts.reporting.PartPatternTerminal;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.item.AEItemStack;
@@ -74,7 +75,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
private final PartPatternTerminal patternTerminal;
private final AppEngInternalInventory cOut = new AppEngInternalInventory( null, 1 );
private final IInventory crafting;
private final IItemHandler crafting;
private final SlotFakeCraftingMatrix[] craftingSlots = new SlotFakeCraftingMatrix[9];
private final OptionalSlotFake[] outputSlots = new OptionalSlotFake[3];
private final SlotPatternTerm craftSlot;
@@ -90,8 +91,8 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
super( ip, monitorable, false );
this.patternTerminal = (PartPatternTerminal) monitorable;
final IInventory patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
final IInventory output = this.getPatternTerminal().getInventoryByName( "output" );
final IItemHandler patternInv = this.getPatternTerminal().getInventoryByName( "pattern" );
final IItemHandler output = this.getPatternTerminal().getInventoryByName( "output" );
this.crafting = this.getPatternTerminal().getInventoryByName( "crafting" );
@@ -166,7 +167,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
}
final ItemStack is = CraftingManager.findMatchingResult( ic, this.getPlayerInv().player.world );
this.cOut.setInventorySlotContents( 0, is );
this.cOut.setStackInSlot( 0, is );
return is;
}
@@ -177,7 +178,7 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
}
@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 )
{
}
@@ -355,8 +356,8 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
if( packetPatternSlot.slotItem != null && this.getCellInventory() != null )
{
final IAEItemStack out = packetPatternSlot.slotItem.copy();
InventoryAdaptor inv = new AdaptorPlayerHand( this.getPlayerInv().player );
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player, EnumFacing.UP );
InventoryAdaptor inv = new AdaptorItemHandler( new WrapperCursorItemHandler( this.getPlayerInv().player.inventory ) );
final InventoryAdaptor playerInv = InventoryAdaptor.getAdaptor( this.getPlayerInv().player );
if( packetPatternSlot.shift )
{
@@ -527,11 +528,11 @@ public class ContainerPatternTerm extends ContainerMEMonitorable implements IAEA
}
@Override
public IInventory getInventoryByName( final String name )
public IItemHandler getInventoryByName( final String name )
{
if( name.equals( "player" ) )
{
return this.getInventoryPlayer();
return new PlayerInvWrapper( this.getInventoryPlayer() );
}
return this.getPatternTerminal().getInventoryByName( name );
}
@@ -33,9 +33,8 @@ public class ContainerQNB extends AEBaseContainer
{
super( ip, quantumBridge, null );
this.addSlotToContainer(
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge, 0, 80, 37, this.getInventoryPlayer() ) )
.setStackLimit( 1 ) );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.QE_SINGULARITY, quantumBridge
.getInternalInventory(), 0, 80, 37, this.getInventoryPlayer() ) ).setStackLimit( 1 ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
@@ -19,34 +19,31 @@
package appeng.container.implementations;
import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.text.ITextComponent;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerDestroyItemEvent;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.container.AEBaseContainer;
import appeng.container.slot.QuartzKnifeOutput;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.items.contents.QuartzKnifeObj;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.util.Platform;
public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngInventory, IInventory
public class ContainerQuartzKnife extends AEBaseContainer
{
private final QuartzKnifeObj toolInv;
private final AppEngInternalInventory inSlot = new AppEngInternalInventory( this, 1 );
private final SlotRestrictedInput metals;
private final QuartzKnifeOutput output;
private final IItemHandler inSlot = new AppEngInternalInventory( null, 1, 1 );
private String myName = "";
public ContainerQuartzKnife( final InventoryPlayer ip, final QuartzKnifeObj te )
@@ -54,11 +51,8 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
super( ip, null, null );
this.toolInv = te;
this.metals = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.METAL_INGOTS, this.inSlot, 0, 94, 44, ip );
this.addSlotToContainer( this.metals );
this.output = new QuartzKnifeOutput( this, 0, 134, 44, -1 );
this.addSlotToContainer( this.output );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.METAL_INGOTS, this.inSlot, 0, 94, 44, ip ) );
this.addSlotToContainer( new QuartzKniveSlot( this.inSlot, 0, 134, 44, -1 ) );
this.lockPlayerInventorySlot( ip.currentItem );
@@ -106,179 +100,73 @@ public class ContainerQuartzKnife extends AEBaseContainer implements IAEAppEngIn
}
}
@Override
public void saveChanges()
private class QuartzKniveSlot extends SlotOutput
{
}
@Override
public void onChangeInventory( final IInventory inv, final int slot, final InvOperation mc, final ItemStack removedStack, final ItemStack newStack )
{
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public ItemStack getStackInSlot( final int var1 )
{
final ItemStack input = this.inSlot.getStackInSlot( 0 );
if( input == ItemStack.EMPTY )
QuartzKniveSlot( IItemHandler a, int b, int c, int d, int i )
{
super( a, b, c, d, i );
}
@Override
public ItemStack getStack()
{
final IItemHandler baseInv = getItemHandler();
final ItemStack input = baseInv.getStackInSlot( 0 );
if( input == ItemStack.EMPTY )
{
return ItemStack.EMPTY;
}
if( SlotRestrictedInput.isMetalIngot( input ) )
{
if( ContainerQuartzKnife.this.myName.length() > 0 )
{
return AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).map( namePressStack ->
{
final NBTTagCompound compound = Platform.openNbtData( namePressStack );
compound.setString( "InscribeName", ContainerQuartzKnife.this.myName );
return namePressStack;
} ).orElse( ItemStack.EMPTY );
}
}
return ItemStack.EMPTY;
}
if( SlotRestrictedInput.isMetalIngot( input ) )
@Override
@Nonnull
public ItemStack decrStackSize( int amount )
{
if( this.myName.length() > 0 )
ItemStack ret = getStack();
if( !ret.isEmpty() )
{
return AEApi.instance().definitions().materials().namePress().maybeStack( 1 ).map( namePressStack ->
makePlate();
}
return ret;
}
@Override
public void putStack( final ItemStack stack )
{
if( stack.isEmpty() )
{
makePlate();
}
}
private void makePlate()
{
if( !getItemHandler().extractItem( 0, 1, false ).isEmpty() )
{
final ItemStack item = ContainerQuartzKnife.this.toolInv.getItemStack();
item.damageItem( 1, getPlayerInv().player );
if( item.getCount() == 0 )
{
final NBTTagCompound compound = Platform.openNbtData( namePressStack );
compound.setString( "InscribeName", this.myName );
return namePressStack;
} ).orElse( ItemStack.EMPTY );
getPlayerInv().mainInventory.add( getPlayerInv().currentItem, ItemStack.EMPTY );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( getPlayerInv().player, item, null ) );
}
}
}
return ItemStack.EMPTY;
}
@Override
public ItemStack decrStackSize( final int var1, final int var2 )
{
final ItemStack is = this.getStackInSlot( 0 );
if( !is.isEmpty() )
{
if( this.makePlate() )
{
return is;
}
}
return ItemStack.EMPTY;
}
private boolean makePlate()
{
if( this.inSlot.decrStackSize( 0, 1 ) != null )
{
final ItemStack item = this.toolInv.getItemStack();
item.damageItem( 1, this.getPlayerInv().player );
if( item.getCount() == 0 )
{
this.getPlayerInv().mainInventory.add( this.getPlayerInv().currentItem, ItemStack.EMPTY );
MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( this.getPlayerInv().player, item, null ) );
}
return true;
}
return false;
}
@Override
public ItemStack removeStackFromSlot( final int var1 )
{
return ItemStack.EMPTY;
}
@Override
public void setInventorySlotContents( final int var1, final ItemStack var2 )
{
if( var2.isEmpty() && Platform.isServer() )
{
this.makePlate();
}
}
@Override
public String getName()
{
return "Quartz Knife Output";
}
@Override
public boolean hasCustomName()
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
public void markDirty()
{
}
@Override
public boolean isUsableByPlayer( EntityPlayer player )
{
return false;
}
@Override
public void openInventory( final EntityPlayer player )
{
}
@Override
public void closeInventory( final EntityPlayer player )
{
}
@Override
public boolean isItemValidForSlot( final int var1, final ItemStack var2 )
{
return false;
}
@Override
public ITextComponent getDisplayName()
{
return null;
}
@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()
{
this.inSlot.setInventorySlotContents( 0, ItemStack.EMPTY );
}
@Override
public boolean isEmpty()
{
// TODO Auto-generated method stub
return false;
}
}
@@ -22,8 +22,8 @@ package appeng.container.implementations;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IContainerListener;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.SecurityPermissions;
@@ -35,9 +35,9 @@ import appeng.container.guisync.GuiSync;
import appeng.container.slot.SlotOutput;
import appeng.container.slot.SlotRestrictedInput;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.IAEAppEngInventory;
import appeng.tile.inventory.InvOperation;
import appeng.tile.misc.TileSecurityStation;
import appeng.util.inv.IAEAppEngInventory;
import appeng.util.inv.InvOperation;
public class ContainerSecurityStation extends ContainerMEMonitorable implements IAEAppEngInventory
@@ -142,7 +142,7 @@ public class ContainerSecurityStation extends ContainerMEMonitorable implements
}
@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( !this.wirelessOut.getHasStack() )
{
@@ -41,7 +41,7 @@ public class ContainerSkyChest extends AEBaseContainer
{
for( int x = 0; x < 9; x++ )
{
this.addSlotToContainer( new SlotNormal( this.chest, y * 9 + x, 8 + 18 * x, 24 + 18 * y ) );
this.addSlotToContainer( new SlotNormal( this.chest.getInternalInventory(), y * 9 + x, 8 + 18 * x, 24 + 18 * y ) );
}
}
@@ -57,9 +57,10 @@ public class ContainerSpatialIOPort extends AEBaseContainer
this.network = spatialIOPort.getGridNode( AEPartLocation.INTERNAL ).getGrid();
}
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, spatialIOPort
.getInternalInventory(), 0, 52, 48, this.getInventoryPlayer() ) );
this.addSlotToContainer(
new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS, spatialIOPort, 0, 52, 48, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotOutput( spatialIOPort, 1, 113, 48, SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon ) );
new SlotOutput( spatialIOPort.getInternalInventory(), 1, 113, 48, SlotRestrictedInput.PlacableItemType.SPATIAL_STORAGE_CELLS.IIcon ) );
this.bindPlayerInventory( ip, 0, 197 - /* height of player inventory */82 );
}
@@ -22,8 +22,8 @@ package appeng.container.implementations;
import java.util.Iterator;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.config.AccessRestriction;
@@ -41,6 +41,7 @@ import appeng.container.slot.SlotFakeTypeOnly;
import appeng.container.slot.SlotRestrictedInput;
import appeng.parts.misc.PartStorageBus;
import appeng.util.Platform;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.iterators.NullIterator;
@@ -73,7 +74,7 @@ public class ContainerStorageBus extends ContainerUpgradeable
final int xo = 8;
final int yo = 23 + 6;
final IInventory config = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler config = this.getUpgradeable().getInventoryByName( "config" );
for( int y = 0; y < 7; y++ )
{
for( int x = 0; x < 9; x++ )
@@ -89,7 +90,7 @@ public class ContainerStorageBus extends ContainerUpgradeable
}
}
final IInventory upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, upgrades, 0, 187, 8, this.getInventoryPlayer() ) )
.setNotDraggable() );
this.addSlotToContainer(
@@ -143,17 +144,13 @@ public class ContainerStorageBus extends ContainerUpgradeable
public void clear()
{
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
for( int x = 0; x < inv.getSizeInventory(); x++ )
{
inv.setInventorySlotContents( x, ItemStack.EMPTY );
}
ItemHandlerUtil.clear( this.getUpgradeable().getInventoryByName( "config" ) );
this.detectAndSendChanges();
}
public void partition()
{
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
final IMEInventory<IAEItemStack> cellInv = this.storageBus.getInternalHandler();
@@ -164,17 +161,17 @@ public class ContainerStorageBus extends ContainerUpgradeable
i = list.iterator();
}
for( int x = 0; x < inv.getSizeInventory(); x++ )
for( int x = 0; x < inv.getSlots(); x++ )
{
if( i.hasNext() && this.isSlotEnabled( ( x / 9 ) - 2 ) )
{
final ItemStack g = i.next().getItemStack();
g.setCount( 1 );
inv.setInventorySlotContents( x, g );
ItemHandlerUtil.setStackInSlot( inv, x, g );
}
else
{
inv.setInventorySlotContents( x, ItemStack.EMPTY );
ItemHandlerUtil.setStackInSlot( inv, x, ItemStack.EMPTY );
}
}
@@ -25,6 +25,7 @@ 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.FuzzyMode;
import appeng.api.config.RedstoneMode;
@@ -112,9 +113,8 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
{
for( int u = 0; u < 3; u++ )
{
this.addSlotToContainer(
( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, this.tbInventory, u + v * 3, 186 + u * 18, this
.getHeight() - 82 + v * 18, this.getInventoryPlayer() ) ).setPlayerSide() );
this.addSlotToContainer( ( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.UPGRADES, this.tbInventory
.getInternalInventory(), u + v * 3, 186 + u * 18, this.getHeight() - 82 + v * 18, this.getInventoryPlayer() ) ).setPlayerSide() );
}
}
}
@@ -138,7 +138,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
{
this.setupUpgrades();
final IInventory inv = this.getUpgradeable().getInventoryByName( "config" );
final IItemHandler inv = this.getUpgradeable().getInventoryByName( "config" );
final int y = 40;
final int x = 80;
this.addSlotToContainer( new SlotFakeTypeOnly( inv, 0, x, y ) );
@@ -159,7 +159,7 @@ public class ContainerUpgradeable extends AEBaseContainer implements IOptionalSl
protected void setupUpgrades()
{
final IInventory upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
final IItemHandler upgrades = this.getUpgradeable().getInventoryByName( "upgrades" );
if( this.availableUpgrades() > 0 )
{
this.addSlotToContainer(
@@ -45,7 +45,8 @@ public class ContainerVibrationChamber extends AEBaseContainer implements IProgr
super( ip, vibrationChamber, null );
this.vibrationChamber = vibrationChamber;
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.FUEL, vibrationChamber, 0, 80, 37, this.getInventoryPlayer() ) );
this.addSlotToContainer( new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.FUEL, vibrationChamber.getInternalInventory(), 0, 80, 37, this
.getInventoryPlayer() ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
@@ -43,9 +43,8 @@ public class ContainerWireless extends AEBaseContainer
super( ip, te, null );
this.wirelessTerminal = te;
this.addSlotToContainer(
this.boosterSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, this.wirelessTerminal, 0, 80, 47, this
.getInventoryPlayer() ) );
this.addSlotToContainer( this.boosterSlot = new SlotRestrictedInput( SlotRestrictedInput.PlacableItemType.RANGE_BOOSTER, this.wirelessTerminal
.getInternalInventory(), 0, 80, 47, this.getInventoryPlayer() ) );
this.bindPlayerInventory( ip, 0, 166 - /* height of player inventory */82 );
}
@@ -20,11 +20,14 @@ package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.CraftingManager;
import net.minecraft.util.NonNullList;
import net.minecraftforge.items.IItemHandler;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.WrapperInvItemHandler;
public class AppEngCraftingSlot extends AppEngSlot
@@ -33,7 +36,7 @@ public class AppEngCraftingSlot extends AppEngSlot
/**
* The craft matrix inventory linked to this result slot.
*/
private final IInventory craftMatrix;
private final IItemHandler craftMatrix;
/**
* The player that is using the GUI where this slot resides.
@@ -45,7 +48,7 @@ public class AppEngCraftingSlot extends AppEngSlot
*/
private int amountCrafted;
public AppEngCraftingSlot( final EntityPlayer par1EntityPlayer, final IInventory par2IInventory, final IInventory par3IInventory, final int par4, final int par5, final int par6 )
public AppEngCraftingSlot( final EntityPlayer par1EntityPlayer, final IItemHandler par2IInventory, final IItemHandler par3IInventory, final int par4, final int par5, final int par6 )
{
super( par3IInventory, par4, par5, par6 );
this.thePlayer = par1EntityPlayer;
@@ -136,22 +139,19 @@ public class AppEngCraftingSlot extends AppEngSlot
@Override
public ItemStack onTake( final EntityPlayer playerIn, final ItemStack stack )
{
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent( playerIn, stack, this.craftMatrix );
net.minecraftforge.fml.common.FMLCommonHandler.instance().firePlayerCraftingEvent( playerIn, stack, new WrapperInvItemHandler( this.craftMatrix ) );
this.onCrafting( stack );
net.minecraftforge.common.ForgeHooks.setCraftingPlayer( playerIn );
final InventoryCrafting ic = new InventoryCrafting( this.getContainer(), 3, 3 );
for( int x = 0; x < this.craftMatrix.getSizeInventory(); x++ )
for( int x = 0; x < this.craftMatrix.getSlots(); x++ )
{
ic.setInventorySlotContents( x, this.craftMatrix.getStackInSlot( x ) );
}
final NonNullList<ItemStack> aitemstack = CraftingManager.getRemainingItems( ic, playerIn.world );
for( int x = 0; x < this.craftMatrix.getSizeInventory(); x++ )
{
this.craftMatrix.setInventorySlotContents( x, ic.getStackInSlot( x ) );
}
ItemHandlerUtil.copy( ic, this.craftMatrix, false );
net.minecraftforge.common.ForgeHooks.setCraftingPlayer( null );
@@ -162,14 +162,14 @@ public class AppEngCraftingSlot extends AppEngSlot
if( !itemstack1.isEmpty() )
{
this.craftMatrix.decrStackSize( i, 1 );
this.craftMatrix.extractItem( i, 1, false );
}
if( !itemstack2.isEmpty() )
{
if( this.craftMatrix.getStackInSlot( i ).isEmpty() )
{
this.craftMatrix.setInventorySlotContents( i, itemstack2 );
ItemHandlerUtil.setStackInSlot( this.craftMatrix, i, itemstack2 );
}
else if( !this.thePlayer.inventory.addItemStackToInventory( itemstack2 ) )
{
@@ -23,17 +23,22 @@ import javax.annotation.Nonnull;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryBasic;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import net.minecraftforge.items.IItemHandler;
import appeng.container.AEBaseContainer;
import appeng.tile.inventory.AppEngInternalInventory;
import appeng.util.helpers.ItemHandlerUtil;
public class AppEngSlot extends Slot
{
private static IInventory emptyInventory = new InventoryBasic( "[Null]", true, 0 );
private final IItemHandler itemHandler;
private final int index;
private final int defX;
private final int defY;
@@ -44,9 +49,12 @@ public class AppEngSlot extends Slot
private hasCalculatedValidness isValid;
private boolean isDisplay = false;
public AppEngSlot( final IInventory inv, final int idx, final int x, final int y )
public AppEngSlot( final IItemHandler inv, final int idx, final int x, final int y )
{
super( inv, idx, x, y );
super( emptyInventory, idx, x, y );
this.itemHandler = inv;
this.index = idx;
this.defX = x;
this.defY = y;
this.setIsValid( hasCalculatedValidness.NotAvailable );
@@ -75,11 +83,11 @@ public class AppEngSlot extends Slot
}
@Override
public boolean isItemValid( final ItemStack par1ItemStack )
public boolean isItemValid( @Nonnull final ItemStack par1ItemStack )
{
if( this.isSlotEnabled() )
{
return super.isItemValid( par1ItemStack );
return ItemHandlerUtil.isItemValidForSlot( this.itemHandler, this.index, par1ItemStack );
}
return false;
}
@@ -93,7 +101,7 @@ public class AppEngSlot extends Slot
return ItemStack.EMPTY;
}
if( this.inventory.getSizeInventory() <= this.getSlotIndex() )
if( this.itemHandler.getSlots() <= this.getSlotIndex() )
{
return ItemStack.EMPTY;
}
@@ -103,15 +111,17 @@ public class AppEngSlot extends Slot
this.setDisplay( false );
return this.getDisplayStack();
}
return super.getStack();
return this.itemHandler.getStackInSlot( index );
}
@Override
public void putStack( final ItemStack par1ItemStack )
public void putStack( final ItemStack stack )
{
if( this.isSlotEnabled() )
{
super.putStack( par1ItemStack );
ItemHandlerUtil.setStackInSlot( this.itemHandler, index, stack );
this.onSlotChanged();
if( this.getContainer() != null )
{
@@ -120,31 +130,53 @@ public class AppEngSlot extends Slot
}
}
public IItemHandler getItemHandler()
{
return this.itemHandler;
}
@Override
public void onSlotChanged()
{
if( this.inventory instanceof AppEngInternalInventory )
{
( (AppEngInternalInventory) this.inventory ).markDirty( this.getSlotIndex() );
}
else
{
super.onSlotChanged();
}
ItemHandlerUtil.markDirty( this.itemHandler, this.index );
this.setIsValid( hasCalculatedValidness.NotAvailable );
}
@Override
public int getSlotStackLimit()
{
return this.itemHandler.getSlotLimit( this.index );
}
@Override
public int getItemStackLimit( @Nonnull ItemStack stack )
{
return Math.min( getSlotStackLimit(), stack.getMaxStackSize() );
}
@Override
public boolean canTakeStack( final EntityPlayer par1EntityPlayer )
{
if( this.isSlotEnabled() )
{
return super.canTakeStack( par1EntityPlayer );
return !this.itemHandler.extractItem( index, 1, true ).isEmpty();
}
return false;
}
@Override
@Nonnull
public ItemStack decrStackSize( int amount )
{
return this.itemHandler.extractItem( index, amount, false );
}
@Override
public boolean isSameInventory( Slot other )
{
return other instanceof AppEngSlot && ( (AppEngSlot) other ).itemHandler == this.itemHandler;
}
@Override
@SideOnly( Side.CLIENT )
public boolean isEnabled()
@@ -159,7 +191,7 @@ public class AppEngSlot extends Slot
public ItemStack getDisplayStack()
{
return super.getStack();
return this.itemHandler.getStackInSlot( index );
}
public float getOpacityOfIcon()
@@ -21,8 +21,8 @@ package appeng.container.slot;
import javax.annotation.Nonnull;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class OptionalSlotFake extends SlotFake
@@ -34,7 +34,7 @@ public class OptionalSlotFake extends SlotFake
private final IOptionalSlotHost host;
private boolean renderDisabled = true;
public OptionalSlotFake( final IInventory inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
public OptionalSlotFake( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
{
super( inv, idx, x + offX * 18, y + offY * 18 );
this.srcX = x;
@@ -19,14 +19,14 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class OptionalSlotFakeTypeOnly extends OptionalSlotFake
{
public OptionalSlotFakeTypeOnly( final IInventory inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
public OptionalSlotFakeTypeOnly( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
{
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
}
@@ -19,7 +19,7 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class OptionalSlotNormal extends AppEngSlot
@@ -28,7 +28,7 @@ public class OptionalSlotNormal extends AppEngSlot
private final int groupNum;
private final IOptionalSlotHost host;
public OptionalSlotNormal( final IInventory inv, final IOptionalSlotHost containerBus, final int slot, final int xPos, final int yPos, final int groupNum )
public OptionalSlotNormal( final IItemHandler inv, final IOptionalSlotHost containerBus, final int slot, final int xPos, final int yPos, final int groupNum )
{
super( inv, slot, xPos, yPos );
this.groupNum = groupNum;
@@ -20,7 +20,7 @@ package appeng.container.slot;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class OptionalSlotRestrictedInput extends SlotRestrictedInput
@@ -29,7 +29,7 @@ public class OptionalSlotRestrictedInput extends SlotRestrictedInput
private final int groupNum;
private final IOptionalSlotHost host;
public OptionalSlotRestrictedInput( final PlacableItemType valid, final IInventory i, final IOptionalSlotHost host, final int slotIndex, final int x, final int y, final int grpNum, final InventoryPlayer invPlayer )
public OptionalSlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final IOptionalSlotHost host, final int slotIndex, final int x, final int y, final int grpNum, final InventoryPlayer invPlayer )
{
super( valid, i, slotIndex, x, y, invPlayer );
this.groupNum = grpNum;
@@ -1,32 +0,0 @@
/*
* 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.container.slot;
import net.minecraft.inventory.IInventory;
public class QuartzKnifeOutput extends SlotOutput
{
public QuartzKnifeOutput( final IInventory a, final int b, final int c, final int d, final int i )
{
super( a, b, c, d, i );
}
}
@@ -19,34 +19,38 @@
package appeng.container.slot;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.container.AEBaseContainer;
import appeng.util.inv.WrapperInvItemHandler;
public class SlotCraftingMatrix extends AppEngSlot
{
private final AEBaseContainer c;
private final IInventory wrappedInventory;
private final Container c;
public SlotCraftingMatrix( final Container c, final IInventory par1iInventory, final int par2, final int par3, final int par4 )
public SlotCraftingMatrix( final AEBaseContainer c, final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
{
super( par1iInventory, par2, par3, par4 );
this.c = c;
this.wrappedInventory = new WrapperInvItemHandler( par1iInventory );
}
@Override
public void clearStack()
{
super.clearStack();
this.c.onCraftMatrixChanged( this.inventory );
this.c.onCraftMatrixChanged( this.wrappedInventory );
}
@Override
public void putStack( final ItemStack par1ItemStack )
{
super.putStack( par1ItemStack );
this.c.onCraftMatrixChanged( this.inventory );
this.c.onCraftMatrixChanged( this.wrappedInventory );
}
@Override
@@ -59,7 +63,7 @@ public class SlotCraftingMatrix extends AppEngSlot
public ItemStack decrStackSize( final int par1 )
{
final ItemStack is = super.decrStackSize( par1 );
this.c.onCraftMatrixChanged( this.inventory );
this.c.onCraftMatrixChanged( this.wrappedInventory );
return is;
}
}
@@ -24,12 +24,12 @@ import java.util.Arrays;
import java.util.List;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.item.crafting.IRecipe;
import net.minecraft.util.math.BlockPos;
import net.minecraftforge.items.IItemHandler;
import appeng.api.config.Actionable;
import appeng.api.networking.energy.IEnergySource;
@@ -44,22 +44,25 @@ import appeng.helpers.InventoryAction;
import appeng.items.storage.ItemViewCell;
import appeng.util.InventoryAdaptor;
import appeng.util.Platform;
import appeng.util.inv.AdaptorPlayerHand;
import appeng.util.helpers.ItemHandlerUtil;
import appeng.util.inv.AdaptorItemHandler;
import appeng.util.inv.WrapperCursorItemHandler;
import appeng.util.inv.WrapperInvItemHandler;
import appeng.util.item.AEItemStack;
public class SlotCraftingTerm extends AppEngCraftingSlot
{
private final IInventory craftInv;
private final IInventory pattern;
private final IItemHandler craftInv;
private final IItemHandler pattern;
private final BaseActionSource mySrc;
private final IEnergySource energySrc;
private final IStorageMonitorable storage;
private final IContainerCraftingPacket container;
public SlotCraftingTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IInventory cMatrix, final IInventory secondMatrix, final IInventory output, final int x, final int y, final IContainerCraftingPacket ccp )
public SlotCraftingTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IContainerCraftingPacket ccp )
{
super( player, cMatrix, output, 0, x, y );
this.energySrc = energySrc;
@@ -70,7 +73,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
this.container = ccp;
}
public IInventory getCraftingMatrix()
public IItemHandler getCraftingMatrix()
{
return this.craftInv;
}
@@ -105,18 +108,18 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
InventoryAdaptor ia = null;
if( action == InventoryAction.CRAFT_SHIFT ) // craft into player inventory...
{
ia = InventoryAdaptor.getAdaptor( who, null );
ia = InventoryAdaptor.getAdaptor( who );
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
}
else if( action == InventoryAction.CRAFT_STACK ) // craft into hand, full stack
{
ia = new AdaptorPlayerHand( who );
ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) );
maxTimesToCraft = (int) Math.floor( (double) this.getStack().getMaxStackSize() / (double) howManyPerCraft );
}
else
// pick up what was crafted...
{
ia = new AdaptorPlayerHand( who );
ia = new AdaptorItemHandler( new WrapperCursorItemHandler( who.inventory ) );
maxTimesToCraft = 1;
}
@@ -162,7 +165,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
if( !is.isEmpty() && Platform.itemComparisons().isEqualItem( request, is ) )
{
final ItemStack[] set = new ItemStack[this.getPattern().getSizeInventory()];
final ItemStack[] set = new ItemStack[this.getPattern().getSlots()];
// Safeguard for empty slots in the inventory for now
Arrays.fill( set, ItemStack.EMPTY );
@@ -199,7 +202,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
{
super.onTake( p, is );
// actually necessary to cleanup this case...
p.openContainer.onCraftMatrixChanged( this.craftInv );
p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) );
return request;
}
}
@@ -210,7 +213,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
if( inv != null )
{
for( int x = 0; x < this.getPattern().getSizeInventory(); x++ )
for( int x = 0; x < this.getPattern().getSlots(); x++ )
{
if( !this.getPattern().getStackInSlot( x ).isEmpty() )
{
@@ -229,8 +232,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
this.postCraft( p, inv, set, is );
}
// shouldn't be necessary...
p.openContainer.onCraftMatrixChanged( this.craftInv );
p.openContainer.onCraftMatrixChanged( new WrapperInvItemHandler( this.craftInv ) );
return is;
}
@@ -256,11 +258,11 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
if( Platform.isServer() )
{
// set new items onto the crafting table...
for( int x = 0; x < this.craftInv.getSizeInventory(); x++ )
for( int x = 0; x < this.craftInv.getSlots(); x++ )
{
if( this.craftInv.getStackInSlot( x ).isEmpty() )
{
this.craftInv.setInventorySlotContents( x, set[x] );
ItemHandlerUtil.setStackInSlot( this.craftInv, x, set[x] );
}
else if( !set[x].isEmpty() )
{
@@ -280,7 +282,7 @@ public class SlotCraftingTerm extends AppEngCraftingSlot
}
}
IInventory getPattern()
IItemHandler getPattern()
{
return this.pattern;
}
@@ -20,14 +20,14 @@ package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class SlotDisabled extends AppEngSlot
{
public SlotDisabled( final IInventory par1iInventory, final int slotIndex, final int x, final int y )
public SlotDisabled( final IItemHandler par1iInventory, final int slotIndex, final int x, final int y )
{
super( par1iInventory, slotIndex, x, y );
}
@@ -20,14 +20,14 @@ package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class SlotFake extends AppEngSlot
{
public SlotFake( final IInventory inv, final int idx, final int x, final int y )
public SlotFake( final IItemHandler inv, final int idx, final int x, final int y )
{
super( inv, idx, x, y );
}
@@ -19,13 +19,13 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class SlotFakeBlacklist extends SlotFakeTypeOnly
{
public SlotFakeBlacklist( final IInventory inv, final int idx, final int x, final int y )
public SlotFakeBlacklist( final IItemHandler inv, final int idx, final int x, final int y )
{
super( inv, idx, x, y );
}
@@ -19,13 +19,13 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class SlotFakeCraftingMatrix extends SlotFake
{
public SlotFakeCraftingMatrix( final IInventory inv, final int idx, final int x, final int y )
public SlotFakeCraftingMatrix( final IItemHandler inv, final int idx, final int x, final int y )
{
super( inv, idx, x, y );
}
@@ -19,14 +19,14 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class SlotFakeTypeOnly extends SlotFake
{
public SlotFakeTypeOnly( final IInventory inv, final int idx, final int x, final int y )
public SlotFakeTypeOnly( final IItemHandler inv, final int idx, final int x, final int y )
{
super( inv, idx, x, y );
}
@@ -20,8 +20,8 @@ package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class SlotInaccessible extends AppEngSlot
@@ -29,7 +29,7 @@ public class SlotInaccessible extends AppEngSlot
private ItemStack dspStack = ItemStack.EMPTY;
public SlotInaccessible( final IInventory i, final int slotIdx, final int x, final int y )
public SlotInaccessible( final IItemHandler i, final int slotIdx, final int x, final int y )
{
super( i, slotIdx, x, y );
}
@@ -19,13 +19,13 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class SlotInaccessibleHD extends SlotInaccessible
{
public SlotInaccessibleHD( final IInventory i, final int slotIdx, final int x, final int y )
public SlotInaccessibleHD( final IItemHandler i, final int slotIdx, final int x, final int y )
{
super( i, slotIdx, x, y );
}
@@ -19,8 +19,8 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.container.implementations.ContainerMAC;
@@ -30,7 +30,7 @@ public class SlotMACPattern extends AppEngSlot
private final ContainerMAC mac;
public SlotMACPattern( final ContainerMAC mac, final IInventory i, final int slotIdx, final int x, final int y )
public SlotMACPattern( final ContainerMAC mac, final IItemHandler i, final int slotIdx, final int x, final int y )
{
super( i, slotIdx, x, y );
this.mac = mac;
@@ -19,13 +19,13 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class SlotNormal extends AppEngSlot
{
public SlotNormal( final IInventory inv, final int slot, final int xPos, final int yPos )
public SlotNormal( final IItemHandler inv, final int slot, final int xPos, final int yPos )
{
super( inv, slot, xPos, yPos );
}
@@ -19,14 +19,14 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
public class SlotOutput extends AppEngSlot
{
public SlotOutput( final IInventory a, final int b, final int c, final int d, final int i )
public SlotOutput( final IItemHandler a, final int b, final int c, final int d, final int i )
{
super( a, b, c, d );
this.setIIcon( i );
@@ -19,13 +19,13 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class SlotPatternOutputs extends OptionalSlotFake
{
public SlotPatternOutputs( final IInventory inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
public SlotPatternOutputs( final IItemHandler inv, final IOptionalSlotHost containerBus, final int idx, final int x, final int y, final int offX, final int offY, final int groupNum )
{
super( inv, containerBus, idx, x, y, offX, offY, groupNum );
}
@@ -22,8 +22,8 @@ package appeng.container.slot;
import java.io.IOException;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.items.IItemHandler;
import appeng.api.AEApi;
import appeng.api.networking.energy.IEnergySource;
@@ -40,7 +40,7 @@ public class SlotPatternTerm extends SlotCraftingTerm
private final int groupNum;
private final IOptionalSlotHost host;
public SlotPatternTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IInventory cMatrix, final IInventory secondMatrix, final IInventory output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
public SlotPatternTerm( final EntityPlayer player, final BaseActionSource mySrc, final IEnergySource energySrc, final IStorageMonitorable storage, final IItemHandler cMatrix, final IItemHandler secondMatrix, final IItemHandler output, final int x, final int y, final IOptionalSlotHost h, final int groupNumber, final IContainerCraftingPacket c )
{
super( player, mySrc, energySrc, storage, cMatrix, secondMatrix, output, x, y, c );
@@ -19,13 +19,13 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
public class SlotPlayerHotBar extends AppEngSlot
{
public SlotPlayerHotBar( final IInventory par1iInventory, final int par2, final int par3, final int par4 )
public SlotPlayerHotBar( final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
{
super( par1iInventory, par2, par3, par4 );
this.setPlayerSide( true );
@@ -19,7 +19,7 @@
package appeng.container.slot;
import net.minecraft.inventory.IInventory;
import net.minecraftforge.items.IItemHandler;
// there is nothing special about this slot, its simply used to represent the players inventory, vs a container slot.
@@ -27,7 +27,7 @@ import net.minecraft.inventory.IInventory;
public class SlotPlayerInv extends AppEngSlot
{
public SlotPlayerInv( final IInventory par1iInventory, final int par2, final int par3, final int par4 )
public SlotPlayerInv( final IItemHandler par1iInventory, final int par2, final int par3, final int par4 )
{
super( par1iInventory, par2, par3, par4 );
@@ -22,11 +22,11 @@ package appeng.container.slot;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.init.Items;
import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.world.World;
import net.minecraftforge.items.IItemHandler;
import net.minecraftforge.oredict.OreDictionary;
import appeng.api.AEApi;
@@ -59,7 +59,7 @@ public class SlotRestrictedInput extends AppEngSlot
private boolean allowEdit = true;
private int stackLimit = -1;
public SlotRestrictedInput( final PlacableItemType valid, final IInventory i, final int slotIndex, final int x, final int y, final InventoryPlayer p )
public SlotRestrictedInput( final PlacableItemType valid, final IItemHandler i, final int slotIndex, final int x, final int y, final InventoryPlayer p )
{
super( i, slotIndex, x, y );
this.which = valid;
@@ -106,12 +106,13 @@ public class SlotRestrictedInput extends AppEngSlot
{
return false;
}
if( i.getItem() == Items.AIR )
{
return false;
}
if( !this.inventory.isItemValidForSlot( this.getSlotIndex(), i ) )
if( !super.isItemValid( i ) )
{
return false;
}