Use IItemHandler instead of IInventory internally (#2971)
* Use IItemHandler instead of IInventory internally
This commit is contained in:
@@ -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 );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user