Applied-Energistics-2-tiler.../src/main/java/appeng/debug/TileItemGen.java

183 lines
3.4 KiB
Java
Raw Normal View History

2014-11-14 12:02:52 +01:00
/*
* 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>.
*/
2014-09-24 02:26:27 +02:00
package appeng.debug;
2014-09-24 02:26:27 +02:00
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;
2015-06-16 02:44:59 +02:00
import net.minecraft.util.IChatComponent;
2014-09-24 02:26:27 +02:00
import appeng.tile.AEBaseTile;
2014-09-24 02:26:27 +02:00
public class TileItemGen extends AEBaseTile implements IInventory
{
private static final Queue<ItemStack> POSSIBLE_ITEMS = new LinkedList<ItemStack>();
2014-09-24 02:26:27 +02:00
public TileItemGen()
{
if( POSSIBLE_ITEMS.isEmpty() )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
for( final Object obj : Item.itemRegistry )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
final Item mi = (Item) obj;
if( mi != null )
2014-09-24 02:26:27 +02:00
{
if( mi.isDamageable() )
2014-09-24 02:26:27 +02:00
{
for( int dmg = 0; dmg < mi.getMaxDamage(); dmg++ )
2015-04-29 02:30:53 +02:00
{
2015-01-01 22:13:10 +01:00
POSSIBLE_ITEMS.add( new ItemStack( mi, 1, dmg ) );
2015-04-29 02:30:53 +02:00
}
2014-09-24 02:26:27 +02:00
}
else
{
2015-09-30 14:24:40 +02:00
final List<ItemStack> list = new ArrayList<ItemStack>();
2014-09-24 02:26:27 +02:00
mi.getSubItems( mi, mi.getCreativeTab(), list );
2015-01-01 22:13:10 +01:00
POSSIBLE_ITEMS.addAll( list );
2014-09-24 02:26:27 +02:00
}
}
}
}
}
@Override
public int getSizeInventory()
{
return 1;
}
@Override
2015-09-30 14:24:40 +02:00
public ItemStack getStackInSlot( final int i )
2014-09-24 02:26:27 +02:00
{
2014-12-29 15:13:47 +01:00
return this.getRandomItem();
2014-09-24 02:26:27 +02:00
}
private ItemStack getRandomItem()
{
2015-01-01 22:13:10 +01:00
return POSSIBLE_ITEMS.peek();
2014-09-24 02:26:27 +02:00
}
@Override
2015-09-30 14:24:40 +02:00
public ItemStack decrStackSize( final int i, final int j )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
final ItemStack a = POSSIBLE_ITEMS.poll();
final ItemStack out = a.copy();
2015-01-01 22:13:10 +01:00
POSSIBLE_ITEMS.add( a );
2014-09-24 02:26:27 +02:00
return out;
}
@Override
2015-09-30 14:24:40 +02:00
public ItemStack getStackInSlotOnClosing( final int i )
2014-09-24 02:26:27 +02:00
{
return null;
}
@Override
2015-09-30 14:24:40 +02:00
public void setInventorySlotContents( final int i, final ItemStack itemstack )
2014-09-24 02:26:27 +02:00
{
2015-09-30 14:24:40 +02:00
final ItemStack a = POSSIBLE_ITEMS.poll();
2015-01-01 22:13:10 +01:00
POSSIBLE_ITEMS.add( a );
2014-09-24 02:26:27 +02:00
}
@Override
2015-09-29 15:47:55 +02:00
public String getCommandSenderName()
2014-09-24 02:26:27 +02:00
{
return null;
}
@Override
2015-06-16 02:44:59 +02:00
public boolean hasCustomName()
2014-09-24 02:26:27 +02:00
{
return false;
}
@Override
public int getInventoryStackLimit()
{
return 1;
}
@Override
2015-09-30 14:24:40 +02:00
public boolean isUseableByPlayer( final EntityPlayer entityplayer )
2014-09-24 02:26:27 +02:00
{
return false;
2014-09-24 02:26:27 +02:00
}
@Override
2015-06-16 02:44:59 +02:00
public void openInventory(
2015-09-30 14:24:40 +02:00
final EntityPlayer player )
2015-06-16 02:44:59 +02:00
{
}
@Override
public void closeInventory(
2015-09-30 14:24:40 +02:00
final EntityPlayer player )
2015-06-16 02:44:59 +02:00
{
}
@Override
2015-09-30 14:24:40 +02:00
public boolean isItemValidForSlot( final int i, final ItemStack itemstack )
2015-06-16 02:44:59 +02:00
{
return false;
}
@Override
public IChatComponent getDisplayName()
2014-09-24 02:26:27 +02:00
{
2015-06-16 02:44:59 +02:00
return null;
}
2014-09-24 02:26:27 +02:00
2015-06-16 02:44:59 +02:00
@Override
public int getField(
2015-09-30 14:24:40 +02:00
final int id )
2015-06-16 02:44:59 +02:00
{
return 0;
2014-09-24 02:26:27 +02:00
}
@Override
2015-06-16 02:44:59 +02:00
public void setField(
2015-09-30 14:24:40 +02:00
final int id,
final int value )
2014-09-24 02:26:27 +02:00
{
2015-06-16 02:44:59 +02:00
}
2015-06-16 02:44:59 +02:00
@Override
public int getFieldCount()
{
return 0;
2014-09-24 02:26:27 +02:00
}
@Override
2015-06-16 02:44:59 +02:00
public void clear()
2014-09-24 02:26:27 +02:00
{
2015-06-16 02:44:59 +02:00
2014-09-24 02:26:27 +02:00
}
}