Re-did grinder input code.

This commit is contained in:
AlgorithmX2 2014-02-11 20:02:21 -06:00
parent 44cfb553ab
commit d8dfe3798e

View file

@ -7,20 +7,15 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import appeng.api.AEApi; import appeng.api.AEApi;
import appeng.api.config.Actionable;
import appeng.api.features.IGrinderEntry; import appeng.api.features.IGrinderEntry;
import appeng.api.implementations.tiles.ICrankable; import appeng.api.implementations.tiles.ICrankable;
import appeng.api.storage.IMEInventory;
import appeng.api.storage.data.IAEItemStack;
import appeng.api.util.WorldCoord; import appeng.api.util.WorldCoord;
import appeng.me.storage.MEIInventoryWrapper;
import appeng.tile.AEBaseInvTile; import appeng.tile.AEBaseInvTile;
import appeng.tile.inventory.AppEngInternalInventory; import appeng.tile.inventory.AppEngInternalInventory;
import appeng.tile.inventory.InvOperation; import appeng.tile.inventory.InvOperation;
import appeng.util.InventoryAdaptor; import appeng.util.InventoryAdaptor;
import appeng.util.Platform; import appeng.util.Platform;
import appeng.util.inv.WrapperInventoryRange; import appeng.util.inv.WrapperInventoryRange;
import appeng.util.item.ItemList;
public class TileGrinder extends AEBaseInvTile implements ICrankable public class TileGrinder extends AEBaseInvTile implements ICrankable
{ {
@ -95,19 +90,27 @@ public class TileGrinder extends AEBaseInvTile implements ICrankable
if ( null == this.getStackInSlot( 6 ) ) // Add if there isn't one... if ( null == this.getStackInSlot( 6 ) ) // Add if there isn't one...
{ {
IMEInventory<IAEItemStack> input = new MEIInventoryWrapper( new WrapperInventoryRange( this, inputs, true ), null ); IInventory src = new WrapperInventoryRange( this, inputs, true );
for (IAEItemStack i : input.getAvailableItems( new ItemList() )) for (int x = 0; x < src.getSizeInventory(); x++)
{ {
IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( i.getItemStack() ); ItemStack item = src.getStackInSlot( x );
if ( item == null )
continue;
IGrinderEntry r = AEApi.instance().registries().grinder().getRecipeForInput( item );
if ( r != null ) if ( r != null )
{ {
if ( i.getStackSize() >= r.getInput().stackSize ) if ( item.stackSize >= r.getInput().stackSize )
{ {
i = i.copy(); item.stackSize -= r.getInput().stackSize;
i.setStackSize( r.getInput().stackSize ); ItemStack ais = item.copy();
IAEItemStack ais = input.extractItems( (IAEItemStack) i, Actionable.MODULATE, null ); ais.stackSize = r.getInput().stackSize;
if ( ais != null )
this.setInventorySlotContents( 6, ais.getItemStack() ); if ( item.stackSize <= 0 )
item = null;
src.setInventorySlotContents( x, item );
this.setInventorySlotContents( 6, ais );
return true; return true;
} }
} }