Applied-Energistics-2-tiler.../debug/TileItemGen.java

125 lines
2.2 KiB
Java
Raw Normal View History

2014-01-20 17:41:37 +01:00
package appeng.debug;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import appeng.tile.AEBaseTile;
public class TileItemGen extends AEBaseTile implements IInventory
{
public static Queue<ItemStack> possibleItems = new LinkedList();
public TileItemGen() {
if ( possibleItems.isEmpty() )
{
2014-02-09 02:34:52 +01:00
for (Object obj : Item.itemRegistry)
2014-01-20 17:41:37 +01:00
{
2014-02-09 02:34:52 +01:00
Item mi = (Item) obj;
2014-01-20 17:41:37 +01:00
if ( mi != null )
{
if ( mi.isDamageable() )
{
for (int dmg = 0; dmg < mi.getMaxDamage(); dmg++)
possibleItems.add( new ItemStack( mi, 1, dmg ) );
}
else
{
List<ItemStack> list = new ArrayList<ItemStack>();
2014-02-09 02:34:52 +01:00
mi.getSubItems( mi, mi.getCreativeTab(), list );
2014-01-20 17:41:37 +01:00
possibleItems.addAll( list );
}
}
}
}
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
public ItemStack getStackInSlot(int i)
{
return getRandomItem();
}
private ItemStack getRandomItem()
{
return possibleItems.peek();
}
@Override
public ItemStack decrStackSize(int i, int j)
{
ItemStack a = possibleItems.poll();
ItemStack out = a.copy();
possibleItems.add( a );
return out;
}
@Override
public ItemStack getStackInSlotOnClosing(int i)
{
return null;
}
@Override
public void setInventorySlotContents(int i, ItemStack itemstack)
{
ItemStack a = possibleItems.poll();
possibleItems.add( a );
}
@Override
2014-02-09 02:34:52 +01:00
public String getInventoryName()
2014-01-20 17:41:37 +01:00
{
return null;
}
@Override
2014-02-09 02:34:52 +01:00
public boolean hasCustomInventoryName()
2014-01-20 17:41:37 +01:00
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
2014-02-09 02:34:52 +01:00
public void openInventory()
2014-01-20 17:41:37 +01:00
{
}
@Override
2014-02-09 02:34:52 +01:00
public void closeInventory()
2014-01-20 17:41:37 +01:00
{
}
@Override
public boolean isItemValidForSlot(int i, ItemStack itemstack)
{
return false;
}
@Override
public boolean isUseableByPlayer(EntityPlayer entityplayer)
{
return false;
}
}