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