Search in sources :

Example 1 with TileEntityLockable

use of net.minecraft.tileentity.TileEntityLockable in project minecolonies by Minecolonies.

the class EntityAIStructureBuilder method getItemStacksOfTileEntity.

/**
     * Get itemStack of tileEntityData. Retrieve the data from the tileEntity.
     *
     * @param compound the tileEntity stored in a compound.
     * @return the list of itemstacks.
     */
private List<ItemStack> getItemStacksOfTileEntity(final NBTTagCompound compound) {
    final List<ItemStack> items = new ArrayList<>();
    final TileEntity tileEntity = TileEntity.create(world, compound);
    if (tileEntity instanceof TileEntityFlowerPot) {
        items.add(((TileEntityFlowerPot) tileEntity).getFlowerItemStack());
    } else if (tileEntity instanceof TileEntityLockable) {
        for (int i = 0; i < ((TileEntityLockable) tileEntity).getSizeInventory(); i++) {
            final ItemStack stack = ((TileEntityLockable) tileEntity).getStackInSlot(i);
            if (stack != null) {
                items.add(stack);
            }
        }
    }
    return items;
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) TileEntityLockable(net.minecraft.tileentity.TileEntityLockable) ArrayList(java.util.ArrayList) ItemStack(net.minecraft.item.ItemStack) TileEntityFlowerPot(net.minecraft.tileentity.TileEntityFlowerPot)

Aggregations

ArrayList (java.util.ArrayList)1 ItemStack (net.minecraft.item.ItemStack)1 TileEntity (net.minecraft.tileentity.TileEntity)1 TileEntityFlowerPot (net.minecraft.tileentity.TileEntityFlowerPot)1 TileEntityLockable (net.minecraft.tileentity.TileEntityLockable)1